diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-06-01 15:41:47 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-06-01 15:41:47 +1000 |
| commit | dd27c3530432ea0b09f01e604bf577f31d8ef841 (patch) | |
| tree | bbf86cf81a78f0ff0b07f31f1c390db473f26fd3 /lib/lvgl/examples/widgets/arc | |
| parent | 6fd588e970470b15936187980829916d0dbe77bb (diff) | |
| download | tangara-fw-dd27c3530432ea0b09f01e604bf577f31d8ef841.tar.gz | |
convert lvgl from submodule to a plain old directory
Diffstat (limited to 'lib/lvgl/examples/widgets/arc')
| m--------- | lib/lvgl | 0 | ||||
| -rw-r--r-- | lib/lvgl/examples/widgets/arc/index.rst | 14 | ||||
| -rw-r--r-- | lib/lvgl/examples/widgets/arc/lv_example_arc_1.c | 35 | ||||
| -rw-r--r-- | lib/lvgl/examples/widgets/arc/lv_example_arc_1.py | 8 | ||||
| -rw-r--r-- | lib/lvgl/examples/widgets/arc/lv_example_arc_2.c | 37 | ||||
| -rw-r--r-- | lib/lvgl/examples/widgets/arc/lv_example_arc_2.py | 37 |
6 files changed, 131 insertions, 0 deletions
diff --git a/lib/lvgl b/lib/lvgl deleted file mode 160000 -Subproject 0732400e7b564dd0e7dc4a924619d8e19c5b23a diff --git a/lib/lvgl/examples/widgets/arc/index.rst b/lib/lvgl/examples/widgets/arc/index.rst new file mode 100644 index 00000000..8dea69d5 --- /dev/null +++ b/lib/lvgl/examples/widgets/arc/index.rst @@ -0,0 +1,14 @@ + +Simple Arc +"""""""""""""""" + +.. lv_example:: widgets/arc/lv_example_arc_1 + :language: c + :description: A simple example to demonstrate the use of an arc. + +Loader with Arc +"""""""""""""""" + +.. lv_example:: widgets/arc/lv_example_arc_2 + :language: c + diff --git a/lib/lvgl/examples/widgets/arc/lv_example_arc_1.c b/lib/lvgl/examples/widgets/arc/lv_example_arc_1.c new file mode 100644 index 00000000..e1ff4e86 --- /dev/null +++ b/lib/lvgl/examples/widgets/arc/lv_example_arc_1.c @@ -0,0 +1,35 @@ +#include "../../lv_examples.h" + +#if LV_USE_ARC && LV_BUILD_EXAMPLES + +static void value_changed_event_cb(lv_event_t * e); + +void lv_example_arc_1(void) +{ + lv_obj_t * label = lv_label_create(lv_scr_act()); + + /*Create an Arc*/ + lv_obj_t * arc = lv_arc_create(lv_scr_act()); + lv_obj_set_size(arc, 150, 150); + lv_arc_set_rotation(arc, 135); + lv_arc_set_bg_angles(arc, 0, 270); + lv_arc_set_value(arc, 10); + lv_obj_center(arc); + lv_obj_add_event_cb(arc, value_changed_event_cb, LV_EVENT_VALUE_CHANGED, label); + + /*Manually update the label for the first time*/ + lv_event_send(arc, LV_EVENT_VALUE_CHANGED, NULL); +} + +static void value_changed_event_cb(lv_event_t * e) +{ + lv_obj_t * arc = lv_event_get_target(e); + lv_obj_t * label = lv_event_get_user_data(e); + + lv_label_set_text_fmt(label, "%d%%", lv_arc_get_value(arc)); + + /*Rotate the label to the current position of the arc*/ + lv_arc_rotate_obj_to_angle(arc, label, 25); +} + +#endif diff --git a/lib/lvgl/examples/widgets/arc/lv_example_arc_1.py b/lib/lvgl/examples/widgets/arc/lv_example_arc_1.py new file mode 100644 index 00000000..5220b548 --- /dev/null +++ b/lib/lvgl/examples/widgets/arc/lv_example_arc_1.py @@ -0,0 +1,8 @@ +# Create an Arc +arc = lv.arc(lv.scr_act()) +arc.set_end_angle(200) +arc.set_size(150, 150) +arc.center() + + + diff --git a/lib/lvgl/examples/widgets/arc/lv_example_arc_2.c b/lib/lvgl/examples/widgets/arc/lv_example_arc_2.c new file mode 100644 index 00000000..3b94a75e --- /dev/null +++ b/lib/lvgl/examples/widgets/arc/lv_example_arc_2.c @@ -0,0 +1,37 @@ +#include "../../lv_examples.h" + +#if LV_USE_ARC && LV_BUILD_EXAMPLES + +static void set_angle(void * obj, int32_t v) +{ + lv_arc_set_value(obj, v); +} + +/** + * 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()); + lv_arc_set_rotation(arc, 270); + lv_arc_set_bg_angles(arc, 0, 360); + lv_obj_remove_style(arc, NULL, LV_PART_KNOB); /*Be sure the knob is not displayed*/ + lv_obj_clear_flag(arc, LV_OBJ_FLAG_CLICKABLE); /*To not allow adjusting by click*/ + lv_obj_center(arc); + + lv_anim_t a; + lv_anim_init(&a); + lv_anim_set_var(&a, arc); + lv_anim_set_exec_cb(&a, set_angle); + lv_anim_set_time(&a, 1000); + lv_anim_set_repeat_count(&a, LV_ANIM_REPEAT_INFINITE); /*Just for the demo*/ + lv_anim_set_repeat_delay(&a, 500); + lv_anim_set_values(&a, 0, 100); + lv_anim_start(&a); + + + +} + +#endif diff --git a/lib/lvgl/examples/widgets/arc/lv_example_arc_2.py b/lib/lvgl/examples/widgets/arc/lv_example_arc_2.py new file mode 100644 index 00000000..91336e2a --- /dev/null +++ b/lib/lvgl/examples/widgets/arc/lv_example_arc_2.py @@ -0,0 +1,37 @@ +# +# An `lv_timer` to call periodically to set the angles of the arc +# +class ArcLoader(): + def __init__(self): + self.a = 270 + + def arc_loader_cb(self,tim,arc): + # print(tim,arc) + self.a += 5 + + arc.set_end_angle(self.a) + + if self.a >= 270 + 360: + tim._del() + + +# +# Create an arc which acts as a loader. +# + +# Create an Arc +arc = lv.arc(lv.scr_act()) +arc.set_bg_angles(0, 360) +arc.set_angles(270, 270) +arc.center() + +# create the loader +arc_loader = ArcLoader() + +# Create an `lv_timer` to update the arc. + +timer = lv.timer_create_basic() +timer.set_period(20) +timer.set_cb(lambda src: arc_loader.arc_loader_cb(timer,arc)) + + |
