update asserts
This commit is contained in:
14
examples/widgets/arc/lv_example_arc_1.c
Normal file
14
examples/widgets/arc/lv_example_arc_1.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_ARC
|
||||
|
||||
void lv_example_arc_1(void)
|
||||
{
|
||||
/*Create an Arc*/
|
||||
lv_obj_t * arc = lv_arc_create(lv_scr_act(), NULL);
|
||||
lv_arc_set_end_angle(arc, 200);
|
||||
lv_obj_set_size(arc, 150, 150);
|
||||
lv_obj_align(arc, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
12
examples/widgets/arc/lv_example_arc_1.py
Normal file
12
examples/widgets/arc/lv_example_arc_1.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# Create style for the Arcs
|
||||
style = lv.style_t()
|
||||
lv.style_copy(style, lv.style_plain)
|
||||
style.line.color = lv.color_make(0,0,255) # Arc color
|
||||
style.line.width = 8 # Arc width
|
||||
|
||||
# Create an Arc
|
||||
arc = lv.arc(lv.scr_act())
|
||||
arc.set_style(lv.arc.STYLE.MAIN, style) # Use the new style
|
||||
arc.set_angles(90, 60)
|
||||
arc.set_size(150, 150)
|
||||
arc.align(None, lv.ALIGN.CENTER, 0, 0)
|
||||
38
examples/widgets/arc/lv_example_arc_2.c
Normal file
38
examples/widgets/arc/lv_example_arc_2.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "../../../lvgl.h"
|
||||
#if LV_USE_ARC
|
||||
|
||||
/**
|
||||
* An `lv_task` to call periodically to set the angles of the arc
|
||||
* @param t
|
||||
*/
|
||||
static void arc_loader(lv_timer_t * t)
|
||||
{
|
||||
static int16_t a = 270;
|
||||
|
||||
a+=5;
|
||||
|
||||
lv_arc_set_end_angle(t->user_data, a);
|
||||
|
||||
if(a >= 270 + 360) {
|
||||
lv_timer_del(t);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an arc which acts as a loader.
|
||||
*/
|
||||
void lv_example_arc_2(void)
|
||||
{
|
||||
/*Create an Arc*/
|
||||
lv_obj_t * arc = lv_arc_create(lv_scr_act(), NULL);
|
||||
lv_arc_set_bg_angles(arc, 0, 360);
|
||||
lv_arc_set_angles(arc, 270, 270);
|
||||
lv_obj_align(arc, NULL, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
/* Create an `lv_task` to update the arc.
|
||||
* Store the `arc` in the user data*/
|
||||
lv_timer_create(arc_loader, 20, arc);
|
||||
}
|
||||
|
||||
#endif
|
||||
43
examples/widgets/arc/lv_example_arc_2.py
Normal file
43
examples/widgets/arc/lv_example_arc_2.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# Create an arc which acts as a loader.
|
||||
class loader_arc(lv.arc):
|
||||
|
||||
def __init__(self, parent, color=lv.color_hex(0x000080),
|
||||
width=8, style=lv.style_plain, rate=20):
|
||||
super().__init__(parent)
|
||||
|
||||
self.a = 0
|
||||
self.rate = rate
|
||||
|
||||
# Create style for the Arcs
|
||||
self.style = lv.style_t()
|
||||
lv.style_copy(self.style, style)
|
||||
self.style.line.color = color
|
||||
self.style.line.width = width
|
||||
|
||||
# Create an Arc
|
||||
self.set_angles(180, 180);
|
||||
self.set_style(self.STYLE.MAIN, self.style);
|
||||
|
||||
# Spin the Arc
|
||||
self.spin()
|
||||
|
||||
def spin(self):
|
||||
# Create an `lv_task` to update the arc.
|
||||
lv.task_create(self.task_cb, self.rate, lv.TASK_PRIO.LOWEST, {})
|
||||
|
||||
|
||||
# An `lv_task` to call periodically to set the angles of the arc
|
||||
def task_cb(self, task):
|
||||
self.a+=5;
|
||||
if self.a >= 359: self.a = 359
|
||||
|
||||
if self.a < 180: self.set_angles(180-self.a, 180)
|
||||
else: self.set_angles(540-self.a, 180)
|
||||
|
||||
if self.a == 359:
|
||||
self.a = 0
|
||||
lv.task_del(task)
|
||||
|
||||
# Create a loader arc
|
||||
loader_arc = loader_arc(lv.scr_act())
|
||||
loader_arc.align(None, lv.ALIGN.CENTER, 0, 0)
|
||||
Reference in New Issue
Block a user