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/calendar | |
| 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/calendar')
| m--------- | lib/lvgl | 0 | ||||
| -rw-r--r-- | lib/lvgl/examples/widgets/calendar/index.rst | 7 | ||||
| -rw-r--r-- | lib/lvgl/examples/widgets/calendar/lv_example_calendar_1.c | 51 | ||||
| -rw-r--r-- | lib/lvgl/examples/widgets/calendar/lv_example_calendar_1.py | 30 |
4 files changed, 88 insertions, 0 deletions
diff --git a/lib/lvgl b/lib/lvgl deleted file mode 160000 -Subproject 0732400e7b564dd0e7dc4a924619d8e19c5b23a diff --git a/lib/lvgl/examples/widgets/calendar/index.rst b/lib/lvgl/examples/widgets/calendar/index.rst new file mode 100644 index 00000000..831fb1e4 --- /dev/null +++ b/lib/lvgl/examples/widgets/calendar/index.rst @@ -0,0 +1,7 @@ + +Calendar with header +"""""""""""""""""""""" + +.. lv_example:: widgets/calendar/lv_example_calendar_1 + :language: c + diff --git a/lib/lvgl/examples/widgets/calendar/lv_example_calendar_1.c b/lib/lvgl/examples/widgets/calendar/lv_example_calendar_1.c new file mode 100644 index 00000000..e76df2ed --- /dev/null +++ b/lib/lvgl/examples/widgets/calendar/lv_example_calendar_1.c @@ -0,0 +1,51 @@ +#include "../../lv_examples.h" +#if LV_USE_CALENDAR && LV_BUILD_EXAMPLES + +static void event_handler(lv_event_t * e) +{ + lv_event_code_t code = lv_event_get_code(e); + lv_obj_t * obj = lv_event_get_current_target(e); + + if(code == LV_EVENT_VALUE_CHANGED) { + lv_calendar_date_t date; + if(lv_calendar_get_pressed_date(obj, &date)) { + LV_LOG_USER("Clicked date: %02d.%02d.%d", date.day, date.month, date.year); + } + } +} + +void lv_example_calendar_1(void) +{ + lv_obj_t * calendar = lv_calendar_create(lv_scr_act()); + lv_obj_set_size(calendar, 185, 185); + lv_obj_align(calendar, LV_ALIGN_CENTER, 0, 27); + lv_obj_add_event_cb(calendar, event_handler, LV_EVENT_ALL, NULL); + + lv_calendar_set_today_date(calendar, 2021, 02, 23); + lv_calendar_set_showed_date(calendar, 2021, 02); + + /*Highlight a few days*/ + static lv_calendar_date_t highlighted_days[3]; /*Only its pointer will be saved so should be static*/ + highlighted_days[0].year = 2021; + highlighted_days[0].month = 02; + highlighted_days[0].day = 6; + + highlighted_days[1].year = 2021; + highlighted_days[1].month = 02; + highlighted_days[1].day = 11; + + highlighted_days[2].year = 2022; + highlighted_days[2].month = 02; + highlighted_days[2].day = 22; + + lv_calendar_set_highlighted_dates(calendar, highlighted_days, 3); + +#if LV_USE_CALENDAR_HEADER_DROPDOWN + lv_calendar_header_dropdown_create(calendar); +#elif LV_USE_CALENDAR_HEADER_ARROW + lv_calendar_header_arrow_create(calendar); +#endif + lv_calendar_set_showed_date(calendar, 2021, 10); +} + +#endif diff --git a/lib/lvgl/examples/widgets/calendar/lv_example_calendar_1.py b/lib/lvgl/examples/widgets/calendar/lv_example_calendar_1.py new file mode 100644 index 00000000..2df024d0 --- /dev/null +++ b/lib/lvgl/examples/widgets/calendar/lv_example_calendar_1.py @@ -0,0 +1,30 @@ + +def event_handler(evt): + code = evt.get_code() + + if code == lv.EVENT.VALUE_CHANGED: + source = evt.get_current_target() + date = lv.calendar_date_t() + if source.get_pressed_date(date) == lv.RES.OK: + calendar.set_today_date(date.year, date.month, date.day) + print("Clicked date: %02d.%02d.%02d"%(date.day, date.month, date.year)) + + +calendar = lv.calendar(lv.scr_act()) +calendar.set_size(200, 200) +calendar.align(lv.ALIGN.CENTER, 0, 20) +calendar.add_event_cb(event_handler, lv.EVENT.ALL, None) + +calendar.set_today_date(2021, 02, 23) +calendar.set_showed_date(2021, 02) + +# Highlight a few days +highlighted_days=[ + lv.calendar_date_t({'year':2021, 'month':2, 'day':6}), + lv.calendar_date_t({'year':2021, 'month':2, 'day':11}), + lv.calendar_date_t({'year':2021, 'month':2, 'day':22}) +] + +calendar.set_highlighted_dates(highlighted_days, len(highlighted_days)) + +lv.calendar_header_dropdown(calendar) |
