From 762296464b3d7dbd3a0521e6569e2a62287c94cd Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Fri, 8 Oct 2021 08:40:42 -0400 Subject: [PATCH 01/25] Update submodule to lvgl v8.0 --- .gitmodules | 3 ++- src/libs/lvgl | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 815fc022be..c1b4efc9b4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,7 @@ [submodule "src/libs/lvgl"] path = src/libs/lvgl - url = https://github.com/joaquimorg/lvgl.git + url = https://github.com/lvgl/lvgl.git + branch = release/v8.0 [submodule "src/libs/littlefs"] path = src/libs/littlefs url = https://github.com/littlefs-project/littlefs.git diff --git a/src/libs/lvgl b/src/libs/lvgl index 23430cf20e..14825e03fa 160000 --- a/src/libs/lvgl +++ b/src/libs/lvgl @@ -1 +1 @@ -Subproject commit 23430cf20e32294549fff9b2879a9466dacc19bb +Subproject commit 14825e03fa06184b7583727bc6604b16a67377f5 From 4070292cdc4df2302ffc7d8e08a1cf1bf8026c82 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Fri, 8 Oct 2021 11:06:42 -0400 Subject: [PATCH 02/25] First pass update to lvgl v8.0 It builds and I have gotten output using my hacks to dev on my nrf52833-DK, but it quickly crashes with memory issues. I have traced freeRTOS stack overflows on tasks with previous `usStackDepth` values: - "MAIN" - "displayapp" - "Heartrate" I've tried tweaking the stack/heap values but have always experienced memory corruption errors. I'm currently waiting for my pinetime devkit to arrive :) I've also enabled `configCHECK_FOR_STACK_OVERFLOW` and put a basic implementation of `vApplicationStackOverflowHook` in `rtoshook.c`. You need to set a breakpoint to read the task name unless you put in a log statement. --- src/CMakeLists.txt | 355 ++-- src/FreeRTOSConfig.h | 2 +- src/components/fs/FS.cpp | 29 +- src/components/fs/FS.h | 2 +- src/displayapp/Colors.cpp | 36 +- src/displayapp/Colors.h | 2 +- src/displayapp/DummyLittleVgl.h | 6 +- src/displayapp/LittleVgl.cpp | 41 +- src/displayapp/LittleVgl.h | 2 +- .../jetbrains_mono_extrabold_compressed.c | 2 +- src/displayapp/lv_pinetime_theme.c | 1453 +++++++++++------ src/displayapp/lv_pinetime_theme.h | 19 +- src/displayapp/screens/Alarm.cpp | 90 +- src/displayapp/screens/Alarm.h | 2 +- src/displayapp/screens/BatteryInfo.cpp | 54 +- src/displayapp/screens/BatteryInfo.h | 2 +- src/displayapp/screens/Brightness.cpp | 19 +- src/displayapp/screens/Brightness.h | 2 +- src/displayapp/screens/Clock.h | 2 +- src/displayapp/screens/DropDownDemo.cpp | 4 +- src/displayapp/screens/FirmwareUpdate.cpp | 24 +- src/displayapp/screens/FirmwareUpdate.h | 4 +- src/displayapp/screens/FirmwareValidation.cpp | 44 +- src/displayapp/screens/FirmwareValidation.h | 4 +- src/displayapp/screens/FlashLight.cpp | 38 +- src/displayapp/screens/FlashLight.h | 2 +- src/displayapp/screens/HeartRate.cpp | 46 +- src/displayapp/screens/HeartRate.h | 8 +- src/displayapp/screens/InfiniPaint.cpp | 16 +- src/displayapp/screens/InfiniPaint.h | 2 +- src/displayapp/screens/Label.cpp | 16 +- src/displayapp/screens/List.cpp | 61 +- src/displayapp/screens/List.h | 2 +- src/displayapp/screens/Meter.cpp | 26 +- src/displayapp/screens/Meter.h | 8 +- src/displayapp/screens/Metronome.cpp | 76 +- src/displayapp/screens/Metronome.h | 6 +- src/displayapp/screens/Motion.cpp | 40 +- src/displayapp/screens/Motion.h | 6 +- src/displayapp/screens/Music.cpp | 122 +- src/displayapp/screens/Music.h | 6 +- src/displayapp/screens/Navigation.cpp | 44 +- src/displayapp/screens/Navigation.h | 4 +- src/displayapp/screens/Notifications.cpp | 106 +- src/displayapp/screens/Notifications.h | 4 +- src/displayapp/screens/Paddle.cpp | 33 +- src/displayapp/screens/Paddle.h | 2 +- src/displayapp/screens/PineTimeStyle.cpp | 187 +-- src/displayapp/screens/PineTimeStyle.h | 10 +- src/displayapp/screens/Screen.cpp | 2 +- src/displayapp/screens/Screen.h | 2 +- src/displayapp/screens/Steps.cpp | 44 +- src/displayapp/screens/Steps.h | 2 +- src/displayapp/screens/StopWatch.cpp | 104 +- src/displayapp/screens/StopWatch.h | 6 +- src/displayapp/screens/SystemInfo.cpp | 21 +- src/displayapp/screens/Tile.cpp | 64 +- src/displayapp/screens/Tile.h | 2 +- src/displayapp/screens/Timer.cpp | 62 +- src/displayapp/screens/Timer.h | 4 +- src/displayapp/screens/Twos.cpp | 121 +- src/displayapp/screens/Twos.h | 3 +- src/displayapp/screens/WatchFaceAnalog.cpp | 89 +- src/displayapp/screens/WatchFaceAnalog.h | 4 +- src/displayapp/screens/WatchFaceDigital.cpp | 100 +- src/displayapp/screens/WatchFaceDigital.h | 4 +- .../screens/settings/QuickSettings.cpp | 94 +- .../screens/settings/QuickSettings.h | 4 +- .../screens/settings/SettingDisplay.cpp | 68 +- .../screens/settings/SettingDisplay.h | 2 +- .../screens/settings/SettingPineTimeStyle.cpp | 326 ++-- .../screens/settings/SettingPineTimeStyle.h | 24 +- .../screens/settings/SettingSteps.cpp | 72 +- .../screens/settings/SettingSteps.h | 6 +- .../screens/settings/SettingTimeFormat.cpp | 55 +- .../screens/settings/SettingTimeFormat.h | 2 +- .../screens/settings/SettingWakeUp.cpp | 64 +- .../screens/settings/SettingWakeUp.h | 2 +- .../screens/settings/SettingWatchFace.cpp | 62 +- .../screens/settings/SettingWatchFace.h | 2 +- src/libs/lv_conf.h | 843 ++++------ src/rtoshook.c | 15 + 82 files changed, 2822 insertions(+), 2524 deletions(-) create mode 100644 src/rtoshook.c diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 37ee0848bd..b90aec6983 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -87,7 +87,7 @@ set(SDK_SOURCE_FILES # GPIOTE "${NRF5_SDK_PATH}/components/libraries/gpiote/app_gpiote.c" - ) + rtoshook.c) set(TINYCRYPT_SRC libs/mynewt-nimble/ext/tinycrypt/src/aes_encrypt.c @@ -183,178 +183,199 @@ set(LVGL_SRC libs/lvgl/src/lvgl.h libs/lvgl/src/lv_api_map.h libs/lvgl/src/lv_conf_internal.h - libs/lvgl/src/lv_core/lv_disp.h - libs/lvgl/src/lv_core/lv_group.h - libs/lvgl/src/lv_core/lv_indev.h - libs/lvgl/src/lv_core/lv_obj.h - libs/lvgl/src/lv_core/lv_obj_style_dec.h - libs/lvgl/src/lv_core/lv_refr.h - libs/lvgl/src/lv_core/lv_style.h - libs/lvgl/src/lv_draw/lv_draw.h - libs/lvgl/src/lv_draw/lv_draw_arc.h - libs/lvgl/src/lv_draw/lv_draw_blend.h - libs/lvgl/src/lv_draw/lv_draw_img.h - libs/lvgl/src/lv_draw/lv_draw_label.h - libs/lvgl/src/lv_draw/lv_draw_line.h - libs/lvgl/src/lv_draw/lv_draw_mask.h - libs/lvgl/src/lv_draw/lv_draw_rect.h - libs/lvgl/src/lv_draw/lv_draw_triangle.h - libs/lvgl/src/lv_draw/lv_img_buf.h - libs/lvgl/src/lv_draw/lv_img_cache.h - libs/lvgl/src/lv_draw/lv_img_decoder.h - libs/lvgl/src/lv_font/lv_font.h - libs/lvgl/src/lv_font/lv_font_fmt_txt.h - libs/lvgl/src/lv_font/lv_font_loader.h - libs/lvgl/src/lv_font/lv_symbol_def.h - libs/lvgl/src/lv_hal/lv_hal.h - libs/lvgl/src/lv_hal/lv_hal_disp.h - libs/lvgl/src/lv_hal/lv_hal_indev.h - libs/lvgl/src/lv_hal/lv_hal_tick.h - libs/lvgl/src/lv_misc/lv_anim.h - libs/lvgl/src/lv_misc/lv_area.h - libs/lvgl/src/lv_misc/lv_async.h - libs/lvgl/src/lv_misc/lv_bidi.h - libs/lvgl/src/lv_misc/lv_color.h - libs/lvgl/src/lv_misc/lv_debug.h - libs/lvgl/src/lv_misc/lv_fs.h - libs/lvgl/src/lv_misc/lv_gc.h - libs/lvgl/src/lv_misc/lv_ll.h - libs/lvgl/src/lv_misc/lv_log.h - libs/lvgl/src/lv_misc/lv_math.h - libs/lvgl/src/lv_misc/lv_mem.h - libs/lvgl/src/lv_misc/lv_printf.h - libs/lvgl/src/lv_misc/lv_task.h - libs/lvgl/src/lv_misc/lv_templ.h - libs/lvgl/src/lv_misc/lv_txt.h - libs/lvgl/src/lv_misc/lv_txt_ap.h - libs/lvgl/src/lv_misc/lv_types.h - libs/lvgl/src/lv_misc/lv_utils.h - libs/lvgl/src/lv_themes/lv_theme.h - libs/lvgl/src/lv_themes/lv_theme_empty.h - libs/lvgl/src/lv_themes/lv_theme_material.h + libs/lvgl/src/core/lv_disp.h + libs/lvgl/src/core/lv_event.h + libs/lvgl/src/core/lv_group.h + libs/lvgl/src/core/lv_indev.h + libs/lvgl/src/core/lv_indev_scroll.h + libs/lvgl/src/core/lv_obj.h + libs/lvgl/src/core/lv_obj_class.h + libs/lvgl/src/core/lv_obj_draw.h + libs/lvgl/src/core/lv_obj_pos.h + libs/lvgl/src/core/lv_obj_scroll.h + libs/lvgl/src/misc/lv_style.h + libs/lvgl/src/misc/lv_style_gen.h + libs/lvgl/src/core/lv_obj_style.h + libs/lvgl/src/core/lv_obj_style_gen.h + libs/lvgl/src/core/lv_obj_tree.h + libs/lvgl/src/core/lv_refr.h + libs/lvgl/src/draw/lv_draw.h + libs/lvgl/src/draw/lv_draw_arc.h + libs/lvgl/src/draw/lv_draw_blend.h + libs/lvgl/src/draw/lv_draw_img.h + libs/lvgl/src/draw/lv_draw_label.h + libs/lvgl/src/draw/lv_draw_line.h + libs/lvgl/src/draw/lv_draw_mask.h + libs/lvgl/src/draw/lv_draw_rect.h + libs/lvgl/src/draw/lv_draw_triangle.h + libs/lvgl/src/draw/lv_img_buf.h + libs/lvgl/src/draw/lv_img_cache.h + libs/lvgl/src/draw/lv_img_decoder.h + libs/lvgl/src/font/lv_font.h + libs/lvgl/src/font/lv_font_fmt_txt.h + libs/lvgl/src/font/lv_font_loader.h + libs/lvgl/src/font/lv_symbol_def.h + libs/lvgl/src/hal/lv_hal.h + libs/lvgl/src/hal/lv_hal_disp.h + libs/lvgl/src/hal/lv_hal_indev.h + libs/lvgl/src/hal/lv_hal_tick.h + libs/lvgl/src/misc/lv_anim.h + libs/lvgl/src/misc/lv_area.h + libs/lvgl/src/misc/lv_async.h + libs/lvgl/src/misc/lv_bidi.h + libs/lvgl/src/misc/lv_color.h + libs/lvgl/src/misc/lv_fs.h + libs/lvgl/src/misc/lv_gc.h + libs/lvgl/src/misc/lv_ll.h + libs/lvgl/src/misc/lv_log.h + libs/lvgl/src/misc/lv_math.h + libs/lvgl/src/misc/lv_mem.h + libs/lvgl/src/misc/lv_printf.h + libs/lvgl/src/misc/lv_timer.h + libs/lvgl/src/misc/lv_tlsf.h + libs/lvgl/src/misc/lv_templ.h + libs/lvgl/src/misc/lv_txt.h + libs/lvgl/src/misc/lv_txt_ap.h + libs/lvgl/src/misc/lv_types.h + libs/lvgl/src/misc/lv_utils.h + libs/lvgl/src/core/lv_theme.h + libs/lvgl/src/extra/lv_extra.h + libs/lvgl/src/extra/themes/lv_themes.h + libs/lvgl/src/extra/themes/basic/lv_theme_basic.h #libs/lvgl/src/lv_themes/lv_theme_mono.h #libs/lvgl/src/lv_themes/lv_theme_template.h - libs/lvgl/src/lv_widgets/lv_arc.h - libs/lvgl/src/lv_widgets/lv_bar.h - libs/lvgl/src/lv_widgets/lv_btn.h - libs/lvgl/src/lv_widgets/lv_btnmatrix.h - libs/lvgl/src/lv_widgets/lv_calendar.h - libs/lvgl/src/lv_widgets/lv_canvas.h - libs/lvgl/src/lv_widgets/lv_chart.h - libs/lvgl/src/lv_widgets/lv_checkbox.h - libs/lvgl/src/lv_widgets/lv_cont.h - libs/lvgl/src/lv_widgets/lv_cpicker.h - libs/lvgl/src/lv_widgets/lv_dropdown.h - libs/lvgl/src/lv_widgets/lv_gauge.h - libs/lvgl/src/lv_widgets/lv_img.h - libs/lvgl/src/lv_widgets/lv_imgbtn.h - libs/lvgl/src/lv_widgets/lv_keyboard.h - libs/lvgl/src/lv_widgets/lv_label.h - libs/lvgl/src/lv_widgets/lv_led.h - libs/lvgl/src/lv_widgets/lv_line.h - libs/lvgl/src/lv_widgets/lv_linemeter.h - libs/lvgl/src/lv_widgets/lv_list.h - libs/lvgl/src/lv_widgets/lv_msgbox.h - libs/lvgl/src/lv_widgets/lv_objmask.h - libs/lvgl/src/lv_widgets/lv_objx_templ.h - libs/lvgl/src/lv_widgets/lv_page.h - libs/lvgl/src/lv_widgets/lv_roller.h - libs/lvgl/src/lv_widgets/lv_slider.h - libs/lvgl/src/lv_widgets/lv_spinbox.h - libs/lvgl/src/lv_widgets/lv_spinner.h - libs/lvgl/src/lv_widgets/lv_switch.h - libs/lvgl/src/lv_widgets/lv_table.h - libs/lvgl/src/lv_widgets/lv_tabview.h - libs/lvgl/src/lv_widgets/lv_textarea.h - libs/lvgl/src/lv_widgets/lv_tileview.h - libs/lvgl/src/lv_widgets/lv_win.h - libs/lvgl/src/lv_core/lv_disp.c - libs/lvgl/src/lv_core/lv_group.c - libs/lvgl/src/lv_core/lv_indev.c - libs/lvgl/src/lv_core/lv_obj.c - libs/lvgl/src/lv_core/lv_refr.c - libs/lvgl/src/lv_core/lv_style.c - libs/lvgl/src/lv_draw/lv_draw_arc.c - libs/lvgl/src/lv_draw/lv_draw_blend.c - libs/lvgl/src/lv_draw/lv_draw_img.c - libs/lvgl/src/lv_draw/lv_draw_label.c - libs/lvgl/src/lv_draw/lv_draw_line.c - libs/lvgl/src/lv_draw/lv_draw_mask.c - libs/lvgl/src/lv_draw/lv_draw_rect.c - libs/lvgl/src/lv_draw/lv_draw_triangle.c - libs/lvgl/src/lv_draw/lv_img_buf.c - libs/lvgl/src/lv_draw/lv_img_cache.c - libs/lvgl/src/lv_draw/lv_img_decoder.c - libs/lvgl/src/lv_font/lv_font.c - #libs/lvgl/src/lv_font/lv_font_dejavu_16_persian_hebrew.c - libs/lvgl/src/lv_font/lv_font_fmt_txt.c - libs/lvgl/src/lv_font/lv_font_loader.c + libs/lvgl/src/widgets/lv_arc.h + libs/lvgl/src/widgets/lv_bar.h + libs/lvgl/src/widgets/lv_btn.h + libs/lvgl/src/widgets/lv_btnmatrix.h + libs/lvgl/src/extra/widgets/calendar/lv_calendar.h + libs/lvgl/src/extra/widgets/calendar/lv_calendar_header_arrow.h + libs/lvgl/src/extra/widgets/calendar/lv_calendar_header_dropdown.h + libs/lvgl/src/widgets/lv_canvas.h + libs/lvgl/src/extra/widgets/chart/lv_chart.h + libs/lvgl/src/widgets/lv_checkbox.h + libs/lvgl/src/extra/widgets/colorwheel/lv_colorwheel.h + libs/lvgl/src/widgets/lv_dropdown.h + libs/lvgl/src/widgets/lv_img.h + libs/lvgl/src/extra/widgets/imgbtn/lv_imgbtn.h + libs/lvgl/src/extra/widgets/keyboard/lv_keyboard.h + libs/lvgl/src/widgets/lv_label.h + libs/lvgl/src/extra/widgets/led/lv_led.h + libs/lvgl/src/widgets/lv_line.h + libs/lvgl/src/extra/widgets/meter/lv_meter.h + libs/lvgl/src/extra/widgets/list/lv_list.h + libs/lvgl/src/extra/widgets/msgbox/lv_msgbox.h + libs/lvgl/src/widgets/lv_objx_templ.h + libs/lvgl/src/widgets/lv_roller.h + libs/lvgl/src/widgets/lv_slider.h + libs/lvgl/src/extra/widgets/spinbox/lv_spinbox.h + libs/lvgl/src/extra/widgets/spinner/lv_spinner.h + libs/lvgl/src/widgets/lv_switch.h + libs/lvgl/src/widgets/lv_table.h + libs/lvgl/src/extra/widgets/tabview/lv_tabview.h + libs/lvgl/src/widgets/lv_textarea.h + libs/lvgl/src/extra/widgets/tileview/lv_tileview.h + libs/lvgl/src/extra/widgets/win/lv_win.h + libs/lvgl/src/extra/layouts/flex/lv_flex.h + libs/lvgl/src/extra/layouts/grid/lv_grid.h + libs/lvgl/src/core/lv_disp.c + libs/lvgl/src/core/lv_event.c + libs/lvgl/src/core/lv_group.c + libs/lvgl/src/core/lv_indev.c + libs/lvgl/src/core/lv_indev_scroll.c + libs/lvgl/src/core/lv_obj.c + libs/lvgl/src/core/lv_obj_class.c + libs/lvgl/src/core/lv_obj_draw.c + libs/lvgl/src/core/lv_obj_pos.c + libs/lvgl/src/core/lv_obj_scroll.c + libs/lvgl/src/core/lv_refr.c + libs/lvgl/src/misc/lv_style.c + libs/lvgl/src/misc/lv_style_gen.c + libs/lvgl/src/core/lv_obj_style.c + libs/lvgl/src/core/lv_obj_style_gen.c + libs/lvgl/src/core/lv_obj_tree.c + libs/lvgl/src/draw/lv_draw_arc.c + libs/lvgl/src/draw/lv_draw_blend.c + libs/lvgl/src/draw/lv_draw_img.c + libs/lvgl/src/draw/lv_draw_label.c + libs/lvgl/src/draw/lv_draw_line.c + libs/lvgl/src/draw/lv_draw_mask.c + libs/lvgl/src/draw/lv_draw_rect.c + libs/lvgl/src/draw/lv_draw_triangle.c + libs/lvgl/src/draw/lv_img_buf.c + libs/lvgl/src/draw/lv_img_cache.c + libs/lvgl/src/draw/lv_img_decoder.c + libs/lvgl/src/font/lv_font.c + #libs/lvgl/src/font/lv_font_dejavu_16_persian_hebrew.c + libs/lvgl/src/font/lv_font_fmt_txt.c + libs/lvgl/src/font/lv_font_loader.c # LVGL Fonts - libs/lvgl/src/lv_font/lv_font_montserrat_14.c - libs/lvgl/src/lv_font/lv_font_montserrat_18.c - libs/lvgl/src/lv_font/lv_font_montserrat_22.c - libs/lvgl/src/lv_font/lv_font_montserrat_28.c + libs/lvgl/src/font/lv_font_montserrat_14.c + libs/lvgl/src/font/lv_font_montserrat_18.c + libs/lvgl/src/font/lv_font_montserrat_22.c + libs/lvgl/src/font/lv_font_montserrat_28.c # - libs/lvgl/src/lv_hal/lv_hal_disp.c - libs/lvgl/src/lv_hal/lv_hal_indev.c - libs/lvgl/src/lv_hal/lv_hal_tick.c - libs/lvgl/src/lv_misc/lv_anim.c - libs/lvgl/src/lv_misc/lv_area.c - libs/lvgl/src/lv_misc/lv_async.c - libs/lvgl/src/lv_misc/lv_bidi.c - libs/lvgl/src/lv_misc/lv_color.c - libs/lvgl/src/lv_misc/lv_debug.c - libs/lvgl/src/lv_misc/lv_fs.c - libs/lvgl/src/lv_misc/lv_gc.c - libs/lvgl/src/lv_misc/lv_ll.c - libs/lvgl/src/lv_misc/lv_log.c - libs/lvgl/src/lv_misc/lv_math.c - libs/lvgl/src/lv_misc/lv_mem.c - libs/lvgl/src/lv_misc/lv_printf.c - libs/lvgl/src/lv_misc/lv_task.c - libs/lvgl/src/lv_misc/lv_templ.c - libs/lvgl/src/lv_misc/lv_txt.c - libs/lvgl/src/lv_misc/lv_txt_ap.c - libs/lvgl/src/lv_misc/lv_utils.c - libs/lvgl/src/lv_themes/lv_theme.c - libs/lvgl/src/lv_themes/lv_theme_empty.c - libs/lvgl/src/lv_themes/lv_theme_material.c + libs/lvgl/src/hal/lv_hal_disp.c + libs/lvgl/src/hal/lv_hal_indev.c + libs/lvgl/src/hal/lv_hal_tick.c + libs/lvgl/src/misc/lv_anim.c + libs/lvgl/src/misc/lv_area.c + libs/lvgl/src/misc/lv_async.c + libs/lvgl/src/misc/lv_bidi.c + libs/lvgl/src/misc/lv_color.c + libs/lvgl/src/misc/lv_fs.c + libs/lvgl/src/misc/lv_gc.c + libs/lvgl/src/misc/lv_ll.c + libs/lvgl/src/misc/lv_log.c + libs/lvgl/src/misc/lv_math.c + libs/lvgl/src/misc/lv_mem.c + libs/lvgl/src/misc/lv_printf.c + libs/lvgl/src/misc/lv_timer.c + libs/lvgl/src/misc/lv_tlsf.c + libs/lvgl/src/misc/lv_templ.c + libs/lvgl/src/misc/lv_txt.c + libs/lvgl/src/misc/lv_txt_ap.c + libs/lvgl/src/misc/lv_utils.c + libs/lvgl/src/core/lv_theme.c + libs/lvgl/src/extra/lv_extra.c + libs/lvgl/src/extra/themes/lv_themes.h + libs/lvgl/src/extra/themes/basic/lv_theme_basic.h #libs/lvgl/src/lv_themes/lv_theme_mono.c #libs/lvgl/src/lv_themes/lv_theme_template.c - libs/lvgl/src/lv_widgets/lv_arc.c - libs/lvgl/src/lv_widgets/lv_bar.c - libs/lvgl/src/lv_widgets/lv_btn.c - libs/lvgl/src/lv_widgets/lv_btnmatrix.c - libs/lvgl/src/lv_widgets/lv_calendar.c - libs/lvgl/src/lv_widgets/lv_canvas.c - libs/lvgl/src/lv_widgets/lv_chart.c - libs/lvgl/src/lv_widgets/lv_checkbox.c - libs/lvgl/src/lv_widgets/lv_cont.c - libs/lvgl/src/lv_widgets/lv_cpicker.c - libs/lvgl/src/lv_widgets/lv_dropdown.c - libs/lvgl/src/lv_widgets/lv_gauge.c - libs/lvgl/src/lv_widgets/lv_img.c - libs/lvgl/src/lv_widgets/lv_imgbtn.c - libs/lvgl/src/lv_widgets/lv_keyboard.c - libs/lvgl/src/lv_widgets/lv_label.c - libs/lvgl/src/lv_widgets/lv_led.c - libs/lvgl/src/lv_widgets/lv_line.c - libs/lvgl/src/lv_widgets/lv_linemeter.c - libs/lvgl/src/lv_widgets/lv_list.c - libs/lvgl/src/lv_widgets/lv_msgbox.c - libs/lvgl/src/lv_widgets/lv_objmask.c - libs/lvgl/src/lv_widgets/lv_objx_templ.c - libs/lvgl/src/lv_widgets/lv_page.c - libs/lvgl/src/lv_widgets/lv_roller.c - libs/lvgl/src/lv_widgets/lv_slider.c - libs/lvgl/src/lv_widgets/lv_spinbox.c - libs/lvgl/src/lv_widgets/lv_spinner.c - libs/lvgl/src/lv_widgets/lv_switch.c - libs/lvgl/src/lv_widgets/lv_table.c - libs/lvgl/src/lv_widgets/lv_tabview.c - libs/lvgl/src/lv_widgets/lv_textarea.c - libs/lvgl/src/lv_widgets/lv_tileview.c - libs/lvgl/src/lv_widgets/lv_win.c + libs/lvgl/src/widgets/lv_arc.c + libs/lvgl/src/widgets/lv_bar.c + libs/lvgl/src/widgets/lv_btn.c + libs/lvgl/src/widgets/lv_btnmatrix.c + libs/lvgl/src/extra/widgets/calendar/lv_calendar.c + libs/lvgl/src/extra/widgets/calendar/lv_calendar_header_arrow.c + libs/lvgl/src/extra/widgets/calendar/lv_calendar_header_dropdown.c + libs/lvgl/src/widgets/lv_canvas.c + libs/lvgl/src/extra/widgets/chart/lv_chart.c + libs/lvgl/src/widgets/lv_checkbox.c + libs/lvgl/src/extra/widgets/colorwheel/lv_colorwheel.c + libs/lvgl/src/widgets/lv_dropdown.c + libs/lvgl/src/widgets/lv_img.c + libs/lvgl/src/extra/widgets/imgbtn/lv_imgbtn.c + libs/lvgl/src/extra/widgets/keyboard/lv_keyboard.c + libs/lvgl/src/widgets/lv_label.c + libs/lvgl/src/extra/widgets/led/lv_led.c + libs/lvgl/src/widgets/lv_line.c + libs/lvgl/src/extra/widgets/meter/lv_meter.c + libs/lvgl/src/extra/widgets/list/lv_list.c + libs/lvgl/src/extra/widgets/msgbox/lv_msgbox.c + libs/lvgl/src/widgets/lv_objx_templ.c + libs/lvgl/src/widgets/lv_roller.c + libs/lvgl/src/widgets/lv_slider.c + libs/lvgl/src/extra/widgets/spinbox/lv_spinbox.c + libs/lvgl/src/extra/widgets/spinner/lv_spinner.c + libs/lvgl/src/widgets/lv_switch.c + libs/lvgl/src/widgets/lv_table.c + libs/lvgl/src/extra/widgets/tabview/lv_tabview.c + libs/lvgl/src/widgets/lv_textarea.c + libs/lvgl/src/extra/widgets/tileview/lv_tileview.c + libs/lvgl/src/extra/widgets/win/lv_win.c + libs/lvgl/src/extra/layouts/flex/lv_flex.c + libs/lvgl/src/extra/layouts/grid/lv_grid.c ) list(APPEND IMAGE_FILES diff --git a/src/FreeRTOSConfig.h b/src/FreeRTOSConfig.h index adbbc8f01e..7a95bd4bb2 100644 --- a/src/FreeRTOSConfig.h +++ b/src/FreeRTOSConfig.h @@ -79,7 +79,7 @@ /* Hook function related definitions. */ #define configUSE_IDLE_HOOK 0 #define configUSE_TICK_HOOK 0 -#define configCHECK_FOR_STACK_OVERFLOW 0 +#define configCHECK_FOR_STACK_OVERFLOW 1 #define configUSE_MALLOC_FAILED_HOOK 0 /* Run time and task stats gathering related definitions. */ diff --git a/src/components/fs/FS.cpp b/src/components/fs/FS.cpp index 857e6bf93d..a548127b5b 100644 --- a/src/components/fs/FS.cpp +++ b/src/components/fs/FS.cpp @@ -72,8 +72,8 @@ int FS::FileWrite(lfs_file_t* file_p, const uint8_t* buff, uint32_t size) { return lfs_file_write(&lfs, file_p, buff, size); } -int FS::FileSeek(lfs_file_t* file_p, uint32_t pos) { - return lfs_file_seek(&lfs, file_p, pos, LFS_SEEK_SET); +int FS::FileSeek(lfs_file_t* file_p, uint32_t pos, lfs_whence_flags whence) { + return lfs_file_seek(&lfs, file_p, pos, whence); } int FS::FileDelete(const char* fileName) { @@ -140,18 +140,16 @@ int FS::SectorRead(const struct lfs_config* c, lfs_block_t block, lfs_off_t off, */ namespace { - lv_fs_res_t lvglOpen(lv_fs_drv_t* drv, void* file_p, const char* path, lv_fs_mode_t mode) { + void * lvglOpen(lv_fs_drv_t* drv, const char* path, lv_fs_mode_t mode) { - lfs_file_t* file = static_cast(file_p); + lfs_file_t* file = nullptr; FS* filesys = static_cast(drv->user_data); filesys->FileOpen(file, path, LFS_O_RDONLY); if (file->type == 0) { - return LV_FS_RES_FS_ERR; - } - else { - return LV_FS_RES_OK; + return nullptr; } + return file; } lv_fs_res_t lvglClose(lv_fs_drv_t* drv, void* file_p) { @@ -169,11 +167,10 @@ namespace { *br = btr; return LV_FS_RES_OK; } - - lv_fs_res_t lvglSeek(lv_fs_drv_t* drv, void* file_p, uint32_t pos) { + lv_fs_res_t lvglSeek(lv_fs_drv_t* drv, void* file_p, uint32_t pos, lv_fs_whence_t whence) { FS* filesys = static_cast(drv->user_data); lfs_file_t* file = static_cast(file_p); - filesys->FileSeek(file, pos); + filesys->FileSeek(file, pos, static_cast(whence)); return LV_FS_RES_OK; } } @@ -183,13 +180,19 @@ void FS::LVGLFileSystemInit() { lv_fs_drv_t fs_drv; lv_fs_drv_init(&fs_drv); - fs_drv.file_size = sizeof(lfs_file_t); fs_drv.letter = 'F'; + fs_drv.ready_cb = nullptr; fs_drv.open_cb = lvglOpen; fs_drv.close_cb = lvglClose; fs_drv.read_cb = lvglRead; + fs_drv.write_cb = nullptr; fs_drv.seek_cb = lvglSeek; - + fs_drv.tell_cb = nullptr; + + fs_drv.dir_open_cb = nullptr; + fs_drv.dir_read_cb = nullptr; + fs_drv.dir_close_cb = nullptr; + fs_drv.user_data = this; lv_fs_drv_register(&fs_drv); diff --git a/src/components/fs/FS.h b/src/components/fs/FS.h index 75ba16c813..9da4ba5ddc 100644 --- a/src/components/fs/FS.h +++ b/src/components/fs/FS.h @@ -17,7 +17,7 @@ namespace Pinetime { int FileClose(lfs_file_t* file_p); int FileRead(lfs_file_t* file_p, uint8_t* buff, uint32_t size); int FileWrite(lfs_file_t* file_p, const uint8_t* buff, uint32_t size); - int FileSeek(lfs_file_t* file_p, uint32_t pos); + int FileSeek(lfs_file_t* file_p, uint32_t pos, lfs_whence_flags whence); int FileDelete(const char* fileName); diff --git a/src/displayapp/Colors.cpp b/src/displayapp/Colors.cpp index f45f072257..589648922c 100644 --- a/src/displayapp/Colors.cpp +++ b/src/displayapp/Colors.cpp @@ -5,23 +5,23 @@ using namespace Pinetime::Controllers; lv_color_t Pinetime::Applications::Convert(Pinetime::Controllers::Settings::Colors color) { switch (color) { - case Pinetime::Controllers::Settings::Colors::White: return LV_COLOR_WHITE; - case Pinetime::Controllers::Settings::Colors::Silver: return LV_COLOR_SILVER; - case Pinetime::Controllers::Settings::Colors::Gray: return LV_COLOR_GRAY; - case Pinetime::Controllers::Settings::Colors::Black: return LV_COLOR_BLACK; - case Pinetime::Controllers::Settings::Colors::Red: return LV_COLOR_RED; - case Pinetime::Controllers::Settings::Colors::Maroon: return LV_COLOR_MAROON; - case Pinetime::Controllers::Settings::Colors::Yellow: return LV_COLOR_YELLOW; - case Pinetime::Controllers::Settings::Colors::Olive: return LV_COLOR_OLIVE; - case Pinetime::Controllers::Settings::Colors::Lime: return LV_COLOR_LIME; - case Pinetime::Controllers::Settings::Colors::Green: return LV_COLOR_GREEN; - case Pinetime::Controllers::Settings::Colors::Cyan: return LV_COLOR_CYAN; - case Pinetime::Controllers::Settings::Colors::Teal: return LV_COLOR_TEAL; - case Pinetime::Controllers::Settings::Colors::Blue: return LV_COLOR_BLUE; - case Pinetime::Controllers::Settings::Colors::Navy: return LV_COLOR_NAVY; - case Pinetime::Controllers::Settings::Colors::Magenta: return LV_COLOR_MAGENTA; - case Pinetime::Controllers::Settings::Colors::Purple: return LV_COLOR_PURPLE; - case Pinetime::Controllers::Settings::Colors::Orange: return LV_COLOR_ORANGE; - default: return LV_COLOR_WHITE; + case Pinetime::Controllers::Settings::Colors::White: return lv_color_white(); + case Pinetime::Controllers::Settings::Colors::Silver: return lv_color_hex(0xC0C0C0); + case Pinetime::Controllers::Settings::Colors::Gray: return lv_palette_main(LV_PALETTE_GREY); + case Pinetime::Controllers::Settings::Colors::Black: return lv_color_black(); + case Pinetime::Controllers::Settings::Colors::Red: return lv_palette_main(LV_PALETTE_RED); + case Pinetime::Controllers::Settings::Colors::Maroon: return lv_color_hex(0x800000); + case Pinetime::Controllers::Settings::Colors::Yellow: return lv_palette_main(LV_PALETTE_YELLOW); + case Pinetime::Controllers::Settings::Colors::Olive: return lv_color_hex(0x808000); + case Pinetime::Controllers::Settings::Colors::Lime: return lv_color_hex(0x00FF00); + case Pinetime::Controllers::Settings::Colors::Green: return lv_palette_main(LV_PALETTE_GREEN); + case Pinetime::Controllers::Settings::Colors::Cyan: return lv_color_hex(0x00FFFF); + case Pinetime::Controllers::Settings::Colors::Teal: return lv_color_hex(0x008080); + case Pinetime::Controllers::Settings::Colors::Blue: return lv_palette_main(LV_PALETTE_BLUE); + case Pinetime::Controllers::Settings::Colors::Navy: return lv_color_hex(0x000080); + case Pinetime::Controllers::Settings::Colors::Magenta: return lv_color_hex(0xFF00FF); + case Pinetime::Controllers::Settings::Colors::Purple: return lv_color_hex(0x800080); + case Pinetime::Controllers::Settings::Colors::Orange: return lv_palette_main(LV_PALETTE_ORANGE); + default: return lv_color_white(); } } diff --git a/src/displayapp/Colors.h b/src/displayapp/Colors.h index 9db7dd20ca..67290b5643 100644 --- a/src/displayapp/Colors.h +++ b/src/displayapp/Colors.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include namespace Pinetime { diff --git a/src/displayapp/DummyLittleVgl.h b/src/displayapp/DummyLittleVgl.h index 1db51343b0..0cfb061fd5 100644 --- a/src/displayapp/DummyLittleVgl.h +++ b/src/displayapp/DummyLittleVgl.h @@ -1,8 +1,8 @@ #pragma once -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index 2bd5e57be7..7fa80273fc 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -16,9 +16,10 @@ static void disp_flush(lv_disp_drv_t* disp_drv, const lv_area_t* area, lv_color_ lvgl->FlushDisplay(area, color_p); } -bool touchpad_read(lv_indev_drv_t* indev_drv, lv_indev_data_t* data) { +void touchpad_read(lv_indev_drv_t* indev_drv, lv_indev_data_t* data) { auto* lvgl = static_cast(indev_drv->user_data); - return lvgl->GetTouchPadInfo(data); + lvgl->GetTouchPadInfo(data); + return; } LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& touchPanel) @@ -34,7 +35,7 @@ void LittleVgl::Init() { } void LittleVgl::InitDisplay() { - lv_disp_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 4); /*Initialize the display buffer*/ + lv_disp_draw_buf_init(&disp_buf_2, buf2_1, buf2_2, LV_HOR_RES_MAX * 4); /*Initialize the display buffer*/ lv_disp_drv_init(&disp_drv); /*Basic initialization*/ /*Set up the functions to access to your display*/ @@ -46,7 +47,7 @@ void LittleVgl::InitDisplay() { /*Used to copy the buffer's content to the display*/ disp_drv.flush_cb = disp_flush; /*Set a display buffer*/ - disp_drv.buffer = &disp_buf_2; + disp_drv.draw_buf = &disp_buf_2; disp_drv.user_data = this; /*Finally register the driver*/ @@ -67,15 +68,15 @@ void LittleVgl::SetFullRefresh(FullRefreshDirections direction) { if (scrollDirection == FullRefreshDirections::None) { scrollDirection = direction; if (scrollDirection == FullRefreshDirections::Down) { - lv_disp_set_direction(lv_disp_get_default(), 1); + lv_disp_set_rotation(lv_disp_get_default(), static_cast(1)); } else if (scrollDirection == FullRefreshDirections::Right) { - lv_disp_set_direction(lv_disp_get_default(), 2); + lv_disp_set_rotation(lv_disp_get_default(), static_cast(2)); } else if (scrollDirection == FullRefreshDirections::Left) { - lv_disp_set_direction(lv_disp_get_default(), 3); + lv_disp_set_rotation(lv_disp_get_default(), static_cast(3)); } else if (scrollDirection == FullRefreshDirections::RightAnim) { - lv_disp_set_direction(lv_disp_get_default(), 5); + lv_disp_set_rotation(lv_disp_get_default(), static_cast(5)); } else if (scrollDirection == FullRefreshDirections::LeftAnim) { - lv_disp_set_direction(lv_disp_get_default(), 4); + lv_disp_set_rotation(lv_disp_get_default(), static_cast(4)); } } } @@ -106,7 +107,7 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { if (area->y1 == 0) { toScroll = height * 2; scrollDirection = FullRefreshDirections::None; - lv_disp_set_direction(lv_disp_get_default(), 0); + lv_disp_set_rotation(lv_disp_get_default(), static_cast(0)); } else { toScroll = height; } @@ -126,7 +127,7 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { if (area->y2 == visibleNbLines - 1) { scrollOffset += (height * 2); scrollDirection = FullRefreshDirections::None; - lv_disp_set_direction(lv_disp_get_default(), 0); + lv_disp_set_rotation(lv_disp_get_default(), static_cast(0)); } else { scrollOffset += height; } @@ -136,12 +137,12 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { } else if (scrollDirection == FullRefreshDirections::Left or scrollDirection == FullRefreshDirections::LeftAnim) { if (area->x2 == visibleNbLines - 1) { scrollDirection = FullRefreshDirections::None; - lv_disp_set_direction(lv_disp_get_default(), 0); + lv_disp_set_rotation(lv_disp_get_default(), static_cast(0)); } } else if (scrollDirection == FullRefreshDirections::Right or scrollDirection == FullRefreshDirections::RightAnim) { if (area->x1 == 0) { scrollDirection = FullRefreshDirections::None; - lv_disp_set_direction(lv_disp_get_default(), 0); + lv_disp_set_rotation(lv_disp_get_default(), static_cast(0)); } } @@ -185,8 +186,14 @@ bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) { void LittleVgl::InitTheme() { - lv_theme_t* th = lv_pinetime_theme_init( - LV_COLOR_WHITE, LV_COLOR_SILVER, 0, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20); - - lv_theme_set_act(th); +// lv_theme_t* th = lv_pinetime_theme_init( +// lv_color_white(), lv_color_hex(0xC0C0C0), 0, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20); + + lv_theme_t* th = lv_pinetime_theme_init(lv_disp_get_default(), + lv_color_white(), + lv_color_hex(0xC0C0C0), + 0, + &jetbrains_mono_bold_20); + + lv_disp_set_theme(lv_disp_get_default(), th); } diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index 1f8a3d79f0..d71ed7060b 100644 --- a/src/displayapp/LittleVgl.h +++ b/src/displayapp/LittleVgl.h @@ -34,7 +34,7 @@ namespace Pinetime { Pinetime::Drivers::St7789& lcd; Pinetime::Drivers::Cst816S& touchPanel; - lv_disp_buf_t disp_buf_2; + lv_disp_draw_buf_t disp_buf_2; lv_color_t buf2_1[LV_HOR_RES_MAX * 4]; lv_color_t buf2_2[LV_HOR_RES_MAX * 4]; diff --git a/src/displayapp/fonts/jetbrains_mono_extrabold_compressed.c b/src/displayapp/fonts/jetbrains_mono_extrabold_compressed.c index c9917e40c1..391795b8e2 100644 --- a/src/displayapp/fonts/jetbrains_mono_extrabold_compressed.c +++ b/src/displayapp/fonts/jetbrains_mono_extrabold_compressed.c @@ -492,7 +492,7 @@ static lv_font_fmt_txt_dsc_t font_dsc = { *----------------*/ /*Initialize a public general font descriptor*/ -lv_font_t jetbrains_mono_extrabold_compressed = { +const lv_font_t jetbrains_mono_extrabold_compressed = { .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ .line_height = 60, /*The maximum line height required by the font*/ diff --git a/src/displayapp/lv_pinetime_theme.c b/src/displayapp/lv_pinetime_theme.c index 1b8b1980aa..9a257594a9 100644 --- a/src/displayapp/lv_pinetime_theme.c +++ b/src/displayapp/lv_pinetime_theme.c @@ -1,64 +1,178 @@ /** - * @file lv_pinetime_theme.c + * @file lv_theme_defau.c * */ /********************* * INCLUDES *********************/ +#include + +#if LV_USE_THEME_DEFAULT + #include "lv_pinetime_theme.h" +#include /********************* * DEFINES *********************/ +#define MODE_DARK 1 +#define RADIUS_DEFAULT (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8)) + +/*SCREEN*/ +#define LIGHT_COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 4) +#define LIGHT_COLOR_CARD lv_color_white() +#define LIGHT_COLOR_TEXT lv_palette_darken(LV_PALETTE_GREY, 4) +#define LIGHT_COLOR_GREY lv_palette_lighten(LV_PALETTE_GREY, 2) +#define DARK_COLOR_SCR lv_color_hex(0x15171A) +#define DARK_COLOR_CARD lv_color_hex(0x282b30) +#define DARK_COLOR_TEXT lv_palette_lighten(LV_PALETTE_GREY, 5) +#define DARK_COLOR_GREY lv_color_hex(0x2f3237) + +#define TRANSITION_TIME LV_THEME_DEFAULT_TRANSITON_TIME +#define BORDER_WIDTH lv_disp_dpx(theme.disp, 2) +#define OUTLINE_WIDTH lv_disp_dpx(theme.disp, 3) + +#define PAD_DEF (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 24) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 20) : lv_disp_dpx(theme.disp, 16)) +#define PAD_SMALL (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 14) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 10)) +#define PAD_TINY (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 8) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 6) : lv_disp_dpx(theme.disp, 2)) /********************** * TYPEDEFS **********************/ +typedef struct { + lv_style_t scr; + lv_style_t scrollbar; + lv_style_t scrollbar_scrolled; + lv_style_t card; + lv_style_t btn; + + /*Utility*/ + lv_style_t bg_color_primary; + lv_style_t bg_color_primary_muted; + lv_style_t bg_color_secondary; + lv_style_t bg_color_secondary_muted; + lv_style_t bg_color_grey; + lv_style_t bg_color_white; + lv_style_t pressed; + lv_style_t disabled; + lv_style_t pad_zero; + lv_style_t pad_tiny; + lv_style_t pad_small; + lv_style_t pad_normal; + lv_style_t pad_gap; + lv_style_t line_space_large; + lv_style_t text_align_center; + lv_style_t outline_primary; + lv_style_t outline_secondary; + lv_style_t circle; + lv_style_t no_radius; + lv_style_t clip_corner; +#if LV_THEME_DEFAULT_GROW + lv_style_t grow; +#endif + lv_style_t transition_delayed; + lv_style_t transition_normal; + lv_style_t anim; + + /*Parts*/ + lv_style_t knob; + lv_style_t indic; + +#if LV_USE_ARC + lv_style_t arc_indic; + lv_style_t arc_indic_primary; +#endif + +#if LV_USE_CHART + lv_style_t chart_series, chart_indic, chart_ticks, chart_bg; +#endif + +#if LV_USE_DROPDOWN + lv_style_t dropdown_list; +#endif + +#if LV_USE_CHECKBOX + lv_style_t cb_marker, cb_marker_checked; +#endif + +#if LV_USE_SWITCH + lv_style_t switch_knob; +#endif + +#if LV_USE_LINE + lv_style_t line; +#endif + +#if LV_USE_TABLE + lv_style_t table_cell; +#endif + +#if LV_USE_METER + lv_style_t meter_marker, meter_indic; +#endif + +#if LV_USE_TEXTAREA + lv_style_t ta_cursor, ta_placeholder; +#endif + +#if LV_USE_CALENDAR + lv_style_t calendar_bg, calendar_day; +#endif + +#if LV_USE_COLORWHEEL + lv_style_t colorwheel_main; +#endif + +#if LV_USE_MSGBOX + lv_style_t msgbox_bg, msgbox_btn_bg; +#endif + +#if LV_USE_KEYBOARD + lv_style_t keyboard_btn_bg; +#endif + +#if LV_USE_LIST + lv_style_t list_bg, list_btn, list_item_grow, list_label; +#endif + +#if LV_USE_TABVIEW + lv_style_t tab_bg_focus, tab_btn; +#endif +#if LV_USE_LED + lv_style_t led; +#endif +} my_theme_styles_t; + +typedef struct { + lv_theme_t base; + uint8_t light :1; +}my_theme_t; + +typedef enum { + DISP_SMALL = 3, + DISP_MEDIUM = 2, + DISP_LARGE = 1, +}disp_size_t; /********************** * STATIC PROTOTYPES **********************/ -static void theme_apply(lv_obj_t* obj, lv_theme_style_t name); +static void theme_apply(lv_theme_t * th, lv_obj_t * obj); +static void style_init_reset(lv_style_t * style); /********************** * STATIC VARIABLES **********************/ +static my_theme_styles_t * styles; static lv_theme_t theme; - -static lv_style_t style_pad; -static lv_style_t style_circle; - -static lv_style_t style_bg; -static lv_style_t style_box; -static lv_style_t style_box_border; -static lv_style_t style_btn; -static lv_style_t style_btn_border; -static lv_style_t style_title; -static lv_style_t style_label_white; -static lv_style_t style_back; -static lv_style_t style_icon; -static lv_style_t style_bar_indic; -static lv_style_t style_slider_knob; -static lv_style_t style_scrollbar; -static lv_style_t style_list_btn; -static lv_style_t style_ddlist_list; -static lv_style_t style_ddlist_selected; -static lv_style_t style_sw_bg; -static lv_style_t style_sw_indic; -static lv_style_t style_sw_knob; -static lv_style_t style_arc_bg; -static lv_style_t style_arc_knob; -static lv_style_t style_arc_indic; -static lv_style_t style_table_cell; -static lv_style_t style_pad_small; -static lv_style_t style_bg_grad; -static lv_style_t style_lmeter; -static lv_style_t style_chart_serie; -static lv_style_t style_cb_bg; -static lv_style_t style_cb_bullet; - +static disp_size_t disp_size; static bool inited; +static lv_color_t color_scr; +static lv_color_t color_text; +static lv_color_t color_card; +static lv_color_t color_grey; + /********************** * MACROS @@ -68,479 +182,826 @@ static bool inited; * STATIC FUNCTIONS **********************/ -static void style_init_reset(lv_style_t* style) { - if (inited) - lv_style_reset(style); - else - lv_style_init(style); + +static lv_color_t dark_color_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t c, lv_opa_t opa) +{ + LV_UNUSED(f); + return lv_color_darken(c, opa); +} + +static lv_color_t grey_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t color, lv_opa_t opa) +{ + LV_UNUSED(f); + if(theme.flags & MODE_DARK) return lv_color_mix(lv_palette_darken(LV_PALETTE_GREY, 2), color, opa); + else return lv_color_mix(lv_palette_lighten(LV_PALETTE_GREY, 2), color, opa); } -static void basic_init(void) { - - style_init_reset(&style_pad); - lv_style_set_pad_top(&style_pad, LV_STATE_DEFAULT, LV_VER_RES / 30); - lv_style_set_pad_bottom(&style_pad, LV_STATE_DEFAULT, LV_VER_RES / 30); - lv_style_set_pad_left(&style_pad, LV_STATE_DEFAULT, LV_VER_RES / 40); - lv_style_set_pad_right(&style_pad, LV_STATE_DEFAULT, LV_VER_RES / 40); - - style_init_reset(&style_circle); - lv_style_set_radius(&style_circle, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - - style_init_reset(&style_bg); - lv_style_set_bg_opa(&style_bg, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_bg, LV_STATE_DEFAULT, LV_COLOR_BLACK); - lv_style_set_text_font(&style_bg, LV_STATE_DEFAULT, theme.font_normal); - - style_init_reset(&style_box); - lv_style_set_bg_opa(&style_box, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_radius(&style_box, LV_STATE_DEFAULT, 10); - lv_style_set_value_color(&style_box, LV_STATE_DEFAULT, LV_PINETIME_BLUE); - lv_style_set_value_font(&style_box, LV_STATE_DEFAULT, theme.font_normal); - - style_init_reset(&style_box_border); - lv_style_set_bg_opa(&style_box_border, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_style_set_border_width(&style_box_border, LV_STATE_DEFAULT, 2); - lv_style_set_border_color(&style_box_border, LV_STATE_DEFAULT, LV_PINETIME_GRAY); - lv_style_set_text_color(&style_box, LV_STATE_DEFAULT, LV_PINETIME_BLUE); - - style_init_reset(&style_title); - lv_style_set_text_color(&style_title, LV_STATE_DEFAULT, LV_PINETIME_WHITE); - lv_style_set_text_font(&style_title, LV_STATE_DEFAULT, theme.font_subtitle); - - style_init_reset(&style_label_white); - lv_style_set_text_color(&style_label_white, LV_STATE_DEFAULT, LV_PINETIME_WHITE); - - style_init_reset(&style_btn); - lv_style_set_radius(&style_btn, LV_STATE_DEFAULT, 10); - lv_style_set_bg_opa(&style_btn, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_btn, LV_STATE_DEFAULT, lv_color_hex(0x2F3540)); - lv_style_set_bg_color(&style_btn, LV_STATE_CHECKED, LV_COLOR_GREEN); - lv_style_set_bg_color(&style_btn, LV_STATE_DISABLED, lv_color_hex(0x2F3540)); - lv_style_set_bg_color(&style_btn, LV_STATE_DISABLED | LV_STATE_CHECKED, lv_color_hex3(0x888)); - lv_style_set_border_color(&style_btn, LV_STATE_DEFAULT, theme.color_primary); - lv_style_set_border_width(&style_btn, LV_STATE_DEFAULT, 0); - lv_style_set_border_opa(&style_btn, LV_STATE_CHECKED, LV_OPA_TRANSP); - - lv_style_set_text_color(&style_btn, LV_STATE_DEFAULT, lv_color_hex(0xffffff)); - lv_style_set_text_color(&style_btn, LV_STATE_CHECKED, lv_color_hex(0xffffff)); - lv_style_set_text_color(&style_btn, LV_STATE_CHECKED, lv_color_hex(0xffffff)); - lv_style_set_text_color(&style_btn, LV_STATE_DISABLED, lv_color_hex(0x888888)); - - lv_style_set_value_color(&style_btn, LV_STATE_DEFAULT, lv_color_hex(0xffffff)); - lv_style_set_value_color(&style_btn, LV_STATE_CHECKED, lv_color_hex(0xffffff)); - lv_style_set_value_color(&style_btn, LV_STATE_CHECKED, lv_color_hex(0xffffff)); - lv_style_set_value_color(&style_btn, LV_STATE_DISABLED, lv_color_hex(0x888888)); - - lv_style_set_pad_left(&style_btn, LV_STATE_DEFAULT, LV_DPX(20)); - lv_style_set_pad_right(&style_btn, LV_STATE_DEFAULT, LV_DPX(20)); - lv_style_set_pad_top(&style_btn, LV_STATE_DEFAULT, LV_DPX(20)); - lv_style_set_pad_bottom(&style_btn, LV_STATE_DEFAULT, LV_DPX(20)); - lv_style_set_pad_inner(&style_btn, LV_STATE_DEFAULT, LV_DPX(15)); - lv_style_set_outline_width(&style_btn, LV_STATE_DEFAULT, LV_DPX(2)); - lv_style_set_outline_opa(&style_btn, LV_STATE_DEFAULT, LV_OPA_0); - lv_style_set_outline_color(&style_btn, LV_STATE_DEFAULT, theme.color_primary); - lv_style_set_transition_time(&style_btn, LV_STATE_DEFAULT, 0); - lv_style_set_transition_delay(&style_btn, LV_STATE_DEFAULT, 0); - - style_init_reset(&style_btn_border); - lv_style_set_radius(&style_btn_border, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_style_set_border_color(&style_btn_border, LV_STATE_DEFAULT, LV_PINETIME_WHITE); - lv_style_set_border_width(&style_btn_border, LV_STATE_DEFAULT, 2); - lv_style_set_bg_opa(&style_btn_border, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_style_set_bg_color(&style_btn_border, LV_STATE_DEFAULT, LV_PINETIME_WHITE); - lv_style_set_text_color(&style_btn_border, LV_STATE_DEFAULT, LV_PINETIME_WHITE); - lv_style_set_value_color(&style_btn_border, LV_STATE_DEFAULT, LV_PINETIME_WHITE); - lv_style_set_transition_prop_3(&style_btn_border, LV_STATE_DEFAULT, LV_STYLE_BG_OPA); - - style_init_reset(&style_icon); - lv_style_set_text_color(&style_icon, LV_STATE_DEFAULT, LV_PINETIME_WHITE); - - style_init_reset(&style_back); - lv_style_set_value_color(&style_back, LV_STATE_DEFAULT, LV_PINETIME_GRAY); - lv_style_set_value_str(&style_back, LV_STATE_DEFAULT, LV_SYMBOL_LEFT); - lv_style_set_value_font(&style_back, LV_STATE_DEFAULT, theme.font_subtitle); - - style_init_reset(&style_bar_indic); - lv_style_set_bg_opa(&style_bar_indic, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_radius(&style_bar_indic, LV_STATE_DEFAULT, 10); - - style_init_reset(&style_scrollbar); - lv_style_set_bg_opa(&style_scrollbar, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_radius(&style_scrollbar, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_style_set_bg_color(&style_scrollbar, LV_STATE_DEFAULT, LV_PINETIME_LIGHT_GRAY); - lv_style_set_size(&style_scrollbar, LV_STATE_DEFAULT, LV_HOR_RES / 80); - lv_style_set_pad_right(&style_scrollbar, LV_STATE_DEFAULT, LV_HOR_RES / 60); - - style_init_reset(&style_list_btn); - lv_style_set_bg_opa(&style_list_btn, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_list_btn, LV_STATE_DEFAULT, LV_PINETIME_WHITE); - lv_style_set_bg_color(&style_list_btn, LV_STATE_CHECKED, LV_PINETIME_GRAY); - lv_style_set_bg_color(&style_list_btn, LV_STATE_CHECKED | LV_STATE_PRESSED, lv_color_darken(LV_PINETIME_GRAY, LV_OPA_20)); - lv_style_set_text_color(&style_list_btn, LV_STATE_DEFAULT, LV_PINETIME_BLUE); - lv_style_set_text_color(&style_list_btn, LV_STATE_CHECKED, LV_PINETIME_WHITE); - lv_style_set_text_color(&style_list_btn, LV_STATE_CHECKED | LV_STATE_PRESSED, LV_PINETIME_WHITE); - lv_style_set_image_recolor(&style_list_btn, LV_STATE_DEFAULT, LV_PINETIME_BLUE); - lv_style_set_image_recolor(&style_list_btn, LV_STATE_CHECKED, LV_PINETIME_WHITE); - lv_style_set_image_recolor(&style_list_btn, LV_STATE_CHECKED | LV_STATE_PRESSED, LV_PINETIME_WHITE); - lv_style_set_pad_left(&style_list_btn, LV_STATE_DEFAULT, LV_HOR_RES / 25); - lv_style_set_pad_right(&style_list_btn, LV_STATE_DEFAULT, LV_HOR_RES / 25); - lv_style_set_pad_top(&style_list_btn, LV_STATE_DEFAULT, LV_HOR_RES / 100); - lv_style_set_pad_bottom(&style_list_btn, LV_STATE_DEFAULT, LV_HOR_RES / 100); - lv_style_set_pad_inner(&style_list_btn, LV_STATE_DEFAULT, LV_HOR_RES / 50); - - style_init_reset(&style_ddlist_list); - lv_style_set_text_line_space(&style_ddlist_list, LV_STATE_DEFAULT, LV_VER_RES / 25); - lv_style_set_shadow_width(&style_ddlist_list, LV_STATE_DEFAULT, LV_VER_RES / 20); - lv_style_set_shadow_color(&style_ddlist_list, LV_STATE_DEFAULT, LV_PINETIME_GRAY); - lv_style_set_bg_color(&style_ddlist_list, LV_STATE_DEFAULT, LV_PINETIME_GRAY); - - style_init_reset(&style_ddlist_selected); - lv_style_set_bg_opa(&style_ddlist_selected, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_ddlist_selected, LV_STATE_DEFAULT, LV_PINETIME_BLUE); - - style_init_reset(&style_sw_bg); - lv_style_set_bg_opa(&style_sw_bg, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_sw_bg, LV_STATE_DEFAULT, LV_PINETIME_LIGHT_GRAY); - lv_style_set_radius(&style_sw_bg, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_style_set_value_color(&style_sw_bg, LV_STATE_DEFAULT, LV_PINETIME_BLUE); - - style_init_reset(&style_sw_indic); - lv_style_set_bg_opa(&style_sw_indic, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_sw_indic, LV_STATE_DEFAULT, LV_PINETIME_GREEN); - - style_init_reset(&style_sw_knob); - lv_style_set_bg_opa(&style_sw_knob, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_sw_knob, LV_STATE_DEFAULT, LV_PINETIME_WHITE); - lv_style_set_radius(&style_sw_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_style_set_pad_top(&style_sw_knob, LV_STATE_DEFAULT, -4); - lv_style_set_pad_bottom(&style_sw_knob, LV_STATE_DEFAULT, -4); - lv_style_set_pad_left(&style_sw_knob, LV_STATE_DEFAULT, -4); - lv_style_set_pad_right(&style_sw_knob, LV_STATE_DEFAULT, -4); - - style_init_reset(&style_slider_knob); - lv_style_set_bg_opa(&style_slider_knob, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_slider_knob, LV_STATE_DEFAULT, LV_COLOR_RED); - lv_style_set_border_color(&style_slider_knob, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_style_set_border_width(&style_slider_knob, LV_STATE_DEFAULT, 6); - lv_style_set_radius(&style_slider_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_style_set_pad_top(&style_slider_knob, LV_STATE_DEFAULT, 10); - lv_style_set_pad_bottom(&style_slider_knob, LV_STATE_DEFAULT, 10); - lv_style_set_pad_left(&style_slider_knob, LV_STATE_DEFAULT, 10); - lv_style_set_pad_right(&style_slider_knob, LV_STATE_DEFAULT, 10); - lv_style_set_pad_top(&style_slider_knob, LV_STATE_PRESSED, 14); - lv_style_set_pad_bottom(&style_slider_knob, LV_STATE_PRESSED, 14); - lv_style_set_pad_left(&style_slider_knob, LV_STATE_PRESSED, 14); - lv_style_set_pad_right(&style_slider_knob, LV_STATE_PRESSED, 14); - - style_init_reset(&style_arc_indic); - lv_style_set_line_color(&style_arc_indic, LV_STATE_DEFAULT, LV_PINETIME_BLUE); - lv_style_set_line_width(&style_arc_indic, LV_STATE_DEFAULT, LV_DPX(25)); - lv_style_set_line_rounded(&style_arc_indic, LV_STATE_DEFAULT, true); - - style_init_reset(&style_arc_bg); - lv_style_set_line_color(&style_arc_bg, LV_STATE_DEFAULT, LV_PINETIME_GRAY); - lv_style_set_line_width(&style_arc_bg, LV_STATE_DEFAULT, LV_DPX(25)); - lv_style_set_line_rounded(&style_arc_bg, LV_STATE_DEFAULT, true); - lv_style_set_pad_all(&style_arc_bg, LV_STATE_DEFAULT, LV_DPX(5)); - - lv_style_reset(&style_arc_knob); - lv_style_set_radius(&style_arc_knob, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_style_set_bg_opa(&style_arc_knob, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_arc_knob, LV_STATE_DEFAULT, LV_PINETIME_LIGHT_GRAY); - lv_style_set_pad_all(&style_arc_knob, LV_STATE_DEFAULT, LV_DPX(5)); - - style_init_reset(&style_table_cell); - lv_style_set_border_color(&style_table_cell, LV_STATE_DEFAULT, LV_PINETIME_GRAY); - lv_style_set_border_width(&style_table_cell, LV_STATE_DEFAULT, 1); - lv_style_set_border_side(&style_table_cell, LV_STATE_DEFAULT, LV_BORDER_SIDE_FULL); - lv_style_set_pad_left(&style_table_cell, LV_STATE_DEFAULT, 5); - lv_style_set_pad_right(&style_table_cell, LV_STATE_DEFAULT, 5); - lv_style_set_pad_top(&style_table_cell, LV_STATE_DEFAULT, 2); - lv_style_set_pad_bottom(&style_table_cell, LV_STATE_DEFAULT, 2); - - style_init_reset(&style_pad_small); - lv_style_int_t pad_small_value = 10; - lv_style_set_pad_left(&style_pad_small, LV_STATE_DEFAULT, pad_small_value); - lv_style_set_pad_right(&style_pad_small, LV_STATE_DEFAULT, pad_small_value); - lv_style_set_pad_top(&style_pad_small, LV_STATE_DEFAULT, pad_small_value); - lv_style_set_pad_bottom(&style_pad_small, LV_STATE_DEFAULT, pad_small_value); - lv_style_set_pad_inner(&style_pad_small, LV_STATE_DEFAULT, pad_small_value); - - style_init_reset(&style_bg_grad); - lv_style_set_bg_color(&style_bg_grad, LV_STATE_DEFAULT, lv_color_hsv_to_rgb(10, 10, 40)); - lv_style_set_bg_grad_color(&style_bg_grad, LV_STATE_DEFAULT, lv_color_hsv_to_rgb(10, 10, 20)); - lv_style_set_bg_grad_dir(&style_bg_grad, LV_STATE_DEFAULT, LV_GRAD_DIR_VER); - - style_init_reset(&style_lmeter); - lv_style_set_radius(&style_lmeter, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_style_set_pad_left(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(20)); - lv_style_set_pad_right(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(20)); - lv_style_set_pad_top(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(20)); - lv_style_set_pad_inner(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(30)); - lv_style_set_scale_width(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(25)); - - lv_style_set_line_color(&style_lmeter, LV_STATE_DEFAULT, theme.color_primary); - lv_style_set_scale_grad_color(&style_lmeter, LV_STATE_DEFAULT, theme.color_primary); - lv_style_set_scale_end_color(&style_lmeter, LV_STATE_DEFAULT, lv_color_hex3(0x888)); - lv_style_set_line_width(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(10)); - lv_style_set_scale_end_line_width(&style_lmeter, LV_STATE_DEFAULT, LV_DPX(7)); - - style_init_reset(&style_chart_serie); - lv_style_set_line_color(&style_chart_serie, LV_STATE_DEFAULT, LV_PINETIME_WHITE); - lv_style_set_line_width(&style_chart_serie, LV_STATE_DEFAULT, 4); - lv_style_set_size(&style_chart_serie, LV_STATE_DEFAULT, 4); - lv_style_set_bg_opa(&style_chart_serie, LV_STATE_DEFAULT, 0); - - lv_style_reset(&style_cb_bg); - lv_style_set_radius(&style_cb_bg, LV_STATE_DEFAULT, LV_DPX(4)); - lv_style_set_pad_inner(&style_cb_bg, LV_STATE_DEFAULT, LV_DPX(10)); - lv_style_set_outline_color(&style_cb_bg, LV_STATE_DEFAULT, theme.color_primary); - lv_style_set_outline_width(&style_cb_bg, LV_STATE_DEFAULT, LV_DPX(2)); - lv_style_set_outline_pad(&style_cb_bg, LV_STATE_DEFAULT, LV_DPX(20)); - lv_style_set_transition_time(&style_cb_bg, LV_STATE_DEFAULT, 0); - lv_style_set_transition_prop_6(&style_cb_bg, LV_STATE_DEFAULT, LV_STYLE_OUTLINE_OPA); - - lv_style_reset(&style_cb_bullet); - lv_style_set_outline_opa(&style_cb_bullet, LV_STATE_FOCUSED, LV_OPA_TRANSP); - lv_style_set_radius(&style_cb_bullet, LV_STATE_DEFAULT, LV_DPX(4)); - lv_style_set_pattern_recolor(&style_cb_bullet, LV_STATE_CHECKED, LV_COLOR_WHITE); - lv_style_set_pad_left(&style_cb_bullet, LV_STATE_DEFAULT, LV_DPX(8)); - lv_style_set_pad_right(&style_cb_bullet, LV_STATE_DEFAULT, LV_DPX(8)); - lv_style_set_pad_top(&style_cb_bullet, LV_STATE_DEFAULT, LV_DPX(8)); - lv_style_set_pad_bottom(&style_cb_bullet, LV_STATE_DEFAULT, LV_DPX(8)); +lv_theme_t * lv_pinetime_theme_init(lv_disp_t* disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t* font) +{ + static const lv_style_prop_t trans_props[] = { + LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, + LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT, + LV_STYLE_TRANSLATE_Y, LV_STYLE_TRANSLATE_X, + LV_STYLE_TRANSFORM_ZOOM, LV_STYLE_TRANSFORM_ANGLE, + LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_DSC, + 0 + }; + + color_scr = theme.flags & MODE_DARK ? DARK_COLOR_SCR : LIGHT_COLOR_SCR; + color_text = theme.flags & MODE_DARK ? DARK_COLOR_TEXT : LIGHT_COLOR_TEXT; + color_card = theme.flags & MODE_DARK ? DARK_COLOR_CARD : LIGHT_COLOR_CARD; + color_grey = theme.flags & MODE_DARK ? DARK_COLOR_GREY : LIGHT_COLOR_GREY; + + static lv_style_transition_dsc_t trans_delayed; + lv_style_transition_dsc_init(&trans_delayed, trans_props, lv_anim_path_linear, TRANSITION_TIME, 70, NULL); + + static lv_style_transition_dsc_t trans_normal; + lv_style_transition_dsc_init(&trans_normal, trans_props, lv_anim_path_linear, TRANSITION_TIME, 0, NULL); + + style_init_reset(&styles->transition_delayed); + lv_style_set_transition(&styles->transition_delayed, &trans_delayed); /*Go back to default state with delay*/ + + style_init_reset(&styles->transition_normal); + lv_style_set_transition(&styles->transition_normal, &trans_normal); /*Go back to default state with delay*/ + + style_init_reset(&styles->scrollbar); + lv_style_set_bg_color(&styles->scrollbar, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, 2) : lv_palette_main(LV_PALETTE_GREY)); + lv_style_set_radius(&styles->scrollbar, LV_RADIUS_CIRCLE); + lv_style_set_pad_right(&styles->scrollbar, lv_disp_dpx(theme.disp, 7)); + lv_style_set_pad_top(&styles->scrollbar, lv_disp_dpx(theme.disp, 7)); + lv_style_set_size(&styles->scrollbar, lv_disp_dpx(theme.disp, 5)); + lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_40); + lv_style_set_transition(&styles->scrollbar, &trans_normal); + + style_init_reset(&styles->scrollbar_scrolled); + lv_style_set_bg_opa(&styles->scrollbar_scrolled, LV_OPA_COVER); + + style_init_reset(&styles->scr); + lv_style_set_bg_opa(&styles->scr, LV_OPA_COVER); + lv_style_set_bg_color(&styles->scr, color_scr); + lv_style_set_text_color(&styles->scr, color_text); + lv_style_set_pad_row(&styles->scr, PAD_SMALL); + lv_style_set_pad_column(&styles->scr, PAD_SMALL); + + style_init_reset(&styles->card); + lv_style_set_radius(&styles->card, RADIUS_DEFAULT); + lv_style_set_bg_opa(&styles->card, LV_OPA_COVER); + lv_style_set_bg_color(&styles->card, color_card); + lv_style_set_border_color(&styles->card, color_grey); + lv_style_set_border_width(&styles->card, BORDER_WIDTH); + lv_style_set_border_post(&styles->card, true); + lv_style_set_text_color(&styles->card, color_text); + lv_style_set_pad_all(&styles->card, PAD_DEF); + lv_style_set_pad_row(&styles->card, PAD_SMALL); + lv_style_set_pad_column(&styles->card, PAD_SMALL); + lv_style_set_line_color(&styles->card, lv_palette_main(LV_PALETTE_GREY)); + lv_style_set_line_width(&styles->card, lv_disp_dpx(theme.disp, 1)); + + style_init_reset(&styles->outline_primary); + lv_style_set_outline_color(&styles->outline_primary, theme.color_primary); + lv_style_set_outline_width(&styles->outline_primary, OUTLINE_WIDTH); + lv_style_set_outline_pad(&styles->outline_primary, OUTLINE_WIDTH); + lv_style_set_outline_opa(&styles->outline_primary, LV_OPA_50); + + style_init_reset(&styles->outline_secondary); + lv_style_set_outline_color(&styles->outline_secondary, theme.color_secondary); + lv_style_set_outline_width(&styles->outline_secondary, OUTLINE_WIDTH); + lv_style_set_outline_opa(&styles->outline_secondary, LV_OPA_50); + + style_init_reset(&styles->btn); + lv_style_set_radius(&styles->btn, (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 16) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8))); + lv_style_set_bg_opa(&styles->btn, LV_OPA_COVER); + lv_style_set_bg_color(&styles->btn, color_grey); + if(!(theme.flags & MODE_DARK)) { + lv_style_set_shadow_color(&styles->btn, lv_palette_lighten(LV_PALETTE_GREY, 3)); + lv_style_set_shadow_width(&styles->btn, 1); + lv_style_set_shadow_ofs_y(&styles->btn, lv_disp_dpx(theme.disp, 4)); + } + lv_style_set_text_color(&styles->btn, color_text); + lv_style_set_pad_hor(&styles->btn, PAD_DEF); + lv_style_set_pad_ver(&styles->btn, PAD_SMALL); + lv_style_set_pad_column(&styles->btn, lv_disp_dpx(theme.disp, 5)); + lv_style_set_pad_row(&styles->btn, lv_disp_dpx(theme.disp, 5)); + + static lv_color_filter_dsc_t dark_filter; + lv_color_filter_dsc_init(&dark_filter, dark_color_filter_cb); + + static lv_color_filter_dsc_t grey_filter; + lv_color_filter_dsc_init(&grey_filter, grey_filter_cb); + + style_init_reset(&styles->pressed); + lv_style_set_color_filter_dsc(&styles->pressed, &dark_filter); + lv_style_set_color_filter_opa(&styles->pressed, 35); + + style_init_reset(&styles->disabled); + lv_style_set_color_filter_dsc(&styles->disabled, &grey_filter); + lv_style_set_color_filter_opa(&styles->disabled, LV_OPA_50); + + style_init_reset(&styles->clip_corner); + lv_style_set_clip_corner(&styles->clip_corner, true); + + style_init_reset(&styles->pad_normal); + lv_style_set_pad_all(&styles->pad_normal, PAD_DEF); + lv_style_set_pad_row(&styles->pad_normal, PAD_DEF); + lv_style_set_pad_column(&styles->pad_normal, PAD_DEF); + + style_init_reset(&styles->pad_small); + lv_style_set_pad_all(&styles->pad_small, PAD_SMALL); + lv_style_set_pad_gap(&styles->pad_small, PAD_SMALL); + + style_init_reset(&styles->pad_gap); + lv_style_set_pad_row(&styles->pad_gap, lv_disp_dpx(theme.disp, 10)); + lv_style_set_pad_column(&styles->pad_gap, lv_disp_dpx(theme.disp, 10)); + + style_init_reset(&styles->line_space_large); + lv_style_set_text_line_space(&styles->line_space_large, lv_disp_dpx(theme.disp, 20)); + + style_init_reset(&styles->text_align_center); + lv_style_set_text_align(&styles->text_align_center, LV_TEXT_ALIGN_CENTER); + + style_init_reset(&styles->pad_zero); + lv_style_set_pad_all(&styles->pad_zero, 0); + lv_style_set_pad_row(&styles->pad_zero, 0); + lv_style_set_pad_column(&styles->pad_zero, 0); + + style_init_reset(&styles->pad_tiny); + lv_style_set_pad_all(&styles->pad_tiny, PAD_TINY); + lv_style_set_pad_row(&styles->pad_tiny, PAD_TINY); + lv_style_set_pad_column(&styles->pad_tiny, PAD_TINY); + + style_init_reset(&styles->bg_color_primary); + lv_style_set_bg_color(&styles->bg_color_primary, theme.color_primary); + lv_style_set_text_color(&styles->bg_color_primary, lv_color_white()); + lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER); + + style_init_reset(&styles->bg_color_primary_muted); + lv_style_set_bg_color(&styles->bg_color_primary_muted, theme.color_primary); + lv_style_set_text_color(&styles->bg_color_primary_muted, theme.color_primary); + lv_style_set_bg_opa(&styles->bg_color_primary_muted, LV_OPA_20); + + style_init_reset(&styles->bg_color_secondary); + lv_style_set_bg_color(&styles->bg_color_secondary, theme.color_secondary); + lv_style_set_text_color(&styles->bg_color_secondary, lv_color_white()); + lv_style_set_bg_opa(&styles->bg_color_secondary, LV_OPA_COVER); + + style_init_reset(&styles->bg_color_secondary_muted); + lv_style_set_bg_color(&styles->bg_color_secondary_muted, theme.color_secondary); + lv_style_set_text_color(&styles->bg_color_secondary_muted, theme.color_secondary); + lv_style_set_bg_opa(&styles->bg_color_secondary_muted, LV_OPA_20); + + style_init_reset(&styles->bg_color_grey); + lv_style_set_bg_color(&styles->bg_color_grey, color_grey); + lv_style_set_bg_opa(&styles->bg_color_grey, LV_OPA_COVER); + lv_style_set_text_color(&styles->bg_color_grey, color_text); + + style_init_reset(&styles->bg_color_white); + lv_style_set_bg_color(&styles->bg_color_white, color_card); + lv_style_set_bg_opa(&styles->bg_color_white, LV_OPA_COVER); + lv_style_set_text_color(&styles->bg_color_white, color_text); + + style_init_reset(&styles->circle); + lv_style_set_radius(&styles->circle, LV_RADIUS_CIRCLE); + + style_init_reset(&styles->no_radius); + lv_style_set_radius(&styles->no_radius, 0); + +#if LV_THEME_DEFAULT_GROW + style_init_reset(&styles->grow); + lv_style_set_transform_width(&styles->grow, lv_disp_dpx(theme.disp, 3)); + lv_style_set_transform_height(&styles->grow, lv_disp_dpx(theme.disp, 3)); +#endif + + style_init_reset(&styles->knob); + lv_style_set_bg_color(&styles->knob, theme.color_primary); + lv_style_set_bg_opa(&styles->knob, LV_OPA_COVER); + lv_style_set_pad_all(&styles->knob, lv_disp_dpx(theme.disp, 6)); + lv_style_set_radius(&styles->knob, LV_RADIUS_CIRCLE); + + style_init_reset(&styles->anim); + lv_style_set_anim_time(&styles->anim, 200); + +#if LV_USE_ARC + style_init_reset(&styles->arc_indic); + lv_style_set_arc_color(&styles->arc_indic, color_grey); + lv_style_set_arc_width(&styles->arc_indic, lv_disp_dpx(theme.disp, 15)); + lv_style_set_arc_rounded(&styles->arc_indic, true); + + style_init_reset(&styles->arc_indic_primary); + lv_style_set_arc_color(&styles->arc_indic_primary, theme.color_primary); +#endif + +#if LV_USE_DROPDOWN + style_init_reset(&styles->dropdown_list); + lv_style_set_max_height(&styles->dropdown_list, LV_DPI_DEF * 2); +#endif +#if LV_USE_CHECKBOX + style_init_reset(&styles->cb_marker); + lv_style_set_pad_all(&styles->cb_marker, lv_disp_dpx(theme.disp, 3)); + lv_style_set_border_width(&styles->cb_marker, BORDER_WIDTH); + lv_style_set_border_color(&styles->cb_marker, theme.color_primary); + lv_style_set_bg_color(&styles->cb_marker, color_card); + lv_style_set_bg_opa(&styles->cb_marker, LV_OPA_COVER); + lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2); + + style_init_reset(&styles->cb_marker_checked); + lv_style_set_bg_img_src(&styles->cb_marker_checked, LV_SYMBOL_OK); + lv_style_set_text_color(&styles->cb_marker_checked, lv_color_white()); + lv_style_set_text_font(&styles->cb_marker_checked, theme.font_small); +#endif + +#if LV_USE_SWITCH + style_init_reset(&styles->switch_knob); + lv_style_set_pad_all(&styles->switch_knob, - lv_disp_dpx(theme.disp, 4)); + lv_style_set_bg_color(&styles->switch_knob, lv_color_white()); +#endif + +#if LV_USE_LINE + style_init_reset(&styles->line); + lv_style_set_line_width(&styles->line, 1); + lv_style_set_line_color(&styles->line, color_text); +#endif + +#if LV_USE_CHART + style_init_reset(&styles->chart_bg); + lv_style_set_border_post(&styles->chart_bg, false); + lv_style_set_pad_column(&styles->chart_bg, lv_disp_dpx(theme.disp, 10)); + lv_style_set_line_color(&styles->chart_bg, color_grey); + + style_init_reset(&styles->chart_series); + lv_style_set_line_width(&styles->chart_series, lv_disp_dpx(theme.disp, 3)); + lv_style_set_radius(&styles->chart_series, lv_disp_dpx(theme.disp, 3)); + lv_style_set_size(&styles->chart_series, lv_disp_dpx(theme.disp, 8)); + lv_style_set_pad_column(&styles->chart_series, lv_disp_dpx(theme.disp, 2)); + + style_init_reset(&styles->chart_indic); + lv_style_set_radius(&styles->chart_indic,LV_RADIUS_CIRCLE); + lv_style_set_size(&styles->chart_indic, lv_disp_dpx(theme.disp, 8)); + lv_style_set_bg_color(&styles->chart_indic, theme.color_primary); + lv_style_set_bg_opa(&styles->chart_indic, LV_OPA_COVER); + + style_init_reset(&styles->chart_ticks); + lv_style_set_line_width(&styles->chart_ticks, lv_disp_dpx(theme.disp, 1)); + lv_style_set_line_color(&styles->chart_ticks, color_text); + lv_style_set_pad_all(&styles->chart_ticks, lv_disp_dpx(theme.disp, 2)); + lv_style_set_text_color(&styles->chart_ticks, lv_palette_main(LV_PALETTE_GREY)); +#endif + +#if LV_USE_METER + style_init_reset(&styles->meter_marker); + lv_style_set_line_width(&styles->meter_marker, lv_disp_dpx(theme.disp, 5)); + lv_style_set_line_color(&styles->meter_marker, color_text); + lv_style_set_size(&styles->meter_marker, lv_disp_dpx(theme.disp, 20)); + lv_style_set_pad_left(&styles->meter_marker, lv_disp_dpx(theme.disp, 15)); + + style_init_reset(&styles->meter_indic); + lv_style_set_radius(&styles->meter_indic, LV_RADIUS_CIRCLE); + lv_style_set_bg_color(&styles->meter_indic, color_text); + lv_style_set_bg_opa(&styles->meter_indic, LV_OPA_COVER); + lv_style_set_size(&styles->meter_indic, lv_disp_dpx(theme.disp, 15)); +#endif + +#if LV_USE_TABLE + style_init_reset(&styles->table_cell); + lv_style_set_border_width(&styles->table_cell, lv_disp_dpx(theme.disp, 1)); + lv_style_set_border_color(&styles->table_cell, color_grey); + lv_style_set_border_side(&styles->table_cell, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM ); +#endif + +#if LV_USE_TEXTAREA + style_init_reset(&styles->ta_cursor); + lv_style_set_border_color(&styles->ta_cursor, color_text); + lv_style_set_border_width(&styles->ta_cursor, lv_disp_dpx(theme.disp, 2)); + lv_style_set_pad_left(&styles->ta_cursor, lv_disp_dpx(theme.disp, 1)); + lv_style_set_border_side(&styles->ta_cursor, LV_BORDER_SIDE_LEFT); + lv_style_set_anim_time(&styles->ta_cursor, 400); + + style_init_reset(&styles->ta_placeholder); + lv_style_set_text_color(&styles->ta_placeholder, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, 2) : lv_palette_lighten(LV_PALETTE_GREY, 1)); +#endif + +#if LV_USE_CALENDAR + style_init_reset(&styles->calendar_bg); + lv_style_set_pad_all(&styles->calendar_bg, PAD_SMALL); + lv_style_set_pad_gap(&styles->calendar_bg, PAD_SMALL / 2); + lv_style_set_radius(&styles->calendar_bg, 0); + + style_init_reset(&styles->calendar_day); + lv_style_set_border_width(&styles->calendar_day, lv_disp_dpx(theme.disp, 1)); + lv_style_set_border_color(&styles->calendar_day, color_grey); + lv_style_set_bg_color(&styles->calendar_day, color_card); + lv_style_set_bg_opa(&styles->calendar_day, LV_OPA_20); +#endif + +#if LV_USE_COLORWHEEL + style_init_reset(&styles->colorwheel_main); + lv_style_set_arc_width(&styles->colorwheel_main, lv_disp_dpx(theme.disp, 10)); +#endif + +#if LV_USE_MSGBOX + /*To add space for for the button shadow*/ + style_init_reset(&styles->msgbox_btn_bg); + lv_style_set_pad_all(&styles->msgbox_btn_bg, lv_disp_dpx(theme.disp, 4)); + + style_init_reset(&styles->msgbox_bg); + lv_style_set_max_width(&styles->msgbox_bg, lv_pct(100)); +#endif +#if LV_USE_KEYBOARD + style_init_reset(&styles->keyboard_btn_bg); + lv_style_set_shadow_width(&styles->keyboard_btn_bg, 0); + lv_style_set_radius(&styles->keyboard_btn_bg, disp_size == DISP_SMALL ? RADIUS_DEFAULT / 2 : RADIUS_DEFAULT); +#endif + +#if LV_USE_TABVIEW + style_init_reset(&styles->tab_btn); + lv_style_set_border_color(&styles->tab_btn, theme.color_primary); + lv_style_set_border_width(&styles->tab_btn, BORDER_WIDTH * 2); + lv_style_set_border_side(&styles->tab_btn, LV_BORDER_SIDE_BOTTOM); + + style_init_reset(&styles->tab_bg_focus); + lv_style_set_outline_pad(&styles->tab_bg_focus, -BORDER_WIDTH); +#endif + +#if LV_USE_LIST + style_init_reset(&styles->list_bg); + lv_style_set_pad_hor(&styles->list_bg, PAD_DEF); + lv_style_set_pad_ver(&styles->list_bg, 0); + lv_style_set_pad_gap(&styles->list_bg, 0); + lv_style_set_clip_corner(&styles->list_bg, true); + + style_init_reset(&styles->list_btn); + lv_style_set_border_width(&styles->list_btn, lv_disp_dpx(theme.disp, 1)); + lv_style_set_border_color(&styles->list_btn, color_grey); + lv_style_set_border_side(&styles->list_btn, LV_BORDER_SIDE_BOTTOM); + lv_style_set_pad_all(&styles->list_btn, PAD_SMALL); + lv_style_set_pad_column(&styles->list_btn, PAD_SMALL); + + style_init_reset(&styles->list_item_grow); + lv_style_set_transform_width(&styles->list_item_grow, PAD_DEF); +#endif + + +#if LV_USE_LED + style_init_reset(&styles->led); + lv_style_set_bg_opa(&styles->led, LV_OPA_COVER); + lv_style_set_bg_color(&styles->led, lv_color_white()); + lv_style_set_bg_grad_color(&styles->led, lv_palette_main(LV_PALETTE_GREY)); + lv_style_set_radius(&styles->led, LV_RADIUS_CIRCLE); + lv_style_set_shadow_width(&styles->led, lv_disp_dpx(theme.disp, 15)); + lv_style_set_shadow_color(&styles->led, lv_color_white()); + lv_style_set_shadow_spread(&styles->led, lv_disp_dpx(theme.disp, 5)); +#endif + + return &theme; } /********************** * GLOBAL FUNCTIONS **********************/ -/** - * Initialize the default - * @param color_primary the primary color of the theme - * @param color_secondary the secondary color for the theme - * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` - * @param font_small pointer to a small font - * @param font_normal pointer to a normal font - * @param font_subtitle pointer to a large font - * @param font_title pointer to a extra large font - * @return a pointer to reference this theme later - */ -lv_theme_t* lv_pinetime_theme_init(lv_color_t color_primary, - lv_color_t color_secondary, - uint32_t flags, - const lv_font_t* font_small, - const lv_font_t* font_normal, - const lv_font_t* font_subtitle, - const lv_font_t* font_title) { - theme.color_primary = color_primary; - theme.color_secondary = color_secondary; - theme.font_small = font_small; - theme.font_normal = font_normal; - theme.font_subtitle = font_subtitle; - theme.font_title = font_title; - theme.flags = flags; - - basic_init(); - - theme.apply_xcb = theme_apply; - - inited = true; - - return &theme; +lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font) +{ + + /*This trick is required only to avoid the garbage collection of + *styles' data if LVGL is used in a binding (e.g. Micropython) + *In a general case styles could be in simple `static lv_style_t my_style...` variables*/ + if(!inited) { + LV_GC_ROOT(_lv_theme_default_styles) = lv_mem_alloc(sizeof(my_theme_styles_t)); + styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_default_styles); + } + + if(LV_HOR_RES <= 320) disp_size = DISP_SMALL; + else if(LV_HOR_RES < 720) disp_size = DISP_MEDIUM; + else disp_size = DISP_LARGE; + + theme.disp = disp; + theme.color_primary = color_primary; + theme.color_secondary = color_secondary; + theme.font_small = font; + theme.font_normal = font; + theme.font_large = font; + theme.apply_cb = theme_apply; + theme.flags = dark ? MODE_DARK : 0; + + lv_pinetime_theme_init(lv_disp_get_default(), + lv_color_white(), + lv_color_hex(0xC0C0C0), + 0, + &jetbrains_mono_bold_20); + inited = true; + + if(disp == NULL || lv_disp_get_theme(disp) == &theme) lv_obj_report_style_change(NULL); + + return (lv_theme_t *)&theme; +} + +bool lv_theme_default_is_inited(void) +{ + return inited; } -static void theme_apply(lv_obj_t* obj, lv_theme_style_t name) { - lv_style_list_t* list; - - /*To avoid warnings*/ - uint32_t name_int = (uint32_t) name; - switch (name_int) { - case LV_THEME_NONE: - break; - - case LV_THEME_SCR: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); - list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); - _lv_style_list_add_style(list, &style_bg); - _lv_style_list_add_style(list, &style_label_white); - break; - - case LV_THEME_OBJ: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); - list = lv_obj_get_style_list(obj, LV_OBJ_PART_MAIN); - _lv_style_list_add_style(list, &style_box); - break; - - case LV_THEME_CONT: - lv_obj_clean_style_list(obj, LV_OBJ_PART_MAIN); - list = lv_obj_get_style_list(obj, LV_CONT_PART_MAIN); - _lv_style_list_add_style(list, &style_box); - break; - - case LV_THEME_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); - _lv_style_list_add_style(list, &style_btn); - //_lv_style_list_add_style(list, &style_bg_grad); - break; - - case LV_THEME_BTNMATRIX: - list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BG); - _lv_style_list_add_style(list, &style_bg); - _lv_style_list_add_style(list, &style_pad_small); - - list = lv_obj_get_style_list(obj, LV_BTNMATRIX_PART_BTN); - _lv_style_list_add_style(list, &style_btn); - //_lv_style_list_add_style(list, &style_bg_grad); - //_lv_style_list_add_style(list, &style_bg_click); - break; - - case LV_THEME_BAR: - lv_obj_clean_style_list(obj, LV_BAR_PART_BG); - list = lv_obj_get_style_list(obj, LV_BAR_PART_BG); - - lv_obj_clean_style_list(obj, LV_BAR_PART_INDIC); - list = lv_obj_get_style_list(obj, LV_BAR_PART_INDIC); - _lv_style_list_add_style(list, &style_bar_indic); - break; - - case LV_THEME_IMAGE: - lv_obj_clean_style_list(obj, LV_IMG_PART_MAIN); - list = lv_obj_get_style_list(obj, LV_IMG_PART_MAIN); - _lv_style_list_add_style(list, &style_icon); - break; - - case LV_THEME_LABEL: - lv_obj_clean_style_list(obj, LV_LABEL_PART_MAIN); - list = lv_obj_get_style_list(obj, LV_LABEL_PART_MAIN); - _lv_style_list_add_style(list, &style_label_white); - break; - - case LV_THEME_SLIDER: - lv_obj_clean_style_list(obj, LV_SLIDER_PART_BG); - list = lv_obj_get_style_list(obj, LV_SLIDER_PART_BG); - _lv_style_list_add_style(list, &style_sw_bg); - - lv_obj_clean_style_list(obj, LV_SLIDER_PART_INDIC); - list = lv_obj_get_style_list(obj, LV_SLIDER_PART_INDIC); - - lv_obj_clean_style_list(obj, LV_SLIDER_PART_KNOB); - list = lv_obj_get_style_list(obj, LV_SLIDER_PART_KNOB); - _lv_style_list_add_style(list, &style_slider_knob); - break; - - case LV_THEME_LIST: - lv_obj_clean_style_list(obj, LV_LIST_PART_BG); - list = lv_obj_get_style_list(obj, LV_LIST_PART_BG); - _lv_style_list_add_style(list, &style_box); - - lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE); - list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLABLE); - - lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR); - list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); - _lv_style_list_add_style(list, &style_scrollbar); - break; - - case LV_THEME_LIST_BTN: - lv_obj_clean_style_list(obj, LV_BTN_PART_MAIN); - list = lv_obj_get_style_list(obj, LV_BTN_PART_MAIN); - _lv_style_list_add_style(list, &style_list_btn); - break; - - case LV_THEME_ARC: - lv_obj_clean_style_list(obj, LV_ARC_PART_BG); - list = lv_obj_get_style_list(obj, LV_ARC_PART_BG); - _lv_style_list_add_style(list, &style_arc_bg); - - lv_obj_clean_style_list(obj, LV_ARC_PART_INDIC); - list = lv_obj_get_style_list(obj, LV_ARC_PART_INDIC); - _lv_style_list_add_style(list, &style_arc_indic); - - lv_obj_clean_style_list(obj, LV_ARC_PART_KNOB); - list = lv_obj_get_style_list(obj, LV_ARC_PART_KNOB); - _lv_style_list_add_style(list, &style_arc_knob); - break; - - case LV_THEME_SWITCH: - lv_obj_clean_style_list(obj, LV_SWITCH_PART_BG); - list = lv_obj_get_style_list(obj, LV_SWITCH_PART_BG); - _lv_style_list_add_style(list, &style_sw_bg); - - lv_obj_clean_style_list(obj, LV_SWITCH_PART_INDIC); - list = lv_obj_get_style_list(obj, LV_SWITCH_PART_INDIC); - _lv_style_list_add_style(list, &style_sw_indic); - - lv_obj_clean_style_list(obj, LV_SWITCH_PART_KNOB); - list = lv_obj_get_style_list(obj, LV_SWITCH_PART_KNOB); - _lv_style_list_add_style(list, &style_sw_knob); - break; - - case LV_THEME_DROPDOWN: - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_MAIN); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_MAIN); - _lv_style_list_add_style(list, &style_btn); - _lv_style_list_add_style(list, &style_pad); - - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_LIST); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_LIST); - _lv_style_list_add_style(list, &style_box); - _lv_style_list_add_style(list, &style_ddlist_list); - _lv_style_list_add_style(list, &style_pad); - - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SELECTED); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SELECTED); - _lv_style_list_add_style(list, &style_ddlist_selected); - - lv_obj_clean_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); - list = lv_obj_get_style_list(obj, LV_DROPDOWN_PART_SCROLLBAR); - _lv_style_list_add_style(list, &style_scrollbar); - break; - - case LV_THEME_TABLE: - list = lv_obj_get_style_list(obj, LV_TABLE_PART_BG); - _lv_style_list_add_style(list, &style_bg); - - int idx = 1; /* start value should be 1, not zero, since cell styles - start at 1 due to presence of LV_TABLE_PART_BG=0 - in the enum (lv_table.h) */ - /* declaring idx outside loop to work with older compilers */ - for (; idx <= LV_TABLE_CELL_STYLE_CNT; idx++) { - list = lv_obj_get_style_list(obj, idx); - _lv_style_list_add_style(list, &style_table_cell); - _lv_style_list_add_style(list, &style_label_white); - } - break; - - case LV_THEME_LINEMETER: - list = lv_obj_get_style_list(obj, LV_LINEMETER_PART_MAIN); - _lv_style_list_add_style(list, &style_bg); - _lv_style_list_add_style(list, &style_lmeter); - break; - - case LV_THEME_CHART: - lv_obj_clean_style_list(obj, LV_CHART_PART_SERIES); - list = lv_obj_get_style_list(obj, LV_CHART_PART_SERIES); - _lv_style_list_add_style(list, &style_btn); - _lv_style_list_add_style(list, &style_chart_serie); - break; - - case LV_THEME_CHECKBOX: - list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BG); - _lv_style_list_add_style(list, &style_cb_bg); - - list = lv_obj_get_style_list(obj, LV_CHECKBOX_PART_BULLET); - _lv_style_list_add_style(list, &style_btn); - _lv_style_list_add_style(list, &style_cb_bullet); - break; - - default: - break; - } - - lv_obj_refresh_style(obj, LV_OBJ_PART_ALL, LV_STYLE_PROP_ALL); + +static void theme_apply(lv_theme_t * th, lv_obj_t * obj) +{ + LV_UNUSED(th); + + if(lv_obj_get_parent(obj) == NULL) { + lv_obj_add_style(obj, &styles->scr, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + return; + } + + if(lv_obj_check_type(obj, &lv_obj_class)) { +#if LV_USE_TABVIEW + lv_obj_t * parent = lv_obj_get_parent(obj); + /*Tabview content area*/ + if(lv_obj_check_type(parent, &lv_tabview_class)) { + return; + } + /*Tabview pages*/ + else if(lv_obj_check_type(lv_obj_get_parent(parent), &lv_tabview_class)) { + lv_obj_add_style(obj, &styles->pad_normal, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + return; + } +#endif + +#if LV_USE_WIN + /*Header*/ + if(lv_obj_get_child_id(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) { + lv_obj_add_style(obj, &styles->bg_color_grey, 0); + lv_obj_add_style(obj, &styles->pad_tiny, 0); + return; + } + /*Content*/ + else if(lv_obj_get_child_id(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) { + lv_obj_add_style(obj, &styles->scr, 0); + lv_obj_add_style(obj, &styles->pad_normal, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + return; + } +#endif + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + } + #if LV_USE_BTN + else if(lv_obj_check_type(obj, &lv_btn_class)) { + lv_obj_add_style(obj, &styles->btn, 0); + lv_obj_add_style(obj, &styles->bg_color_primary, 0); + lv_obj_add_style(obj, &styles->transition_delayed, 0); + lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->transition_normal, LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); +#if LV_THEME_DEFAULT_GROW + lv_obj_add_style(obj, &styles->grow, LV_STATE_PRESSED); +#endif + lv_obj_add_style(obj, &styles->bg_color_secondary, LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED); + } +#endif + +#if LV_USE_LINE + else if(lv_obj_check_type(obj, &lv_line_class)) { + lv_obj_add_style(obj, &styles->line, 0); + } +#endif + +#if LV_USE_BTNMATRIX + else if(lv_obj_check_type(obj, &lv_btnmatrix_class)) { +#if LV_USE_MSGBOX + if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) { + lv_obj_add_style(obj, &styles->msgbox_btn_bg, 0); + lv_obj_add_style(obj, &styles->pad_gap, 0); + lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED); + return; + } +#endif +#if LV_USE_TABVIEW + if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_tabview_class)) { + lv_obj_add_style(obj, &styles->bg_color_white, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->tab_bg_focus, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->tab_btn, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->tab_bg_focus, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + return; + } +#endif + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); + } +#endif + +#if LV_USE_BAR + else if(lv_obj_check_type(obj, &lv_bar_class)) { + lv_obj_add_style(obj, &styles->bg_color_primary_muted, 0); + lv_obj_add_style(obj, &styles->circle, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR); + } +#endif + +#if LV_USE_SLIDER + else if(lv_obj_check_type(obj, &lv_slider_class)) { + lv_obj_add_style(obj, &styles->bg_color_primary_muted, 0); + lv_obj_add_style(obj, &styles->circle, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB); +#if LV_THEME_DEFAULT_GROW + lv_obj_add_style(obj, &styles->grow, LV_PART_KNOB | LV_STATE_PRESSED); +#endif + lv_obj_add_style(obj, &styles->transition_delayed, LV_PART_KNOB); + lv_obj_add_style(obj, &styles->transition_normal, LV_PART_KNOB | LV_STATE_PRESSED); + } +#endif + +#if LV_USE_TABLE + else if(lv_obj_check_type(obj, &lv_table_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->pad_zero, 0); + lv_obj_add_style(obj, &styles->no_radius, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->table_cell, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->pad_normal, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->bg_color_secondary, LV_PART_ITEMS | LV_STATE_EDITED); + } +#endif + +#if LV_USE_CHECKBOX + else if(lv_obj_check_type(obj, &lv_checkbox_class)) { + lv_obj_add_style(obj, &styles->pad_gap, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->cb_marker, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->cb_marker_checked, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->pressed, LV_PART_INDICATOR | LV_STATE_PRESSED); +#if LV_THEME_DEFAULT_GROW + lv_obj_add_style(obj, &styles->grow, LV_PART_INDICATOR | LV_STATE_PRESSED); +#endif + lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->transition_delayed, LV_PART_INDICATOR); + } +#endif + +#if LV_USE_SWITCH + else if(lv_obj_check_type(obj, &lv_switch_class)) { + lv_obj_add_style(obj, &styles->bg_color_grey, 0); + lv_obj_add_style(obj, &styles->circle, 0); + lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB); + lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_KNOB); + lv_obj_add_style(obj, &styles->switch_knob, LV_PART_KNOB); + lv_obj_add_style(obj, &styles->disabled, LV_PART_KNOB | LV_STATE_DISABLED); + } +#endif + +#if LV_USE_CHART + else if(lv_obj_check_type(obj, &lv_chart_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->pad_small, 0); + lv_obj_add_style(obj, &styles->chart_bg, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &styles->chart_series, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->chart_indic, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->chart_ticks, LV_PART_TICKS); + lv_obj_add_style(obj, &styles->chart_series, LV_PART_CURSOR); + } +#endif + +#if LV_USE_ROLLER + else if(lv_obj_check_type(obj, &lv_roller_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->anim, 0); + lv_obj_add_style(obj, &styles->line_space_large, 0); + lv_obj_add_style(obj, &styles->text_align_center, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_SELECTED); + } +#endif + +#if LV_USE_DROPDOWN + else if(lv_obj_check_type(obj, &lv_dropdown_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->pad_small, 0); + lv_obj_add_style(obj, &styles->transition_delayed, 0); + lv_obj_add_style(obj, &styles->transition_normal, LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR); + } + else if(lv_obj_check_type(obj, &lv_dropdownlist_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->clip_corner, 0); + lv_obj_add_style(obj, &styles->line_space_large, 0); + lv_obj_add_style(obj, &styles->dropdown_list, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_SELECTED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_SELECTED | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->pressed, LV_PART_SELECTED | LV_STATE_PRESSED); + } +#endif + +#if LV_USE_ARC + else if(lv_obj_check_type(obj, &lv_arc_class)) { + lv_obj_add_style(obj, &styles->arc_indic, 0); + lv_obj_add_style(obj, &styles->arc_indic, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->arc_indic_primary, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB); + } +#endif + + +#if LV_USE_SPINNER + else if(lv_obj_check_type(obj, &lv_spinner_class)) { + lv_obj_add_style(obj, &styles->arc_indic, 0); + lv_obj_add_style(obj, &styles->arc_indic, LV_PART_INDICATOR); + lv_obj_add_style(obj, &styles->arc_indic_primary, LV_PART_INDICATOR); + } +#endif + +#if LV_USE_METER + else if(lv_obj_check_type(obj, &lv_meter_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->circle, 0); + lv_obj_add_style(obj, &styles->meter_indic, LV_PART_INDICATOR); + } +#endif + +#if LV_USE_TEXTAREA + else if(lv_obj_check_type(obj, &lv_textarea_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->pad_small, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + lv_obj_add_style(obj, &styles->ta_cursor, LV_PART_CURSOR | LV_STATE_FOCUSED); + lv_obj_add_style(obj, &styles->ta_placeholder, LV_PART_TEXTAREA_PLACEHOLDER); + } +#endif + +#if LV_USE_CALENDAR + else if(lv_obj_check_type(obj, &lv_calendar_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->calendar_bg, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->calendar_day, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); + } +#endif + +#if LV_USE_CALENDAR_HEADER_ARROW + else if(lv_obj_check_type(obj, &lv_calendar_header_arrow_class)) { + lv_obj_add_style(obj, &styles->card, 0); + } +#endif + +#if LV_USE_CALENDAR_HEADER_DROPDOWN + else if(lv_obj_check_type(obj, &lv_calendar_header_dropdown_class)) { + lv_obj_add_style(obj, &styles->card, 0); + } +#endif + +#if LV_USE_KEYBOARD + else if(lv_obj_check_type(obj, &lv_keyboard_class)) { + lv_obj_add_style(obj, &styles->scr, 0); + lv_obj_add_style(obj, disp_size == DISP_LARGE ? &styles->pad_small : &styles->pad_tiny, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->keyboard_btn_bg, LV_PART_ITEMS); + lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->bg_color_grey, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED); + } +#endif +#if LV_USE_LIST + else if(lv_obj_check_type(obj, &lv_list_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->list_bg, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + return; + } + else if(lv_obj_check_type(obj, &lv_list_text_class)) { + lv_obj_add_style(obj, &styles->bg_color_grey, 0); + lv_obj_add_style(obj, &styles->list_item_grow, 0); + } + else if(lv_obj_check_type(obj, &lv_list_btn_class)) { + lv_obj_add_style(obj, &styles->bg_color_white, 0); + lv_obj_add_style(obj, &styles->list_btn, 0); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->list_item_grow, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->list_item_grow, LV_STATE_PRESSED); + lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED); + + } +#endif +#if LV_USE_MSGBOX + else if(lv_obj_check_type(obj, &lv_msgbox_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->msgbox_bg, 0); + return; + } +#endif +#if LV_USE_SPINBOX + else if(lv_obj_check_type(obj, &lv_spinbox_class)) { + lv_obj_add_style(obj, &styles->card, 0); + lv_obj_add_style(obj, &styles->pad_small, 0); + lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); + lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); + lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_CURSOR); + } +#endif +#if LV_USE_TILEVIEW + else if(lv_obj_check_type(obj, &lv_tileview_class)) { + lv_obj_add_style(obj, &styles->scr, 0); + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + } + else if(lv_obj_check_type(obj, &lv_tileview_tile_class)) { + lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); + lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); + } +#endif + +#if LV_USE_TABVIEW + if(lv_obj_check_type(obj, &lv_tabview_class)) { + lv_obj_add_style(obj, &styles->scr, 0); + lv_obj_add_style(obj, &styles->pad_zero, 0); + return; + } +#endif + +#if LV_USE_COLORWHEEL + else if(lv_obj_check_type(obj, &lv_colorwheel_class)) { + lv_obj_add_style(obj, &styles->colorwheel_main, 0); + lv_obj_add_style(obj, &styles->pad_normal, 0); + lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_KNOB); + lv_obj_add_style(obj, &styles->pad_normal, LV_PART_KNOB); + } +#endif + +#if LV_USE_LED + else if(lv_obj_check_type(obj, &lv_led_class)) { + lv_obj_add_style(obj, &styles->led, 0); + } +#endif } /********************** * STATIC FUNCTIONS **********************/ + +static void style_init_reset(lv_style_t * style) +{ + if(inited) lv_style_reset(style); + else lv_style_init(style); +} + +#endif \ No newline at end of file diff --git a/src/displayapp/lv_pinetime_theme.h b/src/displayapp/lv_pinetime_theme.h index f914516d3d..f286fe4696 100644 --- a/src/displayapp/lv_pinetime_theme.h +++ b/src/displayapp/lv_pinetime_theme.h @@ -39,20 +39,17 @@ extern "C" { * Initialize the default * @param color_primary the primary color of the theme * @param color_secondary the secondary color for the theme - * @param flags ORed flags starting with `LV_THEME_DEF_FLAG_...` - * @param font_small pointer to a small font - * @param font_normal pointer to a normal font - * @param font_subtitle pointer to a large font - * @param font_title pointer to a extra large font + * @param font pointer to a font to use. * @return a pointer to reference this theme later */ -lv_theme_t* lv_pinetime_theme_init(lv_color_t color_primary, +lv_theme_t* lv_pinetime_theme_init(lv_disp_t* disp, + lv_color_t color_primary, lv_color_t color_secondary, - uint32_t flags, - const lv_font_t* font_small, - const lv_font_t* font_normal, - const lv_font_t* font_subtitle, - const lv_font_t* font_title); + bool dark, + const lv_font_t* font); + +bool lv_theme_default_is_inited(void); + /********************** * MACROS **********************/ diff --git a/src/displayapp/screens/Alarm.cpp b/src/displayapp/screens/Alarm.cpp index 959cb0b26d..343b92ea22 100644 --- a/src/displayapp/screens/Alarm.cpp +++ b/src/displayapp/screens/Alarm.cpp @@ -22,78 +22,78 @@ using namespace Pinetime::Applications::Screens; using Pinetime::Controllers::AlarmController; -static void btnEventHandler(lv_obj_t* obj, lv_event_t event) { - Alarm* screen = static_cast(obj->user_data); - screen->OnButtonEvent(obj, event); +static void btnEventHandler(lv_event_t *event) { + Alarm* screen = static_cast(lv_event_get_user_data(event)); + screen->OnButtonEvent(lv_event_get_target(event), event); } Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController) : Screen(app), running {true}, alarmController {alarmController} { - time = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); - lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + time = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(time, &jetbrains_mono_76, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(time, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); alarmHours = alarmController.Hours(); alarmMinutes = alarmController.Minutes(); lv_label_set_text_fmt(time, "%02lu:%02lu", alarmHours, alarmMinutes); - lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -25); + lv_obj_align(time, LV_ALIGN_CENTER, 0, -25); - btnHoursUp = lv_btn_create(lv_scr_act(), nullptr); + btnHoursUp = lv_btn_create(lv_scr_act()); btnHoursUp->user_data = this; - lv_obj_set_event_cb(btnHoursUp, btnEventHandler); + lv_obj_add_event_cb(btnHoursUp, btnEventHandler, LV_EVENT_ALL, btnHoursUp->user_data); lv_obj_set_size(btnHoursUp, 60, 40); - lv_obj_align(btnHoursUp, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, -85); - txtHrUp = lv_label_create(btnHoursUp, nullptr); + lv_obj_align(btnHoursUp, LV_ALIGN_LEFT_MID, 20, -85); + txtHrUp = lv_label_create(btnHoursUp); lv_label_set_text_static(txtHrUp, "+"); - btnHoursDown = lv_btn_create(lv_scr_act(), nullptr); + btnHoursDown = lv_btn_create(lv_scr_act()); btnHoursDown->user_data = this; - lv_obj_set_event_cb(btnHoursDown, btnEventHandler); + lv_obj_add_event_cb(btnHoursDown, btnEventHandler, LV_EVENT_ALL, btnHoursDown->user_data); lv_obj_set_size(btnHoursDown, 60, 40); - lv_obj_align(btnHoursDown, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, 35); - txtHrDown = lv_label_create(btnHoursDown, nullptr); + lv_obj_align(btnHoursDown, LV_ALIGN_LEFT_MID, 20, 35); + txtHrDown = lv_label_create(btnHoursDown); lv_label_set_text_static(txtHrDown, "-"); - btnMinutesUp = lv_btn_create(lv_scr_act(), nullptr); + btnMinutesUp = lv_btn_create(lv_scr_act()); btnMinutesUp->user_data = this; - lv_obj_set_event_cb(btnMinutesUp, btnEventHandler); + lv_obj_add_event_cb(btnMinutesUp, btnEventHandler, LV_EVENT_ALL, btnMinutesUp->user_data); lv_obj_set_size(btnMinutesUp, 60, 40); - lv_obj_align(btnMinutesUp, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -20, -85); - txtMinUp = lv_label_create(btnMinutesUp, nullptr); + lv_obj_align(btnMinutesUp, LV_ALIGN_RIGHT_MID, -20, -85); + txtMinUp = lv_label_create(btnMinutesUp); lv_label_set_text_static(txtMinUp, "+"); - btnMinutesDown = lv_btn_create(lv_scr_act(), nullptr); + btnMinutesDown = lv_btn_create(lv_scr_act()); btnMinutesDown->user_data = this; - lv_obj_set_event_cb(btnMinutesDown, btnEventHandler); + lv_obj_add_event_cb(btnMinutesDown, btnEventHandler, LV_EVENT_ALL, btnMinutesDown->user_data); lv_obj_set_size(btnMinutesDown, 60, 40); - lv_obj_align(btnMinutesDown, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -20, 35); - txtMinDown = lv_label_create(btnMinutesDown, nullptr); + lv_obj_align(btnMinutesDown, LV_ALIGN_RIGHT_MID, -20, 35); + txtMinDown = lv_label_create(btnMinutesDown); lv_label_set_text_static(txtMinDown, "-"); - btnEnable = lv_btn_create(lv_scr_act(), nullptr); + btnEnable = lv_btn_create(lv_scr_act()); btnEnable->user_data = this; - lv_obj_set_event_cb(btnEnable, btnEventHandler); + lv_obj_add_event_cb(btnEnable, btnEventHandler, LV_EVENT_ALL, btnEnable->user_data); lv_obj_set_size(btnEnable, 115, 50); - lv_obj_align(btnEnable, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); - txtEnable = lv_label_create(btnEnable, nullptr); + lv_obj_align(btnEnable, LV_ALIGN_BOTTOM_LEFT, 0, 0); + txtEnable = lv_label_create(btnEnable); SetEnableButtonState(); - btnRecur = lv_btn_create(lv_scr_act(), nullptr); + btnRecur = lv_btn_create(lv_scr_act()); btnRecur->user_data = this; - lv_obj_set_event_cb(btnRecur, btnEventHandler); + lv_obj_add_event_cb(btnRecur, btnEventHandler, LV_EVENT_ALL, btnRecur->user_data); lv_obj_set_size(btnRecur, 115, 50); - lv_obj_align(btnRecur, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); - txtRecur = lv_label_create(btnRecur, nullptr); + lv_obj_align(btnRecur, LV_ALIGN_BOTTOM_RIGHT, 0, 0); + txtRecur = lv_label_create(btnRecur); SetRecurButtonState(); - btnInfo = lv_btn_create(lv_scr_act(), nullptr); + btnInfo = lv_btn_create(lv_scr_act()); btnInfo->user_data = this; - lv_obj_set_event_cb(btnInfo, btnEventHandler); + lv_obj_add_event_cb(btnInfo, btnEventHandler, LV_EVENT_ALL, btnInfo->user_data); lv_obj_set_size(btnInfo, 50, 40); - lv_obj_align(btnInfo, lv_scr_act(), LV_ALIGN_CENTER, 0, -85); - txtInfo = lv_label_create(btnInfo, nullptr); + lv_obj_align(btnInfo, LV_ALIGN_CENTER, 0, -85); + txtInfo = lv_label_create(btnInfo); lv_label_set_text_static(txtInfo, "i"); } @@ -101,9 +101,9 @@ Alarm::~Alarm() { lv_obj_clean(lv_scr_act()); } -void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t event) { +void Alarm::OnButtonEvent(lv_obj_t* obj, lv_event_t* event) { using Pinetime::Controllers::AlarmController; - if (event == LV_EVENT_CLICKED) { + if (lv_event_get_code(event) == LV_EVENT_CLICKED) { if (obj == btnEnable) { if (alarmController.State() == AlarmController::AlarmState::Alerting) { alarmController.StopAlerting(); @@ -187,27 +187,27 @@ void Alarm::SetEnableButtonState() { switch (alarmController.State()) { case AlarmController::AlarmState::Set: lv_label_set_text(txtEnable, "ON"); - lv_obj_set_style_local_bg_color(btnEnable, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); + lv_obj_set_style_bg_color(btnEnable, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_DEFAULT); break; case AlarmController::AlarmState::Not_Set: lv_label_set_text(txtEnable, "OFF"); - lv_obj_set_style_local_bg_color(btnEnable, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_obj_set_style_bg_color(btnEnable, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); break; case AlarmController::AlarmState::Alerting: lv_label_set_text(txtEnable, Symbols::stop); - lv_obj_set_style_local_bg_color(btnEnable, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); + lv_obj_set_style_bg_color(btnEnable, lv_palette_main(LV_PALETTE_RED), LV_PART_MAIN | LV_STATE_DEFAULT); } } void Alarm::ShowInfo() { - btnMessage = lv_btn_create(lv_scr_act(), nullptr); + btnMessage = lv_btn_create(lv_scr_act()); btnMessage->user_data = this; - lv_obj_set_event_cb(btnMessage, btnEventHandler); + lv_obj_add_event_cb(btnMessage, btnEventHandler, LV_EVENT_ALL, btnMessage->user_data); lv_obj_set_height(btnMessage, 200); lv_obj_set_width(btnMessage, 150); - lv_obj_align(btnMessage, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); - txtMessage = lv_label_create(btnMessage, nullptr); - lv_obj_set_style_local_bg_color(btnMessage, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_NAVY); + lv_obj_align(btnMessage, LV_ALIGN_CENTER, 0, 0); + txtMessage = lv_label_create(btnMessage); + lv_obj_set_style_bg_color(btnMessage, lv_color_hex(0x000080), LV_PART_MAIN | LV_STATE_DEFAULT); if (alarmController.State() == AlarmController::AlarmState::Set) { auto timeToAlarm = alarmController.SecondsToAlarm(); diff --git a/src/displayapp/screens/Alarm.h b/src/displayapp/screens/Alarm.h index abf97ebaa1..786e030d16 100644 --- a/src/displayapp/screens/Alarm.h +++ b/src/displayapp/screens/Alarm.h @@ -30,7 +30,7 @@ namespace Pinetime { Alarm(DisplayApp* app, Controllers::AlarmController& alarmController); ~Alarm() override; void SetAlerting(); - void OnButtonEvent(lv_obj_t* obj, lv_event_t event); + void OnButtonEvent(lv_obj_t* obj, lv_event_t* event); private: bool running; diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp index 44ea7f51b9..54111f2513 100644 --- a/src/displayapp/screens/BatteryInfo.cpp +++ b/src/displayapp/screens/BatteryInfo.cpp @@ -10,46 +10,46 @@ BatteryInfo::BatteryInfo(Pinetime::Applications::DisplayApp* app, Pinetime::Cont batteryPercent = batteryController.PercentRemaining(); batteryVoltage = batteryController.Voltage(); - charging_bar = lv_bar_create(lv_scr_act(), nullptr); + charging_bar = lv_bar_create(lv_scr_act()); lv_obj_set_size(charging_bar, 200, 15); lv_bar_set_range(charging_bar, 0, 100); - lv_obj_align(charging_bar, nullptr, LV_ALIGN_CENTER, 0, 10); - lv_bar_set_anim_time(charging_bar, 1000); - lv_obj_set_style_local_radius(charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, lv_color_hex(0x222222)); - lv_obj_set_style_local_bg_opa(charging_bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_OPA_100); - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, lv_color_hex(0xFF0000)); + lv_obj_align(charging_bar, LV_ALIGN_CENTER, 0, 10); + lv_obj_set_style_anim_time(charging_bar, 1000, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(charging_bar, LV_RADIUS_CIRCLE, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(charging_bar, lv_color_hex(0x222222), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_opa(charging_bar, LV_OPA_100, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(charging_bar, lv_color_hex(0xFF0000), LV_PART_INDICATOR | LV_STATE_DEFAULT); lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON); - status = lv_label_create(lv_scr_act(), nullptr); + status = lv_label_create(lv_scr_act()); lv_label_set_text_static(status, "Reading Battery status"); - lv_label_set_align(status, LV_LABEL_ALIGN_CENTER); - lv_obj_align(status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); + lv_obj_set_style_text_align(status, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align_to(status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); - percent = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(percent, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); + percent = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(percent, &jetbrains_mono_76, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_fmt(percent, "%02i%%", batteryPercent); - lv_label_set_align(percent, LV_LABEL_ALIGN_LEFT); - lv_obj_align(percent, nullptr, LV_ALIGN_CENTER, 0, -60); + lv_obj_set_style_text_align(percent, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(percent, LV_ALIGN_CENTER, 0, -60); - voltage = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(voltage, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xC6A600)); + voltage = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_color(voltage, lv_color_hex(0xC6A600), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10); - lv_label_set_align(voltage, LV_LABEL_ALIGN_CENTER); - lv_obj_align(voltage, nullptr, LV_ALIGN_CENTER, 0, 95); + lv_obj_set_style_text_align(voltage, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(voltage, LV_ALIGN_CENTER, 0, 95); - lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text_static(backgroundLabel, ""); - taskRefresh = lv_task_create(RefreshTaskCallback, 5000, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, 5000, this); Refresh(); } BatteryInfo::~BatteryInfo() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_obj_clean(lv_scr_act()); } @@ -59,22 +59,22 @@ void BatteryInfo::Refresh() { batteryVoltage = batteryController.Voltage(); if (batteryController.IsCharging()) { - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED); + lv_obj_set_style_bg_color(charging_bar, lv_palette_main(LV_PALETTE_RED), LV_PART_INDICATOR | LV_STATE_DEFAULT); lv_label_set_text_static(status, "Charging"); } else if (batteryPercent == 100) { - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_BLUE); + lv_obj_set_style_bg_color(charging_bar, lv_palette_main(LV_PALETTE_BLUE), LV_PART_INDICATOR | LV_STATE_DEFAULT); lv_label_set_text_static(status, "Fully charged"); } else if (batteryPercent < 10) { - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_YELLOW); + lv_obj_set_style_bg_color(charging_bar, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_INDICATOR | LV_STATE_DEFAULT); lv_label_set_text_static(status, "Battery low"); } else { - lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_GREEN); + lv_obj_set_style_bg_color(charging_bar, lv_palette_main(LV_PALETTE_GREEN), LV_PART_INDICATOR | LV_STATE_DEFAULT); lv_label_set_text_static(status, "Discharging"); } lv_label_set_text_fmt(percent, "%02i%%", batteryPercent); - lv_obj_align(status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); + lv_obj_align_to(status, charging_bar, LV_ALIGN_OUT_BOTTOM_MID, 0, 20); lv_label_set_text_fmt(voltage, "%1i.%02i volts", batteryVoltage / 1000, batteryVoltage % 1000 / 10); lv_bar_set_value(charging_bar, batteryPercent, LV_ANIM_ON); } diff --git a/src/displayapp/screens/BatteryInfo.h b/src/displayapp/screens/BatteryInfo.h index 63454a264a..fcbb50643e 100644 --- a/src/displayapp/screens/BatteryInfo.h +++ b/src/displayapp/screens/BatteryInfo.h @@ -29,7 +29,7 @@ namespace Pinetime { lv_obj_t* charging_bar; lv_obj_t* status; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; uint8_t batteryPercent = 0; uint16_t batteryVoltage = 0; diff --git a/src/displayapp/screens/Brightness.cpp b/src/displayapp/screens/Brightness.cpp index 1278cd62aa..9352ff2610 100644 --- a/src/displayapp/screens/Brightness.cpp +++ b/src/displayapp/screens/Brightness.cpp @@ -3,27 +3,26 @@ using namespace Pinetime::Applications::Screens; -void slider_event_cb(lv_obj_t* slider, lv_event_t event) { - if (event == LV_EVENT_VALUE_CHANGED) { - auto* brightnessSlider = static_cast(slider->user_data); +void slider_event_cb(lv_event_t* event) { + if (lv_event_get_code(event) == LV_EVENT_VALUE_CHANGED) { + auto* brightnessSlider = static_cast(lv_event_get_user_data(event)); brightnessSlider->OnValueChanged(); } } Brightness::Brightness(Pinetime::Applications::DisplayApp* app, Controllers::BrightnessController& brightness) : Screen(app), brightness {brightness} { - slider = lv_slider_create(lv_scr_act(), nullptr); + slider = lv_slider_create(lv_scr_act()); lv_obj_set_user_data(slider, this); - lv_obj_set_width(slider, LV_DPI * 2); - lv_obj_align(slider, nullptr, LV_ALIGN_CENTER, 0, 0); - lv_obj_set_event_cb(slider, slider_event_cb); + lv_obj_set_width(slider, LV_DPI_DEF * 2); + lv_obj_align(slider, LV_ALIGN_CENTER, 0, 0); + lv_obj_add_event_cb(slider, slider_event_cb, LV_EVENT_ALL, slider->user_data); lv_slider_set_range(slider, 0, 2); lv_slider_set_value(slider, LevelToInt(brightness.Level()), LV_ANIM_OFF); - slider_label = lv_label_create(lv_scr_act(), nullptr); + slider_label = lv_label_create(slider); lv_label_set_text(slider_label, LevelToString(brightness.Level())); - lv_obj_set_auto_realign(slider_label, true); - lv_obj_align(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 30); + lv_obj_align(slider_label, LV_ALIGN_OUT_BOTTOM_MID, 0, 30); } Brightness::~Brightness() { diff --git a/src/displayapp/screens/Brightness.h b/src/displayapp/screens/Brightness.h index 14e48592e6..39394787a6 100644 --- a/src/displayapp/screens/Brightness.h +++ b/src/displayapp/screens/Brightness.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include "Screen.h" #include "components/brightness/BrightnessController.h" diff --git a/src/displayapp/screens/Clock.h b/src/displayapp/screens/Clock.h index 648f72daac..dd7f478908 100644 --- a/src/displayapp/screens/Clock.h +++ b/src/displayapp/screens/Clock.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include diff --git a/src/displayapp/screens/DropDownDemo.cpp b/src/displayapp/screens/DropDownDemo.cpp index 9043c20dc4..f90cb4632f 100644 --- a/src/displayapp/screens/DropDownDemo.cpp +++ b/src/displayapp/screens/DropDownDemo.cpp @@ -7,7 +7,7 @@ using namespace Pinetime::Applications::Screens; DropDownDemo::DropDownDemo(Pinetime::Applications::DisplayApp* app) : Screen(app) { // Create the dropdown object, with many item, and fix its height - ddlist = lv_ddlist_create(lv_scr_act(), nullptr); + ddlist = lv_ddlist_create(lv_scr_act()); lv_ddlist_set_options(ddlist, "Apple\n" "Banana\n" @@ -23,7 +23,7 @@ DropDownDemo::DropDownDemo(Pinetime::Applications::DisplayApp* app) : Screen(app lv_ddlist_set_fix_width(ddlist, 150); lv_ddlist_set_draw_arrow(ddlist, true); lv_ddlist_set_fix_height(ddlist, 150); - lv_obj_align(ddlist, nullptr, LV_ALIGN_IN_TOP_MID, 0, 20); + lv_obj_align(ddlist, LV_ALIGN_TOP_MID, 0, 20); } DropDownDemo::~DropDownDemo() { diff --git a/src/displayapp/screens/FirmwareUpdate.cpp b/src/displayapp/screens/FirmwareUpdate.cpp index 79bda0ba84..38d91099c1 100644 --- a/src/displayapp/screens/FirmwareUpdate.cpp +++ b/src/displayapp/screens/FirmwareUpdate.cpp @@ -8,34 +8,32 @@ using namespace Pinetime::Applications::Screens; FirmwareUpdate::FirmwareUpdate(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Ble& bleController) : Screen(app), bleController {bleController} { - lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text_static(backgroundLabel, ""); - titleLabel = lv_label_create(lv_scr_act(), nullptr); + titleLabel = lv_label_create(lv_scr_act()); lv_label_set_text(titleLabel, "Firmware update"); - lv_obj_set_auto_realign(titleLabel, true); - lv_obj_align(titleLabel, nullptr, LV_ALIGN_IN_TOP_MID, 0, 50); + lv_obj_align(titleLabel, LV_ALIGN_TOP_MID, 0, 50); - bar1 = lv_bar_create(lv_scr_act(), nullptr); + bar1 = lv_bar_create(lv_scr_act()); lv_obj_set_size(bar1, 200, 30); - lv_obj_align(bar1, nullptr, LV_ALIGN_CENTER, 0, 0); - lv_bar_set_anim_time(bar1, 10); + lv_obj_align(bar1, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_style_anim_time(bar1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); lv_bar_set_range(bar1, 0, 100); lv_bar_set_value(bar1, 0, LV_ANIM_OFF); - percentLabel = lv_label_create(lv_scr_act(), nullptr); + percentLabel = lv_label_create(bar1); lv_label_set_text(percentLabel, "Waiting..."); - lv_obj_set_auto_realign(percentLabel, true); - lv_obj_align(percentLabel, bar1, LV_ALIGN_OUT_TOP_MID, 0, 60); - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + lv_obj_align(percentLabel, LV_ALIGN_OUT_TOP_MID, 0, 60); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); startTime = xTaskGetTickCount(); } FirmwareUpdate::~FirmwareUpdate() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_obj_clean(lv_scr_act()); } diff --git a/src/displayapp/screens/FirmwareUpdate.h b/src/displayapp/screens/FirmwareUpdate.h index 8fc86d8c69..fa4e57bf7a 100644 --- a/src/displayapp/screens/FirmwareUpdate.h +++ b/src/displayapp/screens/FirmwareUpdate.h @@ -1,7 +1,7 @@ #pragma once #include "Screen.h" -#include +#include #include "FreeRTOS.h" namespace Pinetime { @@ -36,7 +36,7 @@ namespace Pinetime { void UpdateError(); - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; TickType_t startTime; }; } diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp index eef8f919c8..89aa0f6d59 100644 --- a/src/displayapp/screens/FirmwareValidation.cpp +++ b/src/displayapp/screens/FirmwareValidation.cpp @@ -7,29 +7,29 @@ using namespace Pinetime::Applications::Screens; namespace { - static void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) { - FirmwareValidation* screen = static_cast(obj->user_data); - screen->OnButtonEvent(obj, event); + static void ButtonEventHandler(lv_event_t* event) { + FirmwareValidation* screen = static_cast(lv_event_get_user_data(event)); + screen->OnButtonEvent(lv_event_get_target(event), event); } } FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::FirmwareValidator& validator) : Screen {app}, validator {validator} { - labelVersion = lv_label_create(lv_scr_act(), nullptr); + labelVersion = lv_label_create(lv_scr_act()); lv_label_set_text_fmt(labelVersion, - "Version : %d.%d.%d\n" + "Version : %u.%u.%u\n" "ShortRef : %s", Version::Major(), Version::Minor(), Version::Patch(), Version::GitCommitHash()); - lv_obj_align(labelVersion, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); + lv_obj_align(labelVersion, LV_ALIGN_TOP_LEFT, 0, 0); - labelIsValidated = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(labelIsValidated, labelVersion, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); + labelIsValidated = lv_label_create(labelVersion); + lv_obj_align(labelIsValidated, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); lv_label_set_recolor(labelIsValidated, true); - lv_label_set_long_mode(labelIsValidated, LV_LABEL_LONG_BREAK); + lv_label_set_long_mode(labelIsValidated, LV_LABEL_LONG_WRAP); lv_obj_set_width(labelIsValidated, 240); if (validator.IsValidated()) @@ -37,24 +37,24 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app, else { lv_label_set_text(labelIsValidated, "Please #00ff00 Validate# this version or\n#ff0000 Reset# to rollback to the previous version."); - buttonValidate = lv_btn_create(lv_scr_act(), nullptr); + buttonValidate = lv_btn_create(lv_scr_act()); buttonValidate->user_data = this; lv_obj_set_size(buttonValidate, 115, 50); - lv_obj_align(buttonValidate, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); - lv_obj_set_event_cb(buttonValidate, ButtonEventHandler); - lv_obj_set_style_local_bg_color(buttonValidate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x009900)); + lv_obj_align(buttonValidate, LV_ALIGN_BOTTOM_LEFT, 0, 0); + lv_obj_add_event_cb(buttonValidate, ButtonEventHandler, LV_EVENT_ALL, buttonValidate->user_data); + lv_obj_set_style_bg_color(buttonValidate, lv_color_hex(0x009900), LV_PART_MAIN | LV_STATE_DEFAULT); - labelButtonValidate = lv_label_create(buttonValidate, nullptr); + labelButtonValidate = lv_label_create(buttonValidate); lv_label_set_text_static(labelButtonValidate, "Validate"); - buttonReset = lv_btn_create(lv_scr_act(), nullptr); + buttonReset = lv_btn_create(lv_scr_act()); buttonReset->user_data = this; lv_obj_set_size(buttonReset, 115, 50); - lv_obj_align(buttonReset, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); - lv_obj_set_style_local_bg_color(buttonReset, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x990000)); - lv_obj_set_event_cb(buttonReset, ButtonEventHandler); + lv_obj_align(buttonReset, LV_ALIGN_BOTTOM_RIGHT, 0, 0); + lv_obj_set_style_bg_color(buttonReset, lv_color_hex(0x990000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_add_event_cb(buttonReset, ButtonEventHandler, LV_EVENT_ALL, buttonReset->user_data); - labelButtonReset = lv_label_create(buttonReset, nullptr); + labelButtonReset = lv_label_create(buttonReset); lv_label_set_text_static(labelButtonReset, "Reset"); } } @@ -63,11 +63,11 @@ FirmwareValidation::~FirmwareValidation() { lv_obj_clean(lv_scr_act()); } -void FirmwareValidation::OnButtonEvent(lv_obj_t* object, lv_event_t event) { - if (object == buttonValidate && event == LV_EVENT_CLICKED) { +void FirmwareValidation::OnButtonEvent(lv_obj_t* object, lv_event_t* event) { + if (object == buttonValidate && lv_event_get_code(event) == LV_EVENT_CLICKED) { validator.Validate(); running = false; - } else if (object == buttonReset && event == LV_EVENT_CLICKED) { + } else if (object == buttonReset && lv_event_get_code(event) == LV_EVENT_CLICKED) { validator.Reset(); } } diff --git a/src/displayapp/screens/FirmwareValidation.h b/src/displayapp/screens/FirmwareValidation.h index bfdb096de0..92c16870ec 100644 --- a/src/displayapp/screens/FirmwareValidation.h +++ b/src/displayapp/screens/FirmwareValidation.h @@ -1,7 +1,7 @@ #pragma once #include "Screen.h" -#include +#include namespace Pinetime { namespace Controllers { @@ -16,7 +16,7 @@ namespace Pinetime { FirmwareValidation(DisplayApp* app, Pinetime::Controllers::FirmwareValidator& validator); ~FirmwareValidation() override; - void OnButtonEvent(lv_obj_t* object, lv_event_t event); + void OnButtonEvent(lv_obj_t* object, lv_event_t* event); private: Pinetime::Controllers::FirmwareValidator& validator; diff --git a/src/displayapp/screens/FlashLight.cpp b/src/displayapp/screens/FlashLight.cpp index 4bc5b558c2..3cfc3ae802 100644 --- a/src/displayapp/screens/FlashLight.cpp +++ b/src/displayapp/screens/FlashLight.cpp @@ -5,9 +5,9 @@ using namespace Pinetime::Applications::Screens; namespace { - static void event_handler(lv_obj_t* obj, lv_event_t event) { - FlashLight* screen = static_cast(obj->user_data); - screen->OnClickEvent(obj, event); + static void event_handler(lv_event_t* event) { + FlashLight* screen = static_cast(lv_event_get_user_data(event)); + screen->OnClickEvent(lv_event_get_target(event), event); } } @@ -22,44 +22,44 @@ FlashLight::FlashLight(Pinetime::Applications::DisplayApp* app, brightness.Backup(); brightness.Set(Controllers::BrightnessController::Levels::High); // Set the background - lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF)); + lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); - flashLight = lv_label_create(lv_scr_act(), NULL); - lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_set_style_local_text_font(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + flashLight = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_color(flashLight, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_font(flashLight, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(flashLight, Symbols::highlight); - lv_obj_align(flashLight, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(flashLight, LV_ALIGN_CENTER, 0, 0); - backgroundAction = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(backgroundAction, LV_LABEL_LONG_CROP); + backgroundAction = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(backgroundAction, LV_LABEL_LONG_CLIP); lv_obj_set_size(backgroundAction, 240, 240); lv_obj_set_pos(backgroundAction, 0, 0); lv_label_set_text(backgroundAction, ""); - lv_obj_set_click(backgroundAction, true); + lv_obj_add_flag(backgroundAction, LV_OBJ_FLAG_CLICKABLE); backgroundAction->user_data = this; - lv_obj_set_event_cb(backgroundAction, event_handler); + lv_obj_add_event_cb(backgroundAction, event_handler, LV_EVENT_ALL, backgroundAction->user_data); systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping); } FlashLight::~FlashLight() { lv_obj_clean(lv_scr_act()); - lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); brightness.Restore(); systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping); } -void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t event) { +void FlashLight::OnClickEvent(lv_obj_t* obj, lv_event_t* event) { if (obj == backgroundAction) { - if (event == LV_EVENT_CLICKED) { + if (lv_event_get_code(event) == LV_EVENT_CLICKED) { isOn = !isOn; if (isOn) { - lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF)); - lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(flashLight, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); } else { - lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_set_style_local_text_color(flashLight, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFFFFFF)); + lv_obj_set_style_bg_color(lv_scr_act(), lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(flashLight, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT); } } } diff --git a/src/displayapp/screens/FlashLight.h b/src/displayapp/screens/FlashLight.h index 7f5ca6c5dc..a2ba7c9802 100644 --- a/src/displayapp/screens/FlashLight.h +++ b/src/displayapp/screens/FlashLight.h @@ -17,7 +17,7 @@ namespace Pinetime { ~FlashLight() override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; - void OnClickEvent(lv_obj_t* obj, lv_event_t event); + void OnClickEvent(lv_obj_t* obj, lv_event_t* event); private: Pinetime::System::SystemTask& systemTask; diff --git a/src/displayapp/screens/HeartRate.cpp b/src/displayapp/screens/HeartRate.cpp index b6ece27f7a..850cbb0126 100644 --- a/src/displayapp/screens/HeartRate.cpp +++ b/src/displayapp/screens/HeartRate.cpp @@ -21,8 +21,8 @@ namespace { return ""; } - static void btnStartStopEventHandler(lv_obj_t* obj, lv_event_t event) { - HeartRate* screen = static_cast(obj->user_data); + static void btnStartStopEventHandler(lv_event_t* event) { + HeartRate* screen = static_cast(lv_event_get_user_data(event)); screen->OnStartStopEvent(event); } } @@ -32,44 +32,44 @@ HeartRate::HeartRate(Pinetime::Applications::DisplayApp* app, System::SystemTask& systemTask) : Screen(app), heartRateController {heartRateController}, systemTask {systemTask} { bool isHrRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; - label_hr = lv_label_create(lv_scr_act(), nullptr); + label_hr = lv_label_create(lv_scr_act()); - lv_obj_set_style_local_text_font(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); + lv_obj_set_style_text_font(label_hr, &jetbrains_mono_76, LV_PART_MAIN | LV_STATE_DEFAULT); if (isHrRunning) - lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); + lv_obj_set_style_text_color(label_hr, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_DEFAULT); else - lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_obj_set_style_text_color(label_hr, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(label_hr, "000"); - lv_obj_align(label_hr, nullptr, LV_ALIGN_CENTER, 0, -40); + lv_obj_align(label_hr, LV_ALIGN_CENTER, 0, -40); - label_bpm = lv_label_create(lv_scr_act(), nullptr); + label_bpm = lv_label_create(lv_scr_act()); lv_label_set_text(label_bpm, "Heart rate BPM"); - lv_obj_align(label_bpm, label_hr, LV_ALIGN_OUT_TOP_MID, 0, -20); + lv_obj_align_to(label_bpm, label_hr, LV_ALIGN_OUT_TOP_MID, 0, -20); - label_status = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(label_status, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222)); + label_status = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_color(label_status, lv_color_hex(0x222222), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(label_status, ToString(Pinetime::Controllers::HeartRateController::States::NotEnoughData)); - lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); + lv_obj_align_to(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); - btn_startStop = lv_btn_create(lv_scr_act(), nullptr); + btn_startStop = lv_btn_create(lv_scr_act()); btn_startStop->user_data = this; lv_obj_set_height(btn_startStop, 50); - lv_obj_set_event_cb(btn_startStop, btnStartStopEventHandler); - lv_obj_align(btn_startStop, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, 0); + lv_obj_add_event_cb(btn_startStop, btnStartStopEventHandler, LV_EVENT_ALL, btn_startStop->user_data); + lv_obj_align(btn_startStop, LV_ALIGN_BOTTOM_MID, 0, 0); - label_startStop = lv_label_create(btn_startStop, nullptr); + label_startStop = lv_label_create(btn_startStop); UpdateStartStopButton(isHrRunning); if (isHrRunning) systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping); - taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, 100, this); } HeartRate::~HeartRate() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_obj_clean(lv_scr_act()); systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping); } @@ -88,21 +88,21 @@ void HeartRate::Refresh() { } lv_label_set_text(label_status, ToString(state)); - lv_obj_align(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); + lv_obj_align_to(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); } -void HeartRate::OnStartStopEvent(lv_event_t event) { - if (event == LV_EVENT_CLICKED) { +void HeartRate::OnStartStopEvent(lv_event_t* event) { + if (lv_event_get_code(event) == LV_EVENT_CLICKED) { if (heartRateController.State() == Controllers::HeartRateController::States::Stopped) { heartRateController.Start(); UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped); systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping); - lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); + lv_obj_set_style_text_color(label_hr, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_DEFAULT); } else { heartRateController.Stop(); UpdateStartStopButton(heartRateController.State() != Controllers::HeartRateController::States::Stopped); systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping); - lv_obj_set_style_local_text_color(label_hr, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_obj_set_style_text_color(label_hr, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); } } } diff --git a/src/displayapp/screens/HeartRate.h b/src/displayapp/screens/HeartRate.h index 7f7d3ad3f0..4775203e62 100644 --- a/src/displayapp/screens/HeartRate.h +++ b/src/displayapp/screens/HeartRate.h @@ -5,8 +5,8 @@ #include "Screen.h" #include #include "systemtask/SystemTask.h" -#include -#include +#include +#include namespace Pinetime { namespace Controllers { @@ -22,7 +22,7 @@ namespace Pinetime { void Refresh() override; - void OnStartStopEvent(lv_event_t event); + void OnStartStopEvent(lv_event_t* event); private: Controllers::HeartRateController& heartRateController; @@ -34,7 +34,7 @@ namespace Pinetime { lv_obj_t* btn_startStop; lv_obj_t* label_startStop; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } } diff --git a/src/displayapp/screens/InfiniPaint.cpp b/src/displayapp/screens/InfiniPaint.cpp index 85a5e826fa..57e81d9cb0 100644 --- a/src/displayapp/screens/InfiniPaint.cpp +++ b/src/displayapp/screens/InfiniPaint.cpp @@ -17,28 +17,28 @@ bool InfiniPaint::OnTouchEvent(Pinetime::Applications::TouchEvents event) { case Pinetime::Applications::TouchEvents::LongTap: switch (color) { case 0: - selectColor = LV_COLOR_MAGENTA; + selectColor = lv_color_hex(0xFF00FF); break; case 1: - selectColor = LV_COLOR_GREEN; + selectColor = lv_palette_main(LV_PALETTE_GREEN); break; case 2: - selectColor = LV_COLOR_WHITE; + selectColor = lv_color_white(); break; case 3: - selectColor = LV_COLOR_RED; + selectColor = lv_palette_main(LV_PALETTE_RED); break; case 4: - selectColor = LV_COLOR_CYAN; + selectColor = lv_palette_main(LV_PALETTE_CYAN); break; case 5: - selectColor = LV_COLOR_YELLOW; + selectColor = lv_palette_main(LV_PALETTE_YELLOW); break; case 6: - selectColor = LV_COLOR_BLUE; + selectColor = lv_palette_main(LV_PALETTE_BLUE); break; case 7: - selectColor = LV_COLOR_BLACK; + selectColor = lv_color_black(); break; default: diff --git a/src/displayapp/screens/InfiniPaint.h b/src/displayapp/screens/InfiniPaint.h index 0a70e03358..786b8d5048 100644 --- a/src/displayapp/screens/InfiniPaint.h +++ b/src/displayapp/screens/InfiniPaint.h @@ -27,7 +27,7 @@ namespace Pinetime { static constexpr uint16_t height = 10; static constexpr uint16_t bufferSize = width * height; lv_color_t b[bufferSize]; - lv_color_t selectColor = LV_COLOR_WHITE; + lv_color_t selectColor = lv_color_white(); uint8_t color = 2; }; } diff --git a/src/displayapp/screens/Label.cpp b/src/displayapp/screens/Label.cpp index 1761a7b5ec..5cb9ac6665 100644 --- a/src/displayapp/screens/Label.cpp +++ b/src/displayapp/screens/Label.cpp @@ -11,10 +11,10 @@ Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::Displ pageIndicatorBasePoints[1].x = LV_HOR_RES - 1; pageIndicatorBasePoints[1].y = LV_VER_RES; - pageIndicatorBase = lv_line_create(lv_scr_act(), NULL); - lv_obj_set_style_local_line_width(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_line_color(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); - lv_obj_set_style_local_line_rounded(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true); + pageIndicatorBase = lv_line_create(lv_scr_act()); + lv_obj_set_style_line_width(pageIndicatorBase, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_color(pageIndicatorBase, lv_color_hex(0x111111), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_rounded(pageIndicatorBase, true, LV_PART_MAIN | LV_STATE_DEFAULT); lv_line_set_points(pageIndicatorBase, pageIndicatorBasePoints, 2); uint16_t indicatorSize = LV_VER_RES / numScreens; @@ -25,10 +25,10 @@ Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::Displ pageIndicatorPoints[1].x = LV_HOR_RES - 1; pageIndicatorPoints[1].y = indicatorPos + indicatorSize; - pageIndicator = lv_line_create(lv_scr_act(), NULL); - lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); - lv_obj_set_style_local_line_rounded(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true); + pageIndicator = lv_line_create(lv_scr_act()); + lv_obj_set_style_line_width(pageIndicator, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_color(pageIndicator, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_rounded(pageIndicator, true, LV_PART_MAIN | LV_STATE_DEFAULT); lv_line_set_points(pageIndicator, pageIndicatorPoints, 2); } } diff --git a/src/displayapp/screens/List.cpp b/src/displayapp/screens/List.cpp index 064b47a6c1..7fad1eb860 100644 --- a/src/displayapp/screens/List.cpp +++ b/src/displayapp/screens/List.cpp @@ -5,9 +5,9 @@ using namespace Pinetime::Applications::Screens; namespace { - static void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) { - List* screen = static_cast(obj->user_data); - screen->OnButtonEvent(obj, event); + static void ButtonEventHandler(lv_event_t* event) { + List* screen = static_cast(lv_event_get_user_data(event)); + screen->OnButtonEvent(lv_event_get_target(event), event); } } @@ -20,7 +20,7 @@ List::List(uint8_t screenID, : Screen(app), settingsController {settingsController} { // Set the background to Black - lv_obj_set_style_local_bg_color(lv_scr_act(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(0, 0, 0)); + lv_obj_set_style_bg_color(lv_scr_act(), lv_color_make(0, 0, 0), LV_PART_MAIN | LV_STATE_DEFAULT); settingsController.SetSettingsMenu(screenID); @@ -30,9 +30,9 @@ List::List(uint8_t screenID, pageIndicatorBasePoints[1].x = LV_HOR_RES - 1; pageIndicatorBasePoints[1].y = LV_VER_RES; - pageIndicatorBase = lv_line_create(lv_scr_act(), NULL); - lv_obj_set_style_local_line_width(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_line_color(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); + pageIndicatorBase = lv_line_create(lv_scr_act()); + lv_obj_set_style_line_width(pageIndicatorBase, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_color(pageIndicatorBase, lv_color_hex(0x111111), LV_PART_MAIN | LV_STATE_DEFAULT); lv_line_set_points(pageIndicatorBase, pageIndicatorBasePoints, 2); const uint16_t indicatorSize = LV_VER_RES / numScreens; @@ -43,22 +43,25 @@ List::List(uint8_t screenID, pageIndicatorPoints[1].x = LV_HOR_RES - 1; pageIndicatorPoints[1].y = indicatorPos + indicatorSize; - pageIndicator = lv_line_create(lv_scr_act(), NULL); - lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + pageIndicator = lv_line_create(lv_scr_act()); + lv_obj_set_style_line_width(pageIndicator, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_color(pageIndicator, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); lv_line_set_points(pageIndicator, pageIndicatorPoints, 2); } - lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr); + lv_obj_t* container1 = lv_obj_create(lv_scr_act()); - lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 4); - lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_row(container1, 4, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_column(container1, 4, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 0, 0); lv_obj_set_width(container1, LV_HOR_RES - 8); lv_obj_set_height(container1, LV_VER_RES); - lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); + lv_obj_set_layout(container1, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START); lv_obj_t* labelBt; lv_obj_t* labelBtIco; @@ -67,28 +70,30 @@ List::List(uint8_t screenID, apps[i] = applications[i].application; if (applications[i].application != Apps::None) { - itemApps[i] = lv_btn_create(container1, nullptr); - lv_obj_set_style_local_bg_opa(itemApps[i], LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_20); - lv_obj_set_style_local_radius(itemApps[i], LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 57); - lv_obj_set_style_local_bg_color(itemApps[i], LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_AQUA); + itemApps[i] = lv_btn_create(container1); + lv_obj_set_style_bg_opa(itemApps[i], LV_OPA_20, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(itemApps[i], 57, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(itemApps[i], lv_color_hex(0x00FFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_width(itemApps[i], LV_HOR_RES - 8); lv_obj_set_height(itemApps[i], 57); - lv_obj_set_event_cb(itemApps[i], ButtonEventHandler); - lv_btn_set_layout(itemApps[i], LV_LAYOUT_ROW_MID); + lv_obj_add_event_cb(itemApps[i], ButtonEventHandler, LV_EVENT_ALL, itemApps[i]->user_data); + lv_obj_set_layout(itemApps[i], LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(itemApps[i], LV_FLEX_FLOW_ROW); + lv_obj_set_flex_align(itemApps[i], LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START); itemApps[i]->user_data = this; - labelBtIco = lv_label_create(itemApps[i], nullptr); - lv_obj_set_style_local_text_color(labelBtIco, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW); + labelBtIco = lv_label_create(itemApps[i]); + lv_obj_set_style_text_color(labelBtIco, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(labelBtIco, applications[i].icon); - labelBt = lv_label_create(itemApps[i], nullptr); + labelBt = lv_label_create(itemApps[i]); lv_label_set_text_fmt(labelBt, " %s", applications[i].name); } } - lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); lv_obj_set_size(backgroundLabel, LV_HOR_RES, LV_VER_RES); lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text_static(backgroundLabel, ""); @@ -98,8 +103,8 @@ List::~List() { lv_obj_clean(lv_scr_act()); } -void List::OnButtonEvent(lv_obj_t* object, lv_event_t event) { - if (event == LV_EVENT_CLICKED) { +void List::OnButtonEvent(lv_obj_t* object, lv_event_t* event) { + if (lv_event_get_code(event) == LV_EVENT_CLICKED) { for (int i = 0; i < MAXLISTITEMS; i++) { if (apps[i] != Apps::None && object == itemApps[i]) { app->StartApp(apps[i], DisplayApp::FullRefreshDirections::Up); diff --git a/src/displayapp/screens/List.h b/src/displayapp/screens/List.h index d9f61f2910..2702d9f20f 100644 --- a/src/displayapp/screens/List.h +++ b/src/displayapp/screens/List.h @@ -27,7 +27,7 @@ namespace Pinetime { std::array& applications); ~List() override; - void OnButtonEvent(lv_obj_t* object, lv_event_t event); + void OnButtonEvent(lv_obj_t* object, lv_event_t* event); private: Controllers::Settings& settingsController; diff --git a/src/displayapp/screens/Meter.cpp b/src/displayapp/screens/Meter.cpp index 57cde9cf2e..5abbbed0c0 100644 --- a/src/displayapp/screens/Meter.cpp +++ b/src/displayapp/screens/Meter.cpp @@ -7,30 +7,28 @@ using namespace Pinetime::Applications::Screens; Meter::Meter(Pinetime::Applications::DisplayApp* app) : Screen(app) { /*Create a line meter */ - lmeter = lv_linemeter_create(lv_scr_act(), nullptr); - lv_linemeter_set_range(lmeter, 0, 60); /*Set the range*/ - lv_linemeter_set_value(lmeter, value); /*Set the current value*/ - lv_linemeter_set_angle_offset(lmeter, 180); - lv_linemeter_set_scale(lmeter, 360, 60); /*Set the angle and number of lines*/ - - lv_obj_set_style_local_scale_end_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(255, 0, 0)); - lv_obj_set_style_local_scale_grad_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, lv_color_make(160, 0, 0)); - lv_obj_set_style_local_line_width(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, 2); - lv_obj_set_style_local_line_color(lmeter, LV_LINEMETER_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_SILVER); + lmeter = lv_meter_create(lv_scr_act()); + lscale = lv_meter_add_scale(lmeter); + lindicator = lv_meter_add_needle_line(lmeter, lscale, 2, lv_color_white(), 0); + lv_meter_set_scale_ticks(lmeter, lscale, 60, 2, 5, lv_color_white()); + lv_meter_set_scale_range(lmeter, lscale, 0, 60, 360, 180); /*Set the range*/ + lv_meter_set_indicator_value(lmeter, lindicator, value); /*Set the current value*/ + + lv_meter_add_scale_lines(lmeter, lscale, lv_palette_lighten(LV_PALETTE_GREY, 1), lv_color_make(160, 0, 0), true, 0); lv_obj_set_size(lmeter, 200, 200); - lv_obj_align(lmeter, nullptr, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(lmeter, LV_ALIGN_CENTER, 0, 0); - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); } Meter::~Meter() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_obj_clean(lv_scr_act()); } void Meter::Refresh() { - lv_linemeter_set_value(lmeter, value++); /*Set the current value*/ + lv_meter_set_indicator_value(lmeter, lindicator, value++); /*Set the current value*/ if (value >= 60) value = 0; } diff --git a/src/displayapp/screens/Meter.h b/src/displayapp/screens/Meter.h index 9b3d1d488a..30536fcf54 100644 --- a/src/displayapp/screens/Meter.h +++ b/src/displayapp/screens/Meter.h @@ -2,8 +2,8 @@ #include #include "Screen.h" -#include -#include +#include +#include namespace Pinetime { namespace Applications { @@ -19,10 +19,12 @@ namespace Pinetime { private: lv_style_t style_lmeter; lv_obj_t* lmeter; + lv_meter_scale_t* lscale; + lv_meter_indicator_t* lindicator; uint32_t value = 0; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } } diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp index 52cb8519b7..3221b3902f 100644 --- a/src/displayapp/screens/Metronome.cpp +++ b/src/displayapp/screens/Metronome.cpp @@ -4,17 +4,17 @@ using namespace Pinetime::Applications::Screens; namespace { - void eventHandler(lv_obj_t* obj, lv_event_t event) { - auto* screen = static_cast(obj->user_data); - screen->OnEvent(obj, event); + void eventHandler(lv_event_t* event) { + auto* screen = static_cast(lv_event_get_user_data(event)); + screen->OnEvent(lv_event_get_target(event), event); } - lv_obj_t* createLabel(const char* name, lv_obj_t* reference, lv_align_t align, lv_font_t* font, uint8_t x, uint8_t y) { - lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, font); - lv_obj_set_style_local_text_color(label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_obj_t* createLabel(const char* name, lv_obj_t* parent, lv_align_t align, const lv_font_t* font, uint8_t x, uint8_t y) { + lv_obj_t* label = lv_label_create(parent); + lv_obj_set_style_text_font(label, font, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(label, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(label, name); - lv_obj_align(label, reference, align, x, y); + lv_obj_align(label, align, x, y); return label; } @@ -23,55 +23,56 @@ namespace { Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask) : Screen(app), motorController {motorController}, systemTask {systemTask} { - bpmArc = lv_arc_create(lv_scr_act(), nullptr); + bpmArc = lv_arc_create(lv_scr_act()); bpmArc->user_data = this; - lv_obj_set_event_cb(bpmArc, eventHandler); + lv_obj_add_event_cb(bpmArc, eventHandler, LV_EVENT_ALL, bpmArc->user_data); lv_arc_set_bg_angles(bpmArc, 0, 270); lv_arc_set_rotation(bpmArc, 135); lv_arc_set_range(bpmArc, 40, 220); lv_arc_set_value(bpmArc, bpm); lv_obj_set_size(bpmArc, 210, 210); - lv_arc_set_adjustable(bpmArc, true); - lv_obj_align(bpmArc, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 0); + lv_obj_add_flag(bpmArc, LV_OBJ_FLAG_CLICKABLE); + lv_obj_align(bpmArc, LV_ALIGN_TOP_MID, 0, 0); - bpmValue = createLabel("120", bpmArc, LV_ALIGN_IN_TOP_MID, &jetbrains_mono_76, 0, 55); + bpmValue = createLabel("120", bpmArc, LV_ALIGN_TOP_MID, &jetbrains_mono_76, 0, 55); createLabel("bpm", bpmValue, LV_ALIGN_OUT_BOTTOM_MID, &jetbrains_mono_bold_20, 0, 0); - bpmTap = lv_btn_create(lv_scr_act(), nullptr); + bpmTap = lv_btn_create(lv_scr_act()); bpmTap->user_data = this; - lv_obj_set_event_cb(bpmTap, eventHandler); - lv_obj_set_style_local_bg_opa(bpmTap, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); + lv_obj_add_event_cb(bpmTap, eventHandler, LV_EVENT_ALL, bpmTap->user_data); + lv_obj_set_style_bg_opa(bpmTap, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_height(bpmTap, 80); - lv_obj_align(bpmTap, bpmValue, LV_ALIGN_IN_TOP_MID, 0, 0); + lv_obj_align_to(bpmTap, bpmValue, LV_ALIGN_TOP_MID, 0, 0); - bpbDropdown = lv_dropdown_create(lv_scr_act(), nullptr); + bpbDropdown = lv_dropdown_create(lv_scr_act()); bpbDropdown->user_data = this; - lv_obj_set_event_cb(bpbDropdown, eventHandler); - lv_obj_set_style_local_pad_left(bpbDropdown, LV_DROPDOWN_PART_MAIN, LV_STATE_DEFAULT, 20); - lv_obj_set_style_local_pad_left(bpbDropdown, LV_DROPDOWN_PART_LIST, LV_STATE_DEFAULT, 20); + lv_obj_add_event_cb(bpbDropdown, eventHandler, LV_EVENT_ALL, bpbDropdown->user_data); + lv_obj_set_style_pad_left(bpbDropdown, 20, LV_PART_MAIN | LV_STATE_DEFAULT); + // The styling for the list itself is set in the event handler, as the "list" object does not exist until it is openened. + // See https://docs.lvgl.io/8.0/widgets/core/dropdown.html#parts-and-styles + // lv_obj_set_style_pad_left(bpbDropdown, 20, LV_DROPDOWN_PART_LIST | LV_STATE_DEFAULT); lv_obj_set_size(bpbDropdown, 115, 50); - lv_obj_align(bpbDropdown, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); + lv_obj_align(bpbDropdown, LV_ALIGN_BOTTOM_LEFT, 0, 0); lv_dropdown_set_options(bpbDropdown, "1\n2\n3\n4\n5\n6\n7\n8\n9"); lv_dropdown_set_selected(bpbDropdown, bpb - 1); - lv_dropdown_set_show_selected(bpbDropdown, false); lv_dropdown_set_text(bpbDropdown, ""); - currentBpbText = lv_label_create(bpbDropdown, nullptr); + currentBpbText = lv_label_create(bpbDropdown); lv_label_set_text_fmt(currentBpbText, "%d bpb", bpb); - lv_obj_align(currentBpbText, bpbDropdown, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(currentBpbText, LV_ALIGN_CENTER, 0, 0); - playPause = lv_btn_create(lv_scr_act(), nullptr); + playPause = lv_btn_create(lv_scr_act()); playPause->user_data = this; - lv_obj_set_event_cb(playPause, eventHandler); + lv_obj_add_event_cb(playPause, eventHandler, LV_EVENT_ALL, playPause->user_data); lv_obj_set_size(playPause, 115, 50); - lv_obj_align(playPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); - lv_obj_set_style_local_value_str(playPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Symbols::play); + lv_obj_align(playPause, LV_ALIGN_BOTTOM_RIGHT, 0, 0); + txtPlayPause = createLabel(LV_SYMBOL_PLAY, playPause, LV_ALIGN_CENTER, LV_FONT_DEFAULT, 0, 0); - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); } Metronome::~Metronome() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); systemTask.PushMessage(System::Messages::EnableSleeping); lv_obj_clean(lv_scr_act()); } @@ -91,16 +92,19 @@ void Metronome::Refresh() { } } -void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) { - switch (event) { +void Metronome::OnEvent(lv_obj_t* obj, lv_event_t* event) { + switch (lv_event_get_code(event)) { case LV_EVENT_VALUE_CHANGED: { if (obj == bpmArc) { bpm = lv_arc_get_value(bpmArc); lv_label_set_text_fmt(bpmValue, "%03d", bpm); } else if (obj == bpbDropdown) { + lv_obj_t *list = lv_dropdown_get_list(obj); + if(list != NULL) { // The list is open, we can style it now + lv_obj_set_style_pad_left(list, 20, LV_PART_MAIN | LV_STATE_DEFAULT); + } bpb = lv_dropdown_get_selected(obj) + 1; lv_label_set_text_fmt(currentBpbText, "%d bpb", bpb); - lv_obj_realign(currentBpbText); } break; } @@ -120,12 +124,12 @@ void Metronome::OnEvent(lv_obj_t* obj, lv_event_t event) { if (obj == playPause) { metronomeStarted = !metronomeStarted; if (metronomeStarted) { - lv_obj_set_style_local_value_str(playPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Symbols::pause); + lv_label_set_text(txtPlayPause, LV_SYMBOL_PAUSE); systemTask.PushMessage(System::Messages::DisableSleeping); startTime = xTaskGetTickCount(); counter = 1; } else { - lv_obj_set_style_local_value_str(playPause, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Symbols::play); + lv_label_set_text(txtPlayPause, LV_SYMBOL_PLAY); systemTask.PushMessage(System::Messages::EnableSleeping); } } diff --git a/src/displayapp/screens/Metronome.h b/src/displayapp/screens/Metronome.h index f3a84dc825..5b7f4fefa0 100644 --- a/src/displayapp/screens/Metronome.h +++ b/src/displayapp/screens/Metronome.h @@ -12,7 +12,7 @@ namespace Pinetime { Metronome(DisplayApp* app, Controllers::MotorController& motorController, System::SystemTask& systemTask); ~Metronome() override; void Refresh() override; - void OnEvent(lv_obj_t* obj, lv_event_t event); + void OnEvent(lv_obj_t* obj, lv_event_t* event); private: TickType_t startTime = 0; @@ -27,9 +27,9 @@ namespace Pinetime { lv_obj_t *bpmArc, *bpmTap, *bpmValue; lv_obj_t *bpbDropdown, *currentBpbText; - lv_obj_t *playPause; + lv_obj_t *playPause, *txtPlayPause; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } } diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp index 2f1f7c2107..4299c58e05 100644 --- a/src/displayapp/screens/Motion.cpp +++ b/src/displayapp/screens/Motion.cpp @@ -6,49 +6,49 @@ using namespace Pinetime::Applications::Screens; Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionController& motionController) : Screen(app), motionController {motionController} { - chart = lv_chart_create(lv_scr_act(), NULL); + chart = lv_chart_create(lv_scr_act()); lv_obj_set_size(chart, 240, 240); - lv_obj_align(chart, NULL, LV_ALIGN_IN_TOP_MID, 0, 0); + lv_obj_align(chart, LV_ALIGN_TOP_MID, 0, 0); lv_chart_set_type(chart, LV_CHART_TYPE_LINE); /*Show lines and points too*/ // lv_chart_set_series_opa(chart, LV_OPA_70); /*Opacity of the data series*/ // lv_chart_set_series_width(chart, 4); /*Line width and point radious*/ - lv_chart_set_range(chart, -1100, 1100); + lv_chart_set_range(chart, LV_CHART_AXIS_PRIMARY_Y, -1100, 1100); lv_chart_set_update_mode(chart, LV_CHART_UPDATE_MODE_SHIFT); lv_chart_set_point_count(chart, 10); /*Add 3 data series*/ - ser1 = lv_chart_add_series(chart, LV_COLOR_RED); - ser2 = lv_chart_add_series(chart, LV_COLOR_GREEN); - ser3 = lv_chart_add_series(chart, LV_COLOR_YELLOW); + ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_RED), LV_CHART_AXIS_PRIMARY_Y); + ser2 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_GREEN), LV_CHART_AXIS_PRIMARY_Y); + ser3 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_YELLOW), LV_CHART_AXIS_PRIMARY_Y); - lv_chart_init_points(chart, ser1, 0); - lv_chart_init_points(chart, ser2, 0); - lv_chart_init_points(chart, ser3, 0); + lv_chart_set_all_value(chart, ser1, 0); + lv_chart_set_all_value(chart, ser2, 0); + lv_chart_set_all_value(chart, ser3, 0); lv_chart_refresh(chart); /*Required after direct set*/ - label = lv_label_create(lv_scr_act(), NULL); + label = lv_label_create(lv_scr_act()); lv_label_set_text_fmt(label, "X #FF0000 %d# Y #008000 %d# Z #FFFF00 %d#", 0, 0, 0); - lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); - lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); + lv_obj_center(label); + lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 10); lv_label_set_recolor(label, true); - labelStep = lv_label_create(lv_scr_act(), NULL); - lv_obj_align(labelStep, chart, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); + labelStep = lv_label_create(chart); + lv_obj_align(labelStep, LV_ALIGN_BOTTOM_LEFT, 0, 0); lv_label_set_text(labelStep, "Steps ---"); - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); } Motion::~Motion() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_obj_clean(lv_scr_act()); } void Motion::Refresh() { - lv_chart_set_next(chart, ser1, motionController.X()); - lv_chart_set_next(chart, ser2, motionController.Y()); - lv_chart_set_next(chart, ser3, motionController.Z()); + lv_chart_set_next_value(chart, ser1, motionController.X()); + lv_chart_set_next_value(chart, ser2, motionController.Y()); + lv_chart_set_next_value(chart, ser3, motionController.Z()); lv_label_set_text_fmt(labelStep, "Steps %lu", motionController.NbSteps()); @@ -57,5 +57,5 @@ void Motion::Refresh() { motionController.X() / 0x10, motionController.Y() / 0x10, motionController.Z() / 0x10); - lv_obj_align(label, NULL, LV_ALIGN_IN_TOP_MID, 0, 10); + lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 10); } diff --git a/src/displayapp/screens/Motion.h b/src/displayapp/screens/Motion.h index 20a18d02a7..11bb5291b4 100644 --- a/src/displayapp/screens/Motion.h +++ b/src/displayapp/screens/Motion.h @@ -4,8 +4,8 @@ #include #include "Screen.h" #include -#include -#include +#include +#include #include namespace Pinetime { @@ -28,7 +28,7 @@ namespace Pinetime { lv_obj_t* label; lv_obj_t* labelStep; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } } diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp index 47ddb65551..582313e6de 100644 --- a/src/displayapp/screens/Music.cpp +++ b/src/displayapp/screens/Music.cpp @@ -26,9 +26,9 @@ using namespace Pinetime::Applications::Screens; -static void event_handler(lv_obj_t* obj, lv_event_t event) { - Music* screen = static_cast(obj->user_data); - screen->OnObjectEvent(obj, event); +static void event_handler(lv_event_t* event) { + Music* screen = static_cast(lv_event_get_user_data(event)); + screen->OnObjectEvent(lv_event_get_target(event), event); } /** @@ -51,100 +51,100 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus lv_obj_t* label; lv_style_init(&btn_style); - lv_style_set_radius(&btn_style, LV_STATE_DEFAULT, 20); - lv_style_set_bg_color(&btn_style, LV_STATE_DEFAULT, LV_COLOR_AQUA); - lv_style_set_bg_opa(&btn_style, LV_STATE_DEFAULT, LV_OPA_20); + lv_style_set_radius(&btn_style, 20); + lv_style_set_bg_color(&btn_style, lv_color_hex(0x00FFFF)); + lv_style_set_bg_opa(&btn_style, LV_OPA_20); - btnVolDown = lv_btn_create(lv_scr_act(), nullptr); + btnVolDown = lv_btn_create(lv_scr_act()); btnVolDown->user_data = this; - lv_obj_set_event_cb(btnVolDown, event_handler); + lv_obj_add_event_cb(btnVolDown, event_handler, LV_EVENT_ALL, btnVolDown->user_data); lv_obj_set_size(btnVolDown, 76, 76); - lv_obj_align(btnVolDown, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); - lv_obj_add_style(btnVolDown, LV_STATE_DEFAULT, &btn_style); - label = lv_label_create(btnVolDown, nullptr); + lv_obj_align(btnVolDown, LV_ALIGN_BOTTOM_LEFT, 0, 0); + lv_obj_add_style(btnVolDown, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); + label = lv_label_create(btnVolDown); lv_label_set_text(label, Symbols::volumDown); - lv_obj_set_hidden(btnVolDown, true); + lv_obj_add_flag(btnVolDown, LV_OBJ_FLAG_HIDDEN); - btnVolUp = lv_btn_create(lv_scr_act(), nullptr); + btnVolUp = lv_btn_create(lv_scr_act()); btnVolUp->user_data = this; - lv_obj_set_event_cb(btnVolUp, event_handler); + lv_obj_add_event_cb(btnVolUp, event_handler, LV_EVENT_ALL, btnVolUp->user_data); lv_obj_set_size(btnVolUp, 76, 76); - lv_obj_align(btnVolUp, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); - lv_obj_add_style(btnVolUp, LV_STATE_DEFAULT, &btn_style); - label = lv_label_create(btnVolUp, nullptr); + lv_obj_align(btnVolUp, LV_ALIGN_BOTTOM_RIGHT, 0, 0); + lv_obj_add_style(btnVolUp, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); + label = lv_label_create(btnVolUp); lv_label_set_text(label, Symbols::volumUp); - lv_obj_set_hidden(btnVolUp, true); + lv_obj_add_flag(btnVolUp, LV_OBJ_FLAG_HIDDEN); - btnPrev = lv_btn_create(lv_scr_act(), nullptr); + btnPrev = lv_btn_create(lv_scr_act()); btnPrev->user_data = this; - lv_obj_set_event_cb(btnPrev, event_handler); + lv_obj_add_event_cb(btnPrev, event_handler, LV_EVENT_ALL, btnPrev->user_data); lv_obj_set_size(btnPrev, 76, 76); - lv_obj_align(btnPrev, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); - lv_obj_add_style(btnPrev, LV_STATE_DEFAULT, &btn_style); - label = lv_label_create(btnPrev, nullptr); + lv_obj_align(btnPrev, LV_ALIGN_BOTTOM_LEFT, 0, 0); + lv_obj_add_style(btnPrev, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); + label = lv_label_create(btnPrev); lv_label_set_text(label, Symbols::stepBackward); - btnNext = lv_btn_create(lv_scr_act(), nullptr); + btnNext = lv_btn_create(lv_scr_act()); btnNext->user_data = this; - lv_obj_set_event_cb(btnNext, event_handler); + lv_obj_add_event_cb(btnNext, event_handler, LV_EVENT_ALL, btnNext->user_data); lv_obj_set_size(btnNext, 76, 76); - lv_obj_align(btnNext, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); - lv_obj_add_style(btnNext, LV_STATE_DEFAULT, &btn_style); - label = lv_label_create(btnNext, nullptr); + lv_obj_align(btnNext, LV_ALIGN_BOTTOM_RIGHT, 0, 0); + lv_obj_add_style(btnNext, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); + label = lv_label_create(btnNext); lv_label_set_text(label, Symbols::stepForward); - btnPlayPause = lv_btn_create(lv_scr_act(), nullptr); + btnPlayPause = lv_btn_create(lv_scr_act()); btnPlayPause->user_data = this; - lv_obj_set_event_cb(btnPlayPause, event_handler); + lv_obj_add_event_cb(btnPlayPause, event_handler, LV_EVENT_ALL, btnPlayPause->user_data); lv_obj_set_size(btnPlayPause, 76, 76); - lv_obj_align(btnPlayPause, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, 0); - lv_obj_add_style(btnPlayPause, LV_STATE_DEFAULT, &btn_style); - txtPlayPause = lv_label_create(btnPlayPause, nullptr); + lv_obj_align(btnPlayPause, LV_ALIGN_BOTTOM_MID, 0, 0); + lv_obj_add_style(btnPlayPause, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); + txtPlayPause = lv_label_create(btnPlayPause); lv_label_set_text(txtPlayPause, Symbols::play); - txtTrackDuration = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SROLL); - lv_obj_align(txtTrackDuration, nullptr, LV_ALIGN_IN_TOP_LEFT, 12, 20); + txtTrackDuration = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SCROLL); + lv_obj_align(txtTrackDuration, LV_ALIGN_TOP_LEFT, 12, 20); lv_label_set_text(txtTrackDuration, "--:--/--:--"); - lv_label_set_align(txtTrackDuration, LV_ALIGN_IN_LEFT_MID); + lv_obj_set_align(txtTrackDuration, LV_ALIGN_LEFT_MID); lv_obj_set_width(txtTrackDuration, LV_HOR_RES); constexpr uint8_t FONT_HEIGHT = 12; constexpr uint8_t LINE_PAD = 15; constexpr int8_t MIDDLE_OFFSET = -25; - txtArtist = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(txtArtist, LV_LABEL_LONG_SROLL_CIRC); - lv_obj_align(txtArtist, nullptr, LV_ALIGN_IN_LEFT_MID, 12, MIDDLE_OFFSET + 1 * FONT_HEIGHT); - lv_label_set_align(txtArtist, LV_ALIGN_IN_LEFT_MID); + txtArtist = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(txtArtist, LV_LABEL_LONG_SCROLL_CIRCULAR); + lv_obj_align(txtArtist, LV_ALIGN_LEFT_MID, 12, MIDDLE_OFFSET + 1 * FONT_HEIGHT); + lv_obj_set_align(txtArtist, LV_ALIGN_LEFT_MID); lv_obj_set_width(txtArtist, LV_HOR_RES - 12); lv_label_set_text(txtArtist, "Artist Name"); - txtTrack = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(txtTrack, LV_LABEL_LONG_SROLL_CIRC); - lv_obj_align(txtTrack, nullptr, LV_ALIGN_IN_LEFT_MID, 12, MIDDLE_OFFSET + 2 * FONT_HEIGHT + LINE_PAD); + txtTrack = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(txtTrack, LV_LABEL_LONG_SCROLL_CIRCULAR); + lv_obj_align(txtTrack, LV_ALIGN_LEFT_MID, 12, MIDDLE_OFFSET + 2 * FONT_HEIGHT + LINE_PAD); - lv_label_set_align(txtTrack, LV_ALIGN_IN_LEFT_MID); + lv_obj_set_align(txtTrack, LV_ALIGN_LEFT_MID); lv_obj_set_width(txtTrack, LV_HOR_RES - 12); lv_label_set_text(txtTrack, "This is a very long getTrack name"); /** Init animation */ - imgDisc = lv_img_create(lv_scr_act(), nullptr); + imgDisc = lv_img_create(lv_scr_act()); lv_img_set_src_arr(imgDisc, &disc); - lv_obj_align(imgDisc, nullptr, LV_ALIGN_IN_TOP_RIGHT, -15, 15); + lv_obj_align(imgDisc, LV_ALIGN_TOP_RIGHT, -15, 15); - imgDiscAnim = lv_img_create(lv_scr_act(), nullptr); + imgDiscAnim = lv_img_create(lv_scr_act()); lv_img_set_src_arr(imgDiscAnim, &disc_f_1); - lv_obj_align(imgDiscAnim, nullptr, LV_ALIGN_IN_TOP_RIGHT, -15 - 32, 15); + lv_obj_align(imgDiscAnim, LV_ALIGN_TOP_RIGHT, -15 - 32, 15); frameB = false; musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN); - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); } Music::~Music() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_style_reset(&btn_style); lv_obj_clean(lv_scr_act()); } @@ -239,8 +239,8 @@ void Music::UpdateLength() { } } -void Music::OnObjectEvent(lv_obj_t* obj, lv_event_t event) { - if (event == LV_EVENT_CLICKED) { +void Music::OnObjectEvent(lv_obj_t* obj, lv_event_t* event) { + if (lv_event_get_code(event) == LV_EVENT_CLICKED) { if (obj == btnVolDown) { musicService.event(Controllers::MusicService::EVENT_MUSIC_VOLDOWN); } else if (obj == btnVolUp) { @@ -269,19 +269,19 @@ void Music::OnObjectEvent(lv_obj_t* obj, lv_event_t event) { bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) { switch (event) { case TouchEvents::SwipeUp: { - lv_obj_set_hidden(btnVolDown, false); - lv_obj_set_hidden(btnVolUp, false); + lv_obj_clear_flag(btnVolDown, LV_OBJ_FLAG_HIDDEN); + lv_obj_clear_flag(btnVolUp, LV_OBJ_FLAG_HIDDEN); - lv_obj_set_hidden(btnNext, true); - lv_obj_set_hidden(btnPrev, true); + lv_obj_add_flag(btnNext, LV_OBJ_FLAG_HIDDEN); + lv_obj_add_flag(btnPrev, LV_OBJ_FLAG_HIDDEN); return true; } case TouchEvents::SwipeDown: { - lv_obj_set_hidden(btnNext, false); - lv_obj_set_hidden(btnPrev, false); + lv_obj_clear_flag(btnNext, LV_OBJ_FLAG_HIDDEN); + lv_obj_clear_flag(btnPrev, LV_OBJ_FLAG_HIDDEN); - lv_obj_set_hidden(btnVolDown, true); - lv_obj_set_hidden(btnVolUp, true); + lv_obj_add_flag(btnVolDown, LV_OBJ_FLAG_HIDDEN); + lv_obj_add_flag(btnVolUp, LV_OBJ_FLAG_HIDDEN); return true; } case TouchEvents::SwipeLeft: { diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h index 6f2d80a069..ca6acb2e95 100644 --- a/src/displayapp/screens/Music.h +++ b/src/displayapp/screens/Music.h @@ -18,7 +18,7 @@ #pragma once #include -#include +#include #include #include "Screen.h" @@ -37,7 +37,7 @@ namespace Pinetime { void Refresh() override; - void OnObjectEvent(lv_obj_t* obj, lv_event_t event); + void OnObjectEvent(lv_obj_t* obj, lv_event_t* event); private: bool OnTouchEvent(TouchEvents event); @@ -79,7 +79,7 @@ namespace Pinetime { bool playing; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; /** Watchapp */ }; diff --git a/src/displayapp/screens/Navigation.cpp b/src/displayapp/screens/Navigation.cpp index d437cc6d5e..ef41454771 100644 --- a/src/displayapp/screens/Navigation.cpp +++ b/src/displayapp/screens/Navigation.cpp @@ -131,42 +131,42 @@ namespace { Navigation::Navigation(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::NavigationService& nav) : Screen(app), navService(nav) { - imgFlag = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(imgFlag, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_navi_80); - lv_obj_set_style_local_text_color(imgFlag, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN); + imgFlag = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(imgFlag, &lv_font_navi_80, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(imgFlag, lv_color_hex(0x00FFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(imgFlag, iconForName("flag")); - lv_obj_align(imgFlag, nullptr, LV_ALIGN_CENTER, 0, -60); + lv_obj_align(imgFlag, LV_ALIGN_CENTER, 0, -60); - txtNarrative = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(txtNarrative, LV_LABEL_LONG_BREAK); + txtNarrative = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(txtNarrative, LV_LABEL_LONG_WRAP); lv_obj_set_width(txtNarrative, LV_HOR_RES); lv_label_set_text(txtNarrative, "Navigation"); - lv_label_set_align(txtNarrative, LV_LABEL_ALIGN_CENTER); - lv_obj_align(txtNarrative, nullptr, LV_ALIGN_CENTER, 0, 10); + lv_obj_center(txtNarrative); + lv_obj_align(txtNarrative, LV_ALIGN_CENTER, 0, 10); - txtManDist = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(txtManDist, LV_LABEL_LONG_BREAK); - lv_obj_set_style_local_text_color(txtManDist, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); + txtManDist = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(txtManDist, LV_LABEL_LONG_WRAP); + lv_obj_set_style_text_color(txtManDist, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_width(txtManDist, LV_HOR_RES); lv_label_set_text(txtManDist, "--M"); - lv_label_set_align(txtManDist, LV_LABEL_ALIGN_CENTER); - lv_obj_align(txtManDist, nullptr, LV_ALIGN_CENTER, 0, 60); + lv_obj_center(txtManDist); + lv_obj_align(txtManDist, LV_ALIGN_CENTER, 0, 60); // Route Progress - barProgress = lv_bar_create(lv_scr_act(), nullptr); + barProgress = lv_bar_create(lv_scr_act()); lv_obj_set_size(barProgress, 200, 20); - lv_obj_align(barProgress, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, -10); - lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_BG, LV_STATE_DEFAULT, lv_color_hex(0x222222)); - lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE); - lv_bar_set_anim_time(barProgress, 500); + lv_obj_align(barProgress, LV_ALIGN_BOTTOM_MID, 0, -10); + lv_obj_set_style_bg_color(barProgress, lv_color_hex(0x222222), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(barProgress, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_INDICATOR | LV_STATE_DEFAULT); + lv_obj_set_style_anim_time(barProgress, 500, LV_PART_MAIN | LV_STATE_DEFAULT); lv_bar_set_range(barProgress, 0, 100); lv_bar_set_value(barProgress, 0, LV_ANIM_OFF); - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); } Navigation::~Navigation() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_obj_clean(lv_scr_act()); } @@ -190,9 +190,9 @@ void Navigation::Refresh() { progress = navService.getProgress(); lv_bar_set_value(barProgress, progress, LV_ANIM_OFF); if (progress > 90) { - lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED); + lv_obj_set_style_bg_color(barProgress, lv_palette_main(LV_PALETTE_RED), LV_PART_INDICATOR | LV_STATE_DEFAULT); } else { - lv_obj_set_style_local_bg_color(barProgress, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_obj_set_style_bg_color(barProgress, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_INDICATOR | LV_STATE_DEFAULT); } } } diff --git a/src/displayapp/screens/Navigation.h b/src/displayapp/screens/Navigation.h index 48f00a76e2..ce41b40f69 100644 --- a/src/displayapp/screens/Navigation.h +++ b/src/displayapp/screens/Navigation.h @@ -18,7 +18,7 @@ #pragma once #include -#include +#include #include #include "Screen.h" #include @@ -50,7 +50,7 @@ namespace Pinetime { std::string manDist; int progress; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } } diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 4f4758133c..63ca096568 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -5,8 +5,8 @@ #include "Symbols.h" using namespace Pinetime::Applications::Screens; -extern lv_font_t jetbrains_mono_extrabold_compressed; -extern lv_font_t jetbrains_mono_bold_20; +extern const lv_font_t jetbrains_mono_extrabold_compressed; +extern const lv_font_t jetbrains_mono_bold_20; Notifications::Notifications(DisplayApp* app, Pinetime::Controllers::NotificationManager& notificationManager, @@ -41,11 +41,11 @@ Notifications::Notifications(DisplayApp* app, motorController.StartRinging(); } else { motorController.RunForDuration(35); - timeoutLine = lv_line_create(lv_scr_act(), nullptr); + timeoutLine = lv_line_create(lv_scr_act()); - lv_obj_set_style_local_line_width(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_line_color(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_obj_set_style_local_line_rounded(timeoutLine, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, true); + lv_obj_set_style_line_width(timeoutLine, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_color(timeoutLine, lv_color_white(), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_rounded(timeoutLine, true, LV_PART_MAIN | LV_STATE_DEFAULT); lv_line_set_points(timeoutLine, timeoutLinePoints, 2); timeoutTickCountStart = xTaskGetTickCount(); @@ -53,11 +53,11 @@ Notifications::Notifications(DisplayApp* app, } } - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); } Notifications::~Notifications() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); // make sure we stop any vibrations before exiting Controllers::MotorController::StopRinging(); lv_obj_clean(lv_scr_act()); @@ -135,9 +135,9 @@ bool Notifications::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } namespace { - void CallEventHandler(lv_obj_t* obj, lv_event_t event) { - auto* item = static_cast(obj->user_data); - item->OnCallButtonEvent(obj, event); + void CallEventHandler(lv_event_t* event) { + auto* item = static_cast(lv_event_get_user_data(event)); + item->OnCallButtonEvent(lv_event_get_target(event), event); } } @@ -149,25 +149,27 @@ Notifications::NotificationItem::NotificationItem(const char* title, Modes mode, Pinetime::Controllers::AlertNotificationService& alertNotificationService) : mode {mode}, alertNotificationService {alertNotificationService} { - lv_obj_t* container1 = lv_cont_create(lv_scr_act(), NULL); + lv_obj_t* container1 = lv_obj_create(lv_scr_act()); - lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x222222)); - lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10); - lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); - lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_style_bg_color(container1, lv_color_hex(0x222222), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 0, 50); lv_obj_set_size(container1, LV_HOR_RES, 190); - lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); - lv_cont_set_fit(container1, LV_FIT_NONE); + lv_obj_set_layout(container1, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); - lv_obj_t* alert_count = lv_label_create(lv_scr_act(), nullptr); + lv_obj_t* alert_count = lv_label_create(lv_scr_act()); lv_label_set_text_fmt(alert_count, "%i/%i", notifNr, notifNb); - lv_obj_align(alert_count, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 16); + lv_obj_align(alert_count, LV_ALIGN_TOP_RIGHT, 0, 16); - lv_obj_t* alert_type = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(alert_type, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x888888)); + lv_obj_t* alert_type = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_color(alert_type, lv_color_hex(0x888888), LV_PART_MAIN | LV_STATE_DEFAULT); if (title == nullptr) title = "Notification"; char* pchar; @@ -177,71 +179,71 @@ Notifications::NotificationItem::NotificationItem(const char* title, pchar = strchr(pchar + 1, '\n'); } lv_label_set_text(alert_type, title); - lv_label_set_long_mode(alert_type, LV_LABEL_LONG_SROLL_CIRC); + lv_label_set_long_mode(alert_type, LV_LABEL_LONG_SCROLL_CIRCULAR); lv_obj_set_width(alert_type, 180); - lv_obj_align(alert_type, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 16); + lv_obj_align(alert_type, LV_ALIGN_TOP_LEFT, 0, 16); ///////// switch (category) { default: { - lv_obj_t* alert_subject = lv_label_create(container1, nullptr); - lv_obj_set_style_local_text_color(alert_subject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); - lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_BREAK); + lv_obj_t* alert_subject = lv_label_create(container1); + lv_obj_set_style_text_color(alert_subject, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_WRAP); lv_obj_set_width(alert_subject, LV_HOR_RES - 20); lv_label_set_text(alert_subject, msg); } break; case Controllers::NotificationManager::Categories::IncomingCall: { lv_obj_set_height(container1, 108); - lv_obj_t* alert_subject = lv_label_create(container1, nullptr); - lv_obj_set_style_local_text_color(alert_subject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); - lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_BREAK); + lv_obj_t* alert_subject = lv_label_create(container1); + lv_obj_set_style_text_color(alert_subject, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_label_set_long_mode(alert_subject, LV_LABEL_LONG_WRAP); lv_obj_set_width(alert_subject, LV_HOR_RES - 20); lv_label_set_text(alert_subject, "Incoming call from"); - lv_obj_t* alert_caller = lv_label_create(container1, nullptr); - lv_obj_align(alert_caller, alert_subject, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); - lv_label_set_long_mode(alert_caller, LV_LABEL_LONG_BREAK); + lv_obj_t* alert_caller = lv_label_create(container1); + lv_obj_align_to(alert_caller, alert_subject, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); + lv_label_set_long_mode(alert_caller, LV_LABEL_LONG_WRAP); lv_obj_set_width(alert_caller, LV_HOR_RES - 20); lv_label_set_text(alert_caller, msg); - bt_accept = lv_btn_create(lv_scr_act(), nullptr); + bt_accept = lv_btn_create(lv_scr_act()); bt_accept->user_data = this; - lv_obj_set_event_cb(bt_accept, CallEventHandler); + lv_obj_add_event_cb(bt_accept, CallEventHandler, LV_EVENT_ALL, bt_accept->user_data); lv_obj_set_size(bt_accept, 76, 76); - lv_obj_align(bt_accept, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); - label_accept = lv_label_create(bt_accept, nullptr); + lv_obj_align(bt_accept, LV_ALIGN_BOTTOM_LEFT, 0, 0); + label_accept = lv_label_create(bt_accept); lv_label_set_text(label_accept, Symbols::phone); - lv_obj_set_style_local_bg_color(bt_accept, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); + lv_obj_set_style_bg_color(bt_accept, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_DEFAULT); - bt_reject = lv_btn_create(lv_scr_act(), nullptr); + bt_reject = lv_btn_create(lv_scr_act()); bt_reject->user_data = this; - lv_obj_set_event_cb(bt_reject, CallEventHandler); + lv_obj_add_event_cb(bt_reject, CallEventHandler, LV_EVENT_ALL, bt_reject->user_data); lv_obj_set_size(bt_reject, 76, 76); - lv_obj_align(bt_reject, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); - label_reject = lv_label_create(bt_reject, nullptr); + lv_obj_align(bt_reject, LV_ALIGN_BOTTOM_MID, 0, 0); + label_reject = lv_label_create(bt_reject); lv_label_set_text(label_reject, Symbols::phoneSlash); - lv_obj_set_style_local_bg_color(bt_reject, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); + lv_obj_set_style_bg_color(bt_reject, lv_palette_main(LV_PALETTE_RED), LV_PART_MAIN | LV_STATE_DEFAULT); - bt_mute = lv_btn_create(lv_scr_act(), nullptr); + bt_mute = lv_btn_create(lv_scr_act()); bt_mute->user_data = this; - lv_obj_set_event_cb(bt_mute, CallEventHandler); + lv_obj_add_event_cb(bt_mute, CallEventHandler, LV_EVENT_ALL, bt_mute->user_data); lv_obj_set_size(bt_mute, 76, 76); - lv_obj_align(bt_mute, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); - label_mute = lv_label_create(bt_mute, nullptr); + lv_obj_align(bt_mute, LV_ALIGN_BOTTOM_RIGHT, 0, 0); + label_mute = lv_label_create(bt_mute); lv_label_set_text(label_mute, Symbols::volumMute); - lv_obj_set_style_local_bg_color(bt_mute, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_obj_set_style_bg_color(bt_mute, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); } break; } - lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text(backgroundLabel, ""); } -void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_t event) { - if (event != LV_EVENT_CLICKED) { +void Notifications::NotificationItem::OnCallButtonEvent(lv_obj_t* obj, lv_event_t* event) { + if (lv_event_get_code(event) != LV_EVENT_CLICKED) { return; } diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 0b5271e72f..81843bf5dd 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -40,7 +40,7 @@ namespace Pinetime { bool IsRunning() const { return running; } - void OnCallButtonEvent(lv_obj_t*, lv_event_t event); + void OnCallButtonEvent(lv_obj_t* obj, lv_event_t* event); private: lv_obj_t* container1; @@ -72,7 +72,7 @@ namespace Pinetime { uint32_t timeoutTickCountStart; uint32_t timeoutTickCountEnd; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } } diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp index 3b6d60e34b..e0c9a804ac 100644 --- a/src/displayapp/screens/Paddle.cpp +++ b/src/displayapp/screens/Paddle.cpp @@ -5,34 +5,35 @@ using namespace Pinetime::Applications::Screens; Paddle::Paddle(Pinetime::Applications::DisplayApp* app, Pinetime::Components::LittleVgl& lvgl) : Screen(app), lvgl {lvgl} { - background = lv_obj_create(lv_scr_act(), nullptr); + background = lv_obj_create(lv_scr_act()); lv_obj_set_size(background, LV_HOR_RES + 1, LV_VER_RES); lv_obj_set_pos(background, -1, 0); - lv_obj_set_style_local_radius(background, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); - lv_obj_set_style_local_bg_color(background, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); - lv_obj_set_style_local_border_color(background, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_obj_set_style_local_border_width(background, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 1); + lv_obj_set_style_radius(background, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(background, lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_color(background, lv_color_white(), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_width(background, 1, LV_PART_MAIN | LV_STATE_DEFAULT); - points = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(points, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + points = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(points, &jetbrains_mono_42, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(points, "0000"); - lv_obj_align(points, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 0, 10); + lv_obj_align(points, LV_ALIGN_TOP_MID, 0, 10); - paddle = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(paddle, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_obj_set_style_local_radius(paddle, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + paddle = lv_obj_create(lv_scr_act()); + lv_obj_set_style_bg_color(paddle, lv_color_white(), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(paddle, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(paddle, 4, 60); - ball = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_obj_set_style_local_radius(ball, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE); + ball = lv_obj_create(lv_scr_act()); + lv_obj_set_style_bg_color(ball, lv_color_white(), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(ball, lv_color_white(), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(ball, LV_RADIUS_CIRCLE, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(ball, ballSize, ballSize); - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); } Paddle::~Paddle() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_obj_clean(lv_scr_act()); } diff --git a/src/displayapp/screens/Paddle.h b/src/displayapp/screens/Paddle.h index fc2131a15c..0ab884099c 100644 --- a/src/displayapp/screens/Paddle.h +++ b/src/displayapp/screens/Paddle.h @@ -41,7 +41,7 @@ namespace Pinetime { lv_obj_t* ball; lv_obj_t* background; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } } diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 6766ecb04f..43489a5b87 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -63,142 +63,139 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, displayedChar[4] = 0; //Create a 200px wide background rectangle - timebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG())); - lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + timebar = lv_obj_create(lv_scr_act()); + lv_obj_set_style_bg_color(timebar, Convert(settingsController.GetPTSColorBG()), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(timebar, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(timebar, 200, 240); - lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0); + lv_obj_align(timebar, LV_ALIGN_TOP_LEFT, 5, 0); // Display the time - timeDD1 = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); + timeDD1 = lv_label_create(timebar); + lv_obj_set_style_text_font(timeDD1, &open_sans_light, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(timeDD1, Convert(settingsController.GetPTSColorTime()), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(timeDD1, "12"); - lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5); + lv_obj_align(timeDD1, LV_ALIGN_TOP_MID, 5, 5); - timeDD2 = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); + timeDD2 = lv_label_create(timebar); + lv_obj_set_style_text_font(timeDD2, &open_sans_light, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(timeDD2, Convert(settingsController.GetPTSColorTime()), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(timeDD2, "34"); - lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); + lv_obj_align(timeDD2, LV_ALIGN_BOTTOM_MID, 5, -5); - timeAMPM = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); - lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3); + timeAMPM = lv_label_create(timebar); + lv_obj_set_style_text_color(timeAMPM, Convert(settingsController.GetPTSColorTime()), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_line_space(timeAMPM, -3, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(timeAMPM, ""); - lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20); + lv_obj_align(timeAMPM, LV_ALIGN_BOTTOM_LEFT, 2, -20); // Create a 40px wide bar down the right side of the screen - sidebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar())); - lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + sidebar = lv_obj_create(lv_scr_act()); + lv_obj_set_style_bg_color(sidebar, Convert(settingsController.GetPTSColorBar()), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(sidebar, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(sidebar, 40, 240); - lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); + lv_obj_align(sidebar, LV_ALIGN_TOP_RIGHT, 0, 0); // Display icons - batteryIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + batteryIcon = lv_label_create(sidebar); + lv_obj_set_style_text_color(batteryIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(batteryIcon, Symbols::batteryFull); - lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2); - lv_obj_set_auto_realign(batteryIcon, true); + lv_obj_align(batteryIcon, LV_ALIGN_TOP_MID, 0, 2); - bleIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); + bleIcon = lv_label_create(sidebar); + lv_obj_set_style_text_color(bleIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(bleIcon, LV_ALIGN_TOP_MID, 0, 25); - notificationIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_align(notificationIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 40); + notificationIcon = lv_label_create(sidebar); + lv_obj_set_style_text_color(notificationIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(notificationIcon, LV_ALIGN_TOP_MID, 0, 40); // Calendar icon - calendarOuter = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + calendarOuter = lv_obj_create(sidebar); + lv_obj_set_style_bg_color(calendarOuter, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(calendarOuter, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarOuter, 34, 34); - lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(calendarOuter, LV_ALIGN_CENTER, 0, 0); - calendarInner = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff)); - lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + calendarInner = lv_obj_create(calendarOuter); + lv_obj_set_style_bg_color(calendarInner, lv_color_hex(0xffffff), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(calendarInner, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarInner, 27, 27); - lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(calendarInner, LV_ALIGN_CENTER, 0, 0); - calendarBar1 = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + calendarBar1 = lv_obj_create(calendarOuter); + lv_obj_set_style_bg_color(calendarBar1, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(calendarBar1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarBar1, 3, 12); - lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3); + lv_obj_align(calendarBar1, LV_ALIGN_TOP_MID, -6, -3); - calendarBar2 = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + calendarBar2 = lv_obj_create(calendarOuter); + lv_obj_set_style_bg_color(calendarBar2, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(calendarBar2, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarBar2, 3, 12); - lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3); + lv_obj_align(calendarBar2, LV_ALIGN_TOP_MID, 6, -3); - calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + calendarCrossBar1 = lv_obj_create(calendarBar1); + lv_obj_set_style_bg_color(calendarCrossBar1, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(calendarCrossBar1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarCrossBar1, 8, 3); - lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0); + lv_obj_align(calendarCrossBar1, LV_ALIGN_BOTTOM_MID, 0, 0); - calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + calendarCrossBar2 = lv_obj_create(calendarBar2); + lv_obj_set_style_bg_color(calendarCrossBar2, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(calendarCrossBar2, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarCrossBar2, 8, 3); - lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0); + lv_obj_align(calendarCrossBar2, LV_ALIGN_BOTTOM_MID, 0, 0); // Display date - dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + dateDayOfWeek = lv_label_create(sidebar); + lv_obj_set_style_text_color(dateDayOfWeek, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateDayOfWeek, "THU"); - lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34); + lv_obj_align(dateDayOfWeek, LV_ALIGN_CENTER, 0, -34); - dateDay = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + dateDay = lv_label_create(sidebar); + lv_obj_set_style_text_color(dateDay, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateDay, "25"); - lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3); + lv_obj_align(dateDay, LV_ALIGN_CENTER, 0, 3); - dateMonth = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + dateMonth = lv_label_create(sidebar); + lv_obj_set_style_text_color(dateMonth, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateMonth, "MAR"); - lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32); + lv_obj_align(dateMonth, LV_ALIGN_CENTER, 0, 32); // Step count gauge - needle_colors[0] = LV_COLOR_WHITE; - stepGauge = lv_gauge_create(lv_scr_act(), nullptr); - lv_gauge_set_needle_count(stepGauge, 1, needle_colors); - lv_obj_set_size(stepGauge, 40, 40); - lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0); - lv_gauge_set_scale(stepGauge, 360, 11, 0); - lv_gauge_set_angle_offset(stepGauge, 180); - lv_gauge_set_critical_value(stepGauge, 100); - lv_gauge_set_range(stepGauge, 0, 100); - lv_gauge_set_value(stepGauge, 0, 0); - - lv_obj_set_style_local_pad_right(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_pad_left(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_pad_bottom(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_obj_set_style_local_scale_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4); - lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4); - lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); - lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); - - backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_click(backgroundLabel, true); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + needle_color = lv_color_white(); + stepMeter = lv_meter_create(sidebar); + stepScale = lv_meter_add_scale(stepMeter); + stepIndicator = lv_meter_add_needle_line(stepMeter, stepScale, 3, needle_color, 0); + lv_meter_set_scale_range(stepMeter, stepScale, 0, 100, 360, 180); + lv_meter_set_scale_ticks(stepMeter, stepScale, 11, 4, 4, lv_color_black()); + lv_obj_set_size(stepMeter, 40, 40); + lv_obj_align(stepMeter, LV_ALIGN_BOTTOM_MID, 0, 0); + lv_meter_set_indicator_value(stepMeter, stepIndicator, 0); + + lv_obj_set_style_pad_right(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_left(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_bottom(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_opa(stepMeter, LV_OPA_COVER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_width(stepMeter, 4, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_color(stepMeter, lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_opa(stepMeter, LV_OPA_COVER, LV_PART_INDICATOR | LV_STATE_DEFAULT); + lv_obj_set_style_pad_row(stepMeter, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT); + lv_obj_set_style_pad_column(stepMeter, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT);; + + backgroundLabel = lv_label_create(lv_scr_act()); + lv_obj_add_flag(backgroundLabel, LV_OBJ_FLAG_CLICKABLE); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text(backgroundLabel, ""); - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); Refresh(); } PineTimeStyle::~PineTimeStyle() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_obj_clean(lv_scr_act()); } @@ -226,13 +223,11 @@ void PineTimeStyle::Refresh() { bleState = bleController.IsConnected(); if (bleState.IsUpdated()) { lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get())); - lv_obj_realign(bleIcon); } notificationState = notificatioManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(notificationState.Get())); - lv_obj_realign(notificationIcon); } currentDateTime = dateTimeController.CurrentDateTime(); @@ -292,7 +287,6 @@ void PineTimeStyle::Refresh() { if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) { lv_label_set_text_fmt(dateDayOfWeek, "%s", dateTimeController.DayOfWeekShortToString()); lv_label_set_text_fmt(dateDay, "%d", day); - lv_obj_realign(dateDay); lv_label_set_text_fmt(dateMonth, "%s", dateTimeController.MonthShortToString()); currentYear = year; @@ -305,11 +299,10 @@ void PineTimeStyle::Refresh() { stepCount = motionController.NbSteps(); motionSensorOk = motionController.IsSensorOk(); if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { - lv_gauge_set_value(stepGauge, 0, (stepCount.Get() / (settingsController.GetStepsGoal() / 100))); - lv_obj_realign(stepGauge); + lv_meter_set_indicator_value(stepMeter, stepIndicator, (stepCount.Get() / (settingsController.GetStepsGoal() / 100))); if (stepCount.Get() > settingsController.GetStepsGoal()) { - lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_obj_set_style_local_scale_grad_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_line_color(stepMeter, lv_color_white(), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_grad_color(stepMeter, lv_color_white(), LV_PART_TICKS | LV_STATE_DEFAULT); } } } diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h index ba47380693..abbc398dca 100644 --- a/src/displayapp/screens/PineTimeStyle.h +++ b/src/displayapp/screens/PineTimeStyle.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -66,8 +66,10 @@ namespace Pinetime { lv_obj_t* calendarCrossBar1; lv_obj_t* calendarCrossBar2; lv_obj_t* notificationIcon; - lv_obj_t* stepGauge; - lv_color_t needle_colors[1]; + lv_obj_t* stepMeter; + lv_meter_scale_t* stepScale; + lv_meter_indicator_t* stepIndicator; + lv_color_t needle_color; Controllers::DateTime& dateTimeController; Controllers::Battery& batteryController; @@ -78,7 +80,7 @@ namespace Pinetime { void SetBatteryIcon(); - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } } diff --git a/src/displayapp/screens/Screen.cpp b/src/displayapp/screens/Screen.cpp index 6ae5b7bb00..8ac9167f89 100644 --- a/src/displayapp/screens/Screen.cpp +++ b/src/displayapp/screens/Screen.cpp @@ -1,6 +1,6 @@ #include "Screen.h" using namespace Pinetime::Applications::Screens; -void Screen::RefreshTaskCallback(lv_task_t* task) { +void Screen::RefreshTaskCallback(lv_timer_t* task) { static_cast(task->user_data)->Refresh(); } diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h index ce5741b24f..c36a88da9c 100644 --- a/src/displayapp/screens/Screen.h +++ b/src/displayapp/screens/Screen.h @@ -48,7 +48,7 @@ namespace Pinetime { } virtual ~Screen() = default; - static void RefreshTaskCallback(lv_task_t* task); + static void RefreshTaskCallback(lv_timer_t* task); bool IsRunning() const { return running; diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp index c41163ab07..f71e13adc8 100644 --- a/src/displayapp/screens/Steps.cpp +++ b/src/displayapp/screens/Steps.cpp @@ -10,49 +10,49 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app, Controllers::Settings& settingsController) : Screen(app), motionController {motionController}, settingsController {settingsController} { - stepsArc = lv_arc_create(lv_scr_act(), nullptr); + stepsArc = lv_arc_create(lv_scr_act()); - lv_obj_set_style_local_bg_opa(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, LV_OPA_0); - lv_obj_set_style_local_border_width(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 2); - lv_obj_set_style_local_radius(stepsArc, LV_ARC_PART_BG, LV_STATE_DEFAULT, 0); - lv_obj_set_style_local_line_color(stepsArc, LV_ARC_PART_INDIC, LV_STATE_DEFAULT, lv_color_hex(0x0000FF)); + lv_obj_set_style_bg_opa(stepsArc, LV_OPA_0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_width(stepsArc, 2, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(stepsArc, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_color(stepsArc, lv_color_hex(0x0000FF), LV_PART_INDICATOR | LV_STATE_DEFAULT); lv_arc_set_end_angle(stepsArc, 200); lv_obj_set_size(stepsArc, 220, 220); lv_arc_set_range(stepsArc, 0, 500); - lv_obj_align(stepsArc, nullptr, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(stepsArc, LV_ALIGN_CENTER, 0, 0); stepsCount = motionController.NbSteps(); lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal())); - lSteps = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); - lv_obj_set_style_local_text_font(lSteps, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lSteps = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_color(lSteps, lv_color_hex(0x00FF00), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_font(lSteps, &jetbrains_mono_42, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_fmt(lSteps, "%li", stepsCount); - lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20); + lv_obj_align(lSteps, LV_ALIGN_CENTER, 0, -20); - lv_obj_t* lstepsL = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(lstepsL, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); + lv_obj_t* lstepsL = lv_label_create(lSteps); + lv_obj_set_style_text_color(lstepsL, lv_color_hex(0x111111), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(lstepsL, "Steps"); - lv_obj_align(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); + lv_obj_align(lstepsL, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); - lv_obj_t* lstepsGoal = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(lstepsGoal, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN); + lv_obj_t* lstepsGoal = lv_label_create(lSteps); + lv_obj_set_style_text_color(lstepsGoal, lv_color_hex(0x00FFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_fmt(lstepsGoal, "Goal\n%lu", settingsController.GetStepsGoal()); - lv_label_set_align(lstepsGoal, LV_LABEL_ALIGN_CENTER); - lv_obj_align(lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 60); + lv_obj_set_style_text_align(lstepsGoal, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(lstepsGoal, LV_ALIGN_OUT_BOTTOM_MID, 0, 60); - lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text_static(backgroundLabel, ""); - taskRefresh = lv_task_create(RefreshTaskCallback, 100, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, 100, this); } Steps::~Steps() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_obj_clean(lv_scr_act()); } @@ -60,7 +60,7 @@ void Steps::Refresh() { stepsCount = motionController.NbSteps(); lv_label_set_text_fmt(lSteps, "%li", stepsCount); - lv_obj_align(lSteps, nullptr, LV_ALIGN_CENTER, 0, -20); + lv_obj_align(lSteps, LV_ALIGN_CENTER, 0, -20); lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal())); } diff --git a/src/displayapp/screens/Steps.h b/src/displayapp/screens/Steps.h index d7cf31e17d..fe192cdab0 100644 --- a/src/displayapp/screens/Steps.h +++ b/src/displayapp/screens/Steps.h @@ -31,7 +31,7 @@ namespace Pinetime { uint32_t stepsCount; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } } diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index 9b27a89db2..49aa5dd75f 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -35,13 +35,13 @@ namespace { } } -static void play_pause_event_handler(lv_obj_t* obj, lv_event_t event) { - auto stopWatch = static_cast(obj->user_data); +static void play_pause_event_handler(lv_event_t* event) { + auto stopWatch = static_cast(lv_event_get_user_data(event)); stopWatch->playPauseBtnEventHandler(event); } -static void stop_lap_event_handler(lv_obj_t* obj, lv_event_t event) { - auto stopWatch = static_cast(obj->user_data); +static void stop_lap_event_handler(lv_event_t* event) { + auto stopWatch = static_cast(lv_event_get_user_data(event)); stopWatch->stopLapBtnEventHandler(event); } @@ -55,57 +55,59 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask) lapBuffer {}, lapNr {} { - time = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); - lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + time = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(time, &jetbrains_mono_76, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(time, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(time, "00:00"); - lv_obj_align(time, lv_scr_act(), LV_ALIGN_CENTER, 0, -45); + lv_obj_align(time, LV_ALIGN_CENTER, 0, -45); - msecTime = lv_label_create(lv_scr_act(), nullptr); - // lv_obj_set_style_local_text_font(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20); - lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + msecTime = lv_label_create(lv_scr_act()); + // lv_obj_set_style_text_font(msecTime, &jetbrains_mono_bold_20, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(msecTime, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(msecTime, "00"); - lv_obj_align(msecTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 3); + lv_obj_align(msecTime, LV_ALIGN_CENTER, 0, 3); - btnPlayPause = lv_btn_create(lv_scr_act(), nullptr); + btnPlayPause = lv_btn_create(lv_scr_act()); btnPlayPause->user_data = this; - lv_obj_set_event_cb(btnPlayPause, play_pause_event_handler); + lv_obj_add_event_cb(btnPlayPause, play_pause_event_handler, LV_EVENT_ALL, btnPlayPause->user_data); lv_obj_set_height(btnPlayPause, 50); lv_obj_set_width(btnPlayPause, 115); - lv_obj_align(btnPlayPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); - txtPlayPause = lv_label_create(btnPlayPause, nullptr); + lv_obj_align(btnPlayPause, LV_ALIGN_BOTTOM_RIGHT, 0, 0); + txtPlayPause = lv_label_create(btnPlayPause); lv_label_set_text(txtPlayPause, Symbols::play); - btnStopLap = lv_btn_create(lv_scr_act(), nullptr); + btnStopLap = lv_btn_create(lv_scr_act()); btnStopLap->user_data = this; - lv_obj_set_event_cb(btnStopLap, stop_lap_event_handler); + lv_obj_add_event_cb(btnStopLap, stop_lap_event_handler, LV_EVENT_ALL, btnStopLap->user_data); lv_obj_set_height(btnStopLap, 50); lv_obj_set_width(btnStopLap, 115); - lv_obj_align(btnStopLap, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); - lv_obj_set_style_local_bg_color(btnStopLap, LV_BTN_PART_MAIN, LV_STATE_DISABLED, lv_color_hex(0x080808)); - txtStopLap = lv_label_create(btnStopLap, nullptr); - lv_obj_set_style_local_text_color(txtStopLap, LV_BTN_PART_MAIN, LV_STATE_DISABLED, lv_color_hex(0x888888)); + lv_obj_align(btnStopLap, LV_ALIGN_BOTTOM_LEFT, 0, 0); + lv_obj_set_style_bg_color(btnStopLap, lv_color_hex(0x080808), LV_PART_MAIN | LV_STATE_DISABLED); + txtStopLap = lv_label_create(btnStopLap); + lv_obj_set_style_text_color(txtStopLap, lv_color_hex(0x888888), LV_PART_MAIN | LV_STATE_DISABLED); lv_label_set_text(txtStopLap, Symbols::stop); - lv_obj_set_state(btnStopLap, LV_STATE_DISABLED); - lv_obj_set_state(txtStopLap, LV_STATE_DISABLED); - - lapOneText = lv_label_create(lv_scr_act(), nullptr); - // lv_obj_set_style_local_text_font(lapOneText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20); - lv_obj_set_style_local_text_color(lapOneText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW); - lv_obj_align(lapOneText, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 50, 30); + lv_obj_clear_state(btnStopLap, LV_STATE_ANY); + lv_obj_clear_state(txtStopLap, LV_STATE_ANY); + lv_obj_add_state(btnStopLap, LV_STATE_DISABLED); + lv_obj_add_state(txtStopLap, LV_STATE_DISABLED); + + lapOneText = lv_label_create(lv_scr_act()); + // lv_obj_set_style_text_font(lapOneText, &jetbrains_mono_bold_20, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(lapOneText, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(lapOneText, LV_ALIGN_LEFT_MID, 50, 30); lv_label_set_text(lapOneText, ""); - lapTwoText = lv_label_create(lv_scr_act(), nullptr); - // lv_obj_set_style_local_text_font(lapTwoText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_bold_20); - lv_obj_set_style_local_text_color(lapTwoText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW); - lv_obj_align(lapTwoText, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 50, 55); + lapTwoText = lv_label_create(lv_scr_act()); + // lv_obj_set_style_text_font(lapTwoText, &jetbrains_mono_bold_20, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(lapTwoText, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(lapTwoText, LV_ALIGN_LEFT_MID, 50, 55); lv_label_set_text(lapTwoText, ""); - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); } StopWatch::~StopWatch() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping); lv_obj_clean(lv_scr_act()); } @@ -113,8 +115,8 @@ StopWatch::~StopWatch() { void StopWatch::reset() { currentState = States::Init; oldTimeElapsed = 0; - lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); - lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + lv_obj_set_style_text_color(time, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(msecTime, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(time, "00:00"); lv_label_set_text(msecTime, "00"); @@ -123,15 +125,19 @@ void StopWatch::reset() { lv_label_set_text(lapTwoText, ""); lapBuffer.clearBuffer(); lapNr = 0; - lv_obj_set_state(btnStopLap, LV_STATE_DISABLED); - lv_obj_set_state(txtStopLap, LV_STATE_DISABLED); + lv_obj_clear_state(btnStopLap, LV_STATE_ANY); + lv_obj_clear_state(txtStopLap, LV_STATE_ANY); + lv_obj_add_state(btnStopLap, LV_STATE_DISABLED); + lv_obj_add_state(txtStopLap, LV_STATE_DISABLED); } void StopWatch::start() { - lv_obj_set_state(btnStopLap, LV_STATE_DEFAULT); - lv_obj_set_state(txtStopLap, LV_STATE_DEFAULT); - lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); - lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); + lv_obj_clear_state(btnStopLap, LV_STATE_ANY); + lv_obj_clear_state(txtStopLap, LV_STATE_ANY); + lv_obj_add_state(btnStopLap, LV_STATE_DEFAULT); + lv_obj_add_state(txtStopLap, LV_STATE_DEFAULT); + lv_obj_set_style_text_color(time, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(msecTime, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(txtPlayPause, Symbols::pause); lv_label_set_text(txtStopLap, Symbols::lapsFlag); startTime = xTaskGetTickCount(); @@ -146,8 +152,8 @@ void StopWatch::pause() { currentState = States::Halted; lv_label_set_text(txtPlayPause, Symbols::play); lv_label_set_text(txtStopLap, Symbols::stop); - lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW); - lv_obj_set_style_local_text_color(msecTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW); + lv_obj_set_style_text_color(time, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(msecTime, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_MAIN | LV_STATE_DEFAULT); systemTask.PushMessage(Pinetime::System::Messages::EnableSleeping); } @@ -161,8 +167,8 @@ void StopWatch::Refresh() { } } -void StopWatch::playPauseBtnEventHandler(lv_event_t event) { - if (event != LV_EVENT_CLICKED) { +void StopWatch::playPauseBtnEventHandler(lv_event_t* event) { + if (lv_event_get_code(event) != LV_EVENT_CLICKED) { return; } if (currentState == States::Init) { @@ -174,8 +180,8 @@ void StopWatch::playPauseBtnEventHandler(lv_event_t event) { } } -void StopWatch::stopLapBtnEventHandler(lv_event_t event) { - if (event != LV_EVENT_CLICKED) { +void StopWatch::stopLapBtnEventHandler(lv_event_t* event) { + if (lv_event_get_code(event) != LV_EVENT_CLICKED) { return; } // If running, then this button is used to save laps diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h index 25634e9236..1c4645dd74 100644 --- a/src/displayapp/screens/StopWatch.h +++ b/src/displayapp/screens/StopWatch.h @@ -66,8 +66,8 @@ namespace Pinetime::Applications::Screens { ~StopWatch() override; void Refresh() override; - void playPauseBtnEventHandler(lv_event_t event); - void stopLapBtnEventHandler(lv_event_t event); + void playPauseBtnEventHandler(lv_event_t* event); + void stopLapBtnEventHandler(lv_event_t* event); bool OnButtonPushed() override; void reset(); @@ -86,6 +86,6 @@ namespace Pinetime::Applications::Screens { lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap; lv_obj_t *lapOneText, *lapTwoText; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index b7a4fc60f9..6809da0e8f 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -70,7 +70,7 @@ bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } std::unique_ptr SystemInfo::CreateScreen1() { - lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr); + lv_obj_t* label = lv_label_create(lv_scr_act()); lv_label_set_recolor(label, true); lv_label_set_text_fmt(label, "#FFFF00 InfiniTime#\n\n" @@ -87,8 +87,7 @@ std::unique_ptr SystemInfo::CreateScreen1() { __DATE__, __TIME__, BootloaderVersion::VersionString()); - lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); - lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + lv_obj_center(label); return std::make_unique(0, 5, app, label); } @@ -132,7 +131,7 @@ std::unique_ptr SystemInfo::CreateScreen2() { uptimeSeconds = uptimeSeconds % secondsInAMinute; // TODO handle more than 100 days of uptime - lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr); + lv_obj_t* label = lv_label_create(lv_scr_act()); lv_label_set_recolor(label, true); lv_label_set_text_fmt(label, "#444444 Date# %02d/%02d/%04d\n" @@ -157,7 +156,7 @@ std::unique_ptr SystemInfo::CreateScreen2() { brightnessController.ToString(), resetReason, ToString(motionController.DeviceType())); - lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + lv_obj_align(label, LV_ALIGN_CENTER, 0, 0); return std::make_unique(1, 5, app, label); } @@ -165,7 +164,7 @@ std::unique_ptr SystemInfo::CreateScreen3() { lv_mem_monitor_t mon; lv_mem_monitor(&mon); - lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr); + lv_obj_t* label = lv_label_create(lv_scr_act()); lv_label_set_recolor(label, true); auto& bleAddr = bleController.Address(); lv_label_set_text_fmt(label, @@ -191,7 +190,7 @@ std::unique_ptr SystemInfo::CreateScreen3() { mon.frag_pct, static_cast(mon.free_biggest_size), 0); - lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + lv_obj_align(label, LV_ALIGN_CENTER, 0, 0); return std::make_unique(2, 5, app, label); } @@ -201,7 +200,7 @@ bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) { std::unique_ptr SystemInfo::CreateScreen4() { TaskStatus_t tasksStatus[10]; - lv_obj_t* infoTask = lv_table_create(lv_scr_act(), NULL); + lv_obj_t* infoTask = lv_table_create(lv_scr_act()); lv_table_set_col_cnt(infoTask, 4); lv_table_set_row_cnt(infoTask, 8); lv_obj_set_pos(infoTask, 0, 10); @@ -252,7 +251,7 @@ std::unique_ptr SystemInfo::CreateScreen4() { } std::unique_ptr SystemInfo::CreateScreen5() { - lv_obj_t* label = lv_label_create(lv_scr_act(), nullptr); + lv_obj_t* label = lv_label_create(lv_scr_act()); lv_label_set_recolor(label, true); lv_label_set_text_static(label, "Software Licensed\n" @@ -262,7 +261,7 @@ std::unique_ptr SystemInfo::CreateScreen5() { "#444444 Source code#\n" "#FFFF00 https://github.com/#\n" "#FFFF00 JF002/InfiniTime#"); - lv_label_set_align(label, LV_LABEL_ALIGN_CENTER); - lv_obj_align(label, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + lv_obj_set_style_text_align(label, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_center(label); return std::make_unique(4, 5, app, label); } diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index 1d4f0d0ef7..739354f0be 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -5,18 +5,17 @@ using namespace Pinetime::Applications::Screens; namespace { - static void lv_update_task(struct _lv_task_t* task) { + static void lv_update_task(struct _lv_timer_t* task) { auto* user_data = static_cast(task->user_data); user_data->UpdateScreen(); } - static void event_handler(lv_obj_t* obj, lv_event_t event) { - if (event != LV_EVENT_VALUE_CHANGED) return; + static void event_handler(lv_event_t* event) { + if (lv_event_get_code(event) != LV_EVENT_VALUE_CHANGED) return; - Tile* screen = static_cast(obj->user_data); - auto* eventDataPtr = (uint32_t*) lv_event_get_data(); - uint32_t eventData = *eventDataPtr; - screen->OnValueChangedEvent(obj, eventData); + Tile* screen = static_cast(lv_event_get_user_data(event)); + uint32_t btnId= reinterpret_cast(lv_event_get_param(event)); + screen->OnValueChangedEvent(lv_event_get_target(event), btnId); } } @@ -32,15 +31,15 @@ Tile::Tile(uint8_t screenID, settingsController.SetAppMenu(screenID); // Time - label_time = lv_label_create(lv_scr_act(), nullptr); + label_time = lv_label_create(lv_scr_act()); lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes()); - lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER); - lv_obj_align(label_time, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); + lv_obj_set_align(label_time, LV_ALIGN_CENTER); + lv_obj_align(label_time, LV_ALIGN_TOP_LEFT, 0, 0); // Battery - batteryIcon = lv_label_create(lv_scr_act(), nullptr); + batteryIcon = lv_label_create(lv_scr_act()); lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining())); - lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, -8, 0); + lv_obj_align(batteryIcon, LV_ALIGN_TOP_RIGHT, -8, 0); if (numScreens > 1) { pageIndicatorBasePoints[0].x = LV_HOR_RES - 1; @@ -48,9 +47,9 @@ Tile::Tile(uint8_t screenID, pageIndicatorBasePoints[1].x = LV_HOR_RES - 1; pageIndicatorBasePoints[1].y = LV_VER_RES; - pageIndicatorBase = lv_line_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_line_width(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_line_color(pageIndicatorBase, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); + pageIndicatorBase = lv_line_create(lv_scr_act()); + lv_obj_set_style_line_width(pageIndicatorBase, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_color(pageIndicatorBase, lv_color_hex(0x111111), LV_PART_MAIN | LV_STATE_DEFAULT); lv_line_set_points(pageIndicatorBase, pageIndicatorBasePoints, 2); const uint16_t indicatorSize = LV_VER_RES / numScreens; @@ -61,9 +60,9 @@ Tile::Tile(uint8_t screenID, pageIndicatorPoints[1].x = LV_HOR_RES - 1; pageIndicatorPoints[1].y = indicatorPos + indicatorSize; - pageIndicator = lv_line_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_line_width(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_line_color(pageIndicator, LV_LINE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + pageIndicator = lv_line_create(lv_scr_act()); + lv_obj_set_style_line_width(pageIndicator, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_color(pageIndicator, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); lv_line_set_points(pageIndicator, pageIndicatorPoints, 2); } @@ -81,18 +80,19 @@ Tile::Tile(uint8_t screenID, } btnmMap[btIndex] = ""; - btnm1 = lv_btnmatrix_create(lv_scr_act(), nullptr); + btnm1 = lv_btnmatrix_create(lv_scr_act()); lv_btnmatrix_set_map(btnm1, btnmMap); lv_obj_set_size(btnm1, LV_HOR_RES - 16, LV_VER_RES - 60); - lv_obj_align(btnm1, NULL, LV_ALIGN_CENTER, 0, 10); + lv_obj_align(btnm1, LV_ALIGN_CENTER, 0, 10); - lv_obj_set_style_local_radius(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DEFAULT, 20); - lv_obj_set_style_local_bg_opa(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DEFAULT, LV_OPA_20); - lv_obj_set_style_local_bg_color(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DEFAULT, LV_COLOR_AQUA); - lv_obj_set_style_local_bg_opa(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DISABLED, LV_OPA_20); - lv_obj_set_style_local_bg_color(btnm1, LV_BTNMATRIX_PART_BTN, LV_STATE_DISABLED, lv_color_hex(0x111111)); - lv_obj_set_style_local_pad_all(btnm1, LV_BTNMATRIX_PART_BG, LV_STATE_DEFAULT, 0); - lv_obj_set_style_local_pad_inner(btnm1, LV_BTNMATRIX_PART_BG, LV_STATE_DEFAULT, 10); + lv_obj_set_style_radius(btnm1, 20, LV_PART_ITEMS | LV_STATE_DEFAULT); + lv_obj_set_style_bg_opa(btnm1, LV_OPA_20, LV_PART_ITEMS | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(btnm1, lv_color_hex(0x00FFFF), LV_PART_ITEMS | LV_STATE_DEFAULT); + lv_obj_set_style_bg_opa(btnm1, LV_OPA_20, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_set_style_bg_color(btnm1, lv_color_hex(0x111111), LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_set_style_pad_all(btnm1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_row(btnm1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_column(btnm1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); for (uint8_t i = 0; i < 6; i++) { lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_CLICK_TRIG); @@ -102,19 +102,19 @@ Tile::Tile(uint8_t screenID, } btnm1->user_data = this; - lv_obj_set_event_cb(btnm1, event_handler); + lv_obj_add_event_cb(btnm1, event_handler, LV_EVENT_ALL, btnm1->user_data); - lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text_static(backgroundLabel, ""); - taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_MID, this); + taskUpdate = lv_timer_create(lv_update_task, 5000, this); } Tile::~Tile() { - lv_task_del(taskUpdate); + lv_timer_del(taskUpdate); lv_obj_clean(lv_scr_act()); } diff --git a/src/displayapp/screens/Tile.h b/src/displayapp/screens/Tile.h index 83d3fdf5fa..2f2467087e 100644 --- a/src/displayapp/screens/Tile.h +++ b/src/displayapp/screens/Tile.h @@ -37,7 +37,7 @@ namespace Pinetime { Pinetime::Controllers::Battery& batteryController; Controllers::DateTime& dateTimeController; - lv_task_t* taskUpdate; + lv_timer_t* taskUpdate; lv_obj_t* label_time; lv_obj_t* batteryIcon; diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp index ff3099d54e..c86e1d5f7e 100644 --- a/src/displayapp/screens/Timer.cpp +++ b/src/displayapp/screens/Timer.cpp @@ -6,67 +6,67 @@ using namespace Pinetime::Applications::Screens; -static void btnEventHandler(lv_obj_t* obj, lv_event_t event) { - Timer* screen = static_cast(obj->user_data); - screen->OnButtonEvent(obj, event); +static void btnEventHandler(lv_event_t* event) { + Timer* screen = static_cast(lv_event_get_user_data(event)); + screen->OnButtonEvent(lv_event_get_target(event), event); } void Timer::createButtons() { - btnMinutesUp = lv_btn_create(lv_scr_act(), nullptr); + btnMinutesUp = lv_btn_create(lv_scr_act()); btnMinutesUp->user_data = this; - lv_obj_set_event_cb(btnMinutesUp, btnEventHandler); - lv_obj_align(btnMinutesUp, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, -80); + lv_obj_add_event_cb(btnMinutesUp, btnEventHandler, LV_EVENT_ALL, btnMinutesUp->user_data); + lv_obj_align(btnMinutesUp, LV_ALIGN_LEFT_MID, 20, -80); lv_obj_set_height(btnMinutesUp, 40); lv_obj_set_width(btnMinutesUp, 60); - txtMUp = lv_label_create(btnMinutesUp, nullptr); + txtMUp = lv_label_create(btnMinutesUp); lv_label_set_text(txtMUp, "+"); - btnMinutesDown = lv_btn_create(lv_scr_act(), nullptr); + btnMinutesDown = lv_btn_create(lv_scr_act()); btnMinutesDown->user_data = this; - lv_obj_set_event_cb(btnMinutesDown, btnEventHandler); - lv_obj_align(btnMinutesDown, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 20, +40); + lv_obj_add_event_cb(btnMinutesDown, btnEventHandler, LV_EVENT_ALL, btnMinutesDown->user_data); + lv_obj_align(btnMinutesDown, LV_ALIGN_LEFT_MID, 20, +40); lv_obj_set_height(btnMinutesDown, 40); lv_obj_set_width(btnMinutesDown, 60); - txtMDown = lv_label_create(btnMinutesDown, nullptr); + txtMDown = lv_label_create(btnMinutesDown); lv_label_set_text(txtMDown, "-"); - btnSecondsUp = lv_btn_create(lv_scr_act(), nullptr); + btnSecondsUp = lv_btn_create(lv_scr_act()); btnSecondsUp->user_data = this; - lv_obj_set_event_cb(btnSecondsUp, btnEventHandler); - lv_obj_align(btnSecondsUp, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 10, -80); + lv_obj_add_event_cb(btnSecondsUp, btnEventHandler, LV_EVENT_ALL, btnSecondsUp->user_data); + lv_obj_align(btnSecondsUp, LV_ALIGN_RIGHT_MID, 10, -80); lv_obj_set_height(btnSecondsUp, 40); lv_obj_set_width(btnSecondsUp, 60); - txtSUp = lv_label_create(btnSecondsUp, nullptr); + txtSUp = lv_label_create(btnSecondsUp); lv_label_set_text(txtSUp, "+"); - btnSecondsDown = lv_btn_create(lv_scr_act(), nullptr); + btnSecondsDown = lv_btn_create(lv_scr_act()); btnSecondsDown->user_data = this; - lv_obj_set_event_cb(btnSecondsDown, btnEventHandler); - lv_obj_align(btnSecondsDown, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 10, +40); + lv_obj_add_event_cb(btnSecondsDown, btnEventHandler, LV_EVENT_ALL, btnSecondsDown->user_data); + lv_obj_align(btnSecondsDown, LV_ALIGN_RIGHT_MID, 10, +40); lv_obj_set_height(btnSecondsDown, 40); lv_obj_set_width(btnSecondsDown, 60); - txtSDown = lv_label_create(btnSecondsDown, nullptr); + txtSDown = lv_label_create(btnSecondsDown); lv_label_set_text(txtSDown, "-"); } Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController) : Screen(app), running {true}, timerController {timerController} { - time = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_76); - lv_obj_set_style_local_text_color(time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY); + time = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(time, &jetbrains_mono_76, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(time, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); uint32_t seconds = timerController.GetTimeRemaining() / 1000; lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60); - lv_obj_align(time, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, -20); + lv_obj_align(time, LV_ALIGN_LEFT_MID, 0, -20); - btnPlayPause = lv_btn_create(lv_scr_act(), nullptr); + btnPlayPause = lv_btn_create(lv_scr_act()); btnPlayPause->user_data = this; - lv_obj_set_event_cb(btnPlayPause, btnEventHandler); - lv_obj_align(btnPlayPause, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, -10); + lv_obj_add_event_cb(btnPlayPause, btnEventHandler, LV_EVENT_ALL, btnPlayPause->user_data); + lv_obj_align(btnPlayPause, LV_ALIGN_BOTTOM_MID, 0, -10); lv_obj_set_height(btnPlayPause, 40); - txtPlayPause = lv_label_create(btnPlayPause, nullptr); + txtPlayPause = lv_label_create(btnPlayPause); if (timerController.IsRunning()) { lv_label_set_text(txtPlayPause, Symbols::pause); } else { @@ -74,11 +74,11 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController) createButtons(); } - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); } Timer::~Timer() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_obj_clean(lv_scr_act()); } @@ -89,8 +89,8 @@ void Timer::Refresh() { } } -void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t event) { - if (event == LV_EVENT_CLICKED) { +void Timer::OnButtonEvent(lv_obj_t* obj, lv_event_t* event) { + if (lv_event_get_code(event) == LV_EVENT_CLICKED) { if (obj == btnPlayPause) { if (timerController.IsRunning()) { lv_label_set_text(txtPlayPause, Symbols::play); diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h index d0fc8ed151..5fb87b8a5b 100644 --- a/src/displayapp/screens/Timer.h +++ b/src/displayapp/screens/Timer.h @@ -21,7 +21,7 @@ namespace Pinetime::Applications::Screens { void setDone(); - void OnButtonEvent(lv_obj_t* obj, lv_event_t event); + void OnButtonEvent(lv_obj_t* obj, lv_event_t* event); private: bool running; @@ -34,6 +34,6 @@ namespace Pinetime::Applications::Screens { lv_obj_t *time, *msecTime, *btnPlayPause, *txtPlayPause, *btnMinutesUp, *btnMinutesDown, *btnSecondsUp, *btnSecondsDown, *txtMUp, *txtMDown, *txtSUp, *txtSDown; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } diff --git a/src/displayapp/screens/Twos.cpp b/src/displayapp/screens/Twos.cpp index 4201d501cc..cee332e9b4 100644 --- a/src/displayapp/screens/Twos.cpp +++ b/src/displayapp/screens/Twos.cpp @@ -8,89 +8,98 @@ using namespace Pinetime::Applications::Screens; + +namespace { + + static lv_color_t TWOS_COLOR_0 = lv_color_hex(0xcdc0b4); + static lv_color_t TWOS_COLOR_2 = lv_color_hex(0xefdfc6); + static lv_color_t TWOS_COLOR_8 = lv_color_hex(0xef9263); + static lv_color_t TWOS_COLOR_32 = lv_color_hex(0xf76142); + static lv_color_t TWOS_COLOR_128 = lv_color_hex(0x007dc5); + + static void draw_part_event_cb(lv_event_t* event){ + + lv_obj_draw_part_dsc_t *dsc = static_cast(lv_event_get_param(event)); + if(dsc->part == LV_PART_ITEMS) { + switch (dsc->value) { + case 0: + dsc->rect_dsc->bg_color = TWOS_COLOR_0; + break; + case 2: + case 4: + dsc->rect_dsc->bg_color = TWOS_COLOR_2; + break; + case 8: + case 16: + dsc->rect_dsc->bg_color = TWOS_COLOR_8; + break; + case 32: + case 64: + dsc->rect_dsc->bg_color = TWOS_COLOR_32; + break; + default: + dsc->rect_dsc->bg_color = TWOS_COLOR_128; + break; + + } + } + } +} + Twos::Twos(Pinetime::Applications::DisplayApp* app) : Screen(app) { // create styles to apply to different valued tiles + lv_style_init(&style_cell_default); lv_style_init(&style_cell1); lv_style_init(&style_cell2); lv_style_init(&style_cell3); lv_style_init(&style_cell4); lv_style_init(&style_cell5); - lv_style_set_border_color(&style_cell1, LV_STATE_DEFAULT, lv_color_hex(0xbbada0)); - lv_style_set_border_width(&style_cell1, LV_STATE_DEFAULT, 3); - lv_style_set_bg_opa(&style_cell1, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_cell1, LV_STATE_DEFAULT, lv_color_hex(0xcdc0b4)); - lv_style_set_pad_top(&style_cell1, LV_STATE_DEFAULT, 25); - lv_style_set_text_color(&style_cell1, LV_STATE_DEFAULT, LV_COLOR_BLACK); + lv_style_set_border_color(&style_cell_default, lv_color_hex(0xbbada0)); + lv_style_set_border_width(&style_cell_default, 3); + lv_style_set_bg_opa(&style_cell_default, LV_OPA_COVER); + lv_style_set_pad_top(&style_cell_default, 25); + lv_style_set_text_color(&style_cell_default, lv_color_black()); - lv_style_set_border_color(&style_cell2, LV_STATE_DEFAULT, lv_color_hex(0xbbada0)); - lv_style_set_border_width(&style_cell2, LV_STATE_DEFAULT, 3); - lv_style_set_bg_opa(&style_cell2, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_cell2, LV_STATE_DEFAULT, lv_color_hex(0xefdfc6)); - lv_style_set_pad_top(&style_cell2, LV_STATE_DEFAULT, 25); - lv_style_set_text_color(&style_cell2, LV_STATE_DEFAULT, LV_COLOR_BLACK); - - lv_style_set_border_color(&style_cell3, LV_STATE_DEFAULT, lv_color_hex(0xbbada0)); - lv_style_set_border_width(&style_cell3, LV_STATE_DEFAULT, 3); - lv_style_set_bg_opa(&style_cell3, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_cell3, LV_STATE_DEFAULT, lv_color_hex(0xef9263)); - lv_style_set_pad_top(&style_cell3, LV_STATE_DEFAULT, 25); - - lv_style_set_border_color(&style_cell4, LV_STATE_DEFAULT, lv_color_hex(0xbbada0)); - lv_style_set_border_width(&style_cell4, LV_STATE_DEFAULT, 3); - lv_style_set_bg_opa(&style_cell4, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_cell4, LV_STATE_DEFAULT, lv_color_hex(0xf76142)); - lv_style_set_pad_top(&style_cell4, LV_STATE_DEFAULT, 25); - - lv_style_set_border_color(&style_cell5, LV_STATE_DEFAULT, lv_color_hex(0xbbada0)); - lv_style_set_border_width(&style_cell5, LV_STATE_DEFAULT, 3); - lv_style_set_bg_opa(&style_cell5, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_style_set_bg_color(&style_cell5, LV_STATE_DEFAULT, lv_color_hex(0x007dc5)); - lv_style_set_pad_top(&style_cell5, LV_STATE_DEFAULT, 25); // format grid display - gridDisplay = lv_table_create(lv_scr_act(), nullptr); - lv_obj_add_style(gridDisplay, LV_TABLE_PART_CELL1, &style_cell1); - lv_obj_add_style(gridDisplay, LV_TABLE_PART_CELL2, &style_cell2); - lv_obj_add_style(gridDisplay, LV_TABLE_PART_CELL3, &style_cell3); - lv_obj_add_style(gridDisplay, LV_TABLE_PART_CELL4, &style_cell4); - lv_obj_add_style(gridDisplay, LV_TABLE_PART_CELL4 + 1, &style_cell5); + gridDisplay = lv_table_create(lv_scr_act()); + lv_obj_add_style(gridDisplay, &style_cell_default, LV_PART_ITEMS | LV_STATE_DEFAULT); lv_table_set_col_cnt(gridDisplay, 4); lv_table_set_row_cnt(gridDisplay, 4); lv_table_set_col_width(gridDisplay, 0, LV_HOR_RES / 4); lv_table_set_col_width(gridDisplay, 1, LV_HOR_RES / 4); lv_table_set_col_width(gridDisplay, 2, LV_HOR_RES / 4); lv_table_set_col_width(gridDisplay, 3, LV_HOR_RES / 4); - lv_obj_align(gridDisplay, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); - - lv_obj_clean_style_list(gridDisplay, LV_TABLE_PART_BG); + lv_obj_align(gridDisplay, LV_ALIGN_BOTTOM_MID, 0, 0); // initialize grid for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { grid[row][col].value = 0; - lv_table_set_cell_type(gridDisplay, row, col, 1); - lv_table_set_cell_align(gridDisplay, row, col, LV_LABEL_ALIGN_CENTER); } } placeNewTile(); placeNewTile(); // format score text - scoreText = lv_label_create(lv_scr_act(), nullptr); + scoreText = lv_label_create(lv_scr_act()); lv_obj_set_width(scoreText, LV_HOR_RES); - lv_label_set_align(scoreText, LV_ALIGN_IN_LEFT_MID); - lv_obj_align(scoreText, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 10); + lv_obj_set_style_text_align(scoreText, LV_ALIGN_LEFT_MID, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(scoreText, LV_ALIGN_TOP_LEFT, 0, 10); lv_label_set_recolor(scoreText, true); lv_label_set_text_fmt(scoreText, "Score #FFFF00 %i#", score); - lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text(backgroundLabel, ""); + + // Need a draw callback to color the cells + lv_obj_add_event_cb(gridDisplay, draw_part_event_cb, LV_EVENT_DRAW_PART_BEGIN, gridDisplay->user_data); } Twos::~Twos() { @@ -269,26 +278,6 @@ void Twos::updateGridDisplay(Tile grid[][4]) { } else { lv_table_set_cell_value(gridDisplay, row, col, ""); } - switch (grid[row][col].value) { - case 0: - lv_table_set_cell_type(gridDisplay, row, col, 1); - break; - case 2: - case 4: - lv_table_set_cell_type(gridDisplay, row, col, 2); - break; - case 8: - case 16: - lv_table_set_cell_type(gridDisplay, row, col, 3); - break; - case 32: - case 64: - lv_table_set_cell_type(gridDisplay, row, col, 4); - break; - default: - lv_table_set_cell_type(gridDisplay, row, col, 5); - break; - } } } } diff --git a/src/displayapp/screens/Twos.h b/src/displayapp/screens/Twos.h index 6d85cff68b..89fa63d8b6 100644 --- a/src/displayapp/screens/Twos.h +++ b/src/displayapp/screens/Twos.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include "Screen.h" namespace Pinetime { @@ -18,6 +18,7 @@ namespace Pinetime { bool OnTouchEvent(TouchEvents event) override; private: + lv_style_t style_cell_default; lv_style_t style_cell1; lv_style_t style_cell2; lv_style_t style_cell3; diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index 53e7faf7a6..a5e330bff1 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -15,14 +15,14 @@ constexpr int16_t MinuteLength = 90; constexpr int16_t SecondLength = 110; // sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor -const auto LV_TRIG_SCALE = _lv_trigo_sin(90); +const auto LV_TRIG_SCALE = lv_trigo_sin(90); int16_t Cosine(int16_t angle) { - return _lv_trigo_sin(angle + 90); + return lv_trigo_cos(angle); } int16_t Sine(int16_t angle) { - return _lv_trigo_sin(angle); + return lv_trigo_sin(angle); } int16_t CoordinateXRelocate(int16_t x) { @@ -61,70 +61,69 @@ WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app, sMinute = 99; sSecond = 99; - lv_obj_t* bg_clock_img = lv_img_create(lv_scr_act(), NULL); + lv_obj_t* bg_clock_img = lv_img_create(lv_scr_act()); lv_img_set_src(bg_clock_img, &bg_clock); - lv_obj_align(bg_clock_img, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(bg_clock_img, LV_ALIGN_CENTER, 0, 0); - batteryIcon = lv_label_create(lv_scr_act(), nullptr); + batteryIcon = lv_label_create(lv_scr_act()); lv_label_set_text(batteryIcon, Symbols::batteryHalf); - lv_obj_align(batteryIcon, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0); - lv_obj_set_auto_realign(batteryIcon, true); + lv_obj_align(batteryIcon, LV_ALIGN_TOP_RIGHT, 0, 0); - notificationIcon = lv_label_create(lv_scr_act(), NULL); - lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); + notificationIcon = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_color(notificationIcon, lv_color_hex(0x00FF00), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false)); - lv_obj_align(notificationIcon, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); + lv_obj_align(notificationIcon, LV_ALIGN_BOTTOM_LEFT, 0, 0); // Date - Day / Week day - label_date_day = lv_label_create(lv_scr_act(), NULL); - lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xf0a500)); + label_date_day = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_color(label_date_day, lv_color_hex(0xf0a500), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day()); - lv_label_set_align(label_date_day, LV_LABEL_ALIGN_CENTER); - lv_obj_align(label_date_day, NULL, LV_ALIGN_CENTER, 50, 0); + lv_obj_set_style_text_align(label_date_day, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(label_date_day, LV_ALIGN_CENTER, 50, 0); - minute_body = lv_line_create(lv_scr_act(), NULL); - minute_body_trace = lv_line_create(lv_scr_act(), NULL); - hour_body = lv_line_create(lv_scr_act(), NULL); - hour_body_trace = lv_line_create(lv_scr_act(), NULL); - second_body = lv_line_create(lv_scr_act(), NULL); + minute_body = lv_line_create(lv_scr_act()); + minute_body_trace = lv_line_create(lv_scr_act()); + hour_body = lv_line_create(lv_scr_act()); + hour_body_trace = lv_line_create(lv_scr_act()); + second_body = lv_line_create(lv_scr_act()); lv_style_init(&second_line_style); - lv_style_set_line_width(&second_line_style, LV_STATE_DEFAULT, 3); - lv_style_set_line_color(&second_line_style, LV_STATE_DEFAULT, LV_COLOR_RED); - lv_style_set_line_rounded(&second_line_style, LV_STATE_DEFAULT, true); - lv_obj_add_style(second_body, LV_LINE_PART_MAIN, &second_line_style); + lv_style_set_line_width(&second_line_style, 3); + lv_style_set_line_color(&second_line_style, lv_palette_main(LV_PALETTE_RED)); + lv_style_set_line_rounded(&second_line_style, true); + lv_obj_add_style(second_body, &second_line_style, LV_PART_MAIN | LV_STATE_DEFAULT); lv_style_init(&minute_line_style); - lv_style_set_line_width(&minute_line_style, LV_STATE_DEFAULT, 7); - lv_style_set_line_color(&minute_line_style, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_style_set_line_rounded(&minute_line_style, LV_STATE_DEFAULT, true); - lv_obj_add_style(minute_body, LV_LINE_PART_MAIN, &minute_line_style); + lv_style_set_line_width(&minute_line_style, 7); + lv_style_set_line_color(&minute_line_style, lv_color_white()); + lv_style_set_line_rounded(&minute_line_style, true); + lv_obj_add_style(minute_body, &minute_line_style, LV_PART_MAIN | LV_STATE_DEFAULT); lv_style_init(&minute_line_style_trace); - lv_style_set_line_width(&minute_line_style_trace, LV_STATE_DEFAULT, 3); - lv_style_set_line_color(&minute_line_style_trace, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_style_set_line_rounded(&minute_line_style_trace, LV_STATE_DEFAULT, false); - lv_obj_add_style(minute_body_trace, LV_LINE_PART_MAIN, &minute_line_style_trace); + lv_style_set_line_width(&minute_line_style_trace, 3); + lv_style_set_line_color(&minute_line_style_trace, lv_color_white()); + lv_style_set_line_rounded(&minute_line_style_trace, false); + lv_obj_add_style(minute_body_trace, &minute_line_style_trace, LV_PART_MAIN | LV_STATE_DEFAULT); lv_style_init(&hour_line_style); - lv_style_set_line_width(&hour_line_style, LV_STATE_DEFAULT, 7); - lv_style_set_line_color(&hour_line_style, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_style_set_line_rounded(&hour_line_style, LV_STATE_DEFAULT, true); - lv_obj_add_style(hour_body, LV_LINE_PART_MAIN, &hour_line_style); + lv_style_set_line_width(&hour_line_style, 7); + lv_style_set_line_color(&hour_line_style, lv_color_white()); + lv_style_set_line_rounded(&hour_line_style, true); + lv_obj_add_style(hour_body, &hour_line_style, LV_PART_MAIN | LV_STATE_DEFAULT); lv_style_init(&hour_line_style_trace); - lv_style_set_line_width(&hour_line_style_trace, LV_STATE_DEFAULT, 3); - lv_style_set_line_color(&hour_line_style_trace, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false); - lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace); + lv_style_set_line_width(&hour_line_style_trace, 3); + lv_style_set_line_color(&hour_line_style_trace, lv_color_white()); + lv_style_set_line_rounded(&hour_line_style_trace, false); + lv_obj_add_style(hour_body_trace, &hour_line_style_trace, LV_PART_MAIN | LV_STATE_DEFAULT); - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); UpdateClock(); } WatchFaceAnalog::~WatchFaceAnalog() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_style_reset(&hour_line_style); lv_style_reset(&hour_line_style_trace); @@ -180,9 +179,9 @@ void WatchFaceAnalog::UpdateClock() { void WatchFaceAnalog::SetBatteryIcon() { auto batteryPercent = batteryPercentRemaining.Get(); if (batteryPercent == 100) { - lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); + lv_obj_set_style_text_color(batteryIcon, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_DEFAULT); } else { - lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_text_color(batteryIcon, lv_color_white(), LV_PART_MAIN | LV_STATE_DEFAULT); } lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); } @@ -191,7 +190,7 @@ void WatchFaceAnalog::Refresh() { isCharging = batteryController.IsCharging(); if (isCharging.IsUpdated()) { if (isCharging.Get()) { - lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); + lv_obj_set_style_text_color(batteryIcon,lv_palette_main(LV_PALETTE_RED), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(batteryIcon, Symbols::plug); } else { SetBatteryIcon(); diff --git a/src/displayapp/screens/WatchFaceAnalog.h b/src/displayapp/screens/WatchFaceAnalog.h index 001414a627..c9bfb3c764 100644 --- a/src/displayapp/screens/WatchFaceAnalog.h +++ b/src/displayapp/screens/WatchFaceAnalog.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -84,7 +84,7 @@ namespace Pinetime { void UpdateClock(); void SetBatteryIcon(); - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } } diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 2ecab60975..2ba5ff5ccc 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -33,71 +33,71 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, motionController {motionController} { settingsController.SetClockFace(0); - batteryIcon = lv_label_create(lv_scr_act(), nullptr); + batteryIcon = lv_label_create(lv_scr_act()); lv_label_set_text(batteryIcon, Symbols::batteryFull); - lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); + lv_obj_align(batteryIcon, LV_ALIGN_TOP_RIGHT, 0, 0); - batteryPlug = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(batteryPlug, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xFF0000)); + batteryPlug = lv_label_create(batteryIcon); + lv_obj_set_style_text_color(batteryPlug, lv_color_hex(0xFF0000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(batteryPlug, Symbols::plug); - lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align(batteryPlug,LV_ALIGN_OUT_LEFT_MID, -5, 0); - bleIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x0000FF)); + bleIcon = lv_label_create(batteryPlug); + lv_obj_set_style_text_color(bleIcon, lv_color_hex(0x0000FF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(bleIcon, Symbols::bluetooth); - lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align(bleIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); - notificationIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); + notificationIcon = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_color(notificationIcon, lv_color_hex(0x00FF00), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false)); - lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); + lv_obj_align(notificationIcon, LV_ALIGN_TOP_LEFT, 0, 0); - label_date = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); - lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); + label_date = lv_label_create(lv_scr_act()); + lv_obj_align(label_date, LV_ALIGN_CENTER, 0, 60); + lv_obj_set_style_text_color(label_date, lv_color_hex(0x999999), LV_PART_MAIN | LV_STATE_DEFAULT); - label_time = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_extrabold_compressed); + label_time = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(label_time, &jetbrains_mono_extrabold_compressed, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0); + lv_obj_align(label_time, LV_ALIGN_RIGHT_MID, 0, 0); - label_time_ampm = lv_label_create(lv_scr_act(), nullptr); + label_time_ampm = lv_label_create(lv_scr_act()); lv_label_set_text_static(label_time_ampm, ""); - lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55); + lv_obj_align(label_time_ampm, LV_ALIGN_RIGHT_MID, -30, -55); - backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_click(backgroundLabel, true); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + backgroundLabel = lv_label_create(lv_scr_act()); + lv_obj_add_flag(backgroundLabel, LV_OBJ_FLAG_CLICKABLE); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text(backgroundLabel, ""); - heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); + heartbeatIcon = lv_label_create(lv_scr_act()); lv_label_set_text(heartbeatIcon, Symbols::heartBeat); - lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); - lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); + lv_obj_set_style_text_color(heartbeatIcon, lv_color_hex(0xCE1B1B), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(heartbeatIcon, LV_ALIGN_BOTTOM_LEFT, 0, 0); - heartbeatValue = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); + heartbeatValue = lv_label_create(heartbeatIcon); + lv_obj_set_style_text_color(heartbeatValue, lv_color_hex(0xCE1B1B), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(heartbeatValue, ""); - lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0); + lv_obj_align(heartbeatValue, LV_ALIGN_OUT_RIGHT_MID, 5, 0); - stepValue = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7)); + stepValue = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_color(stepValue, lv_color_hex(0x00FFE7), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(stepValue, "0"); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); + lv_obj_align(stepValue, LV_ALIGN_BOTTOM_RIGHT, 0, 0); - stepIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7)); + stepIcon = lv_label_create(stepValue); + lv_obj_set_style_text_color(stepIcon, lv_color_hex(0x00FFE7), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(stepIcon, Symbols::shoe); - lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align(stepIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); Refresh(); } WatchFaceDigital::~WatchFaceDigital() { - lv_task_del(taskRefresh); + lv_timer_del(taskRefresh); lv_obj_clean(lv_scr_act()); } @@ -111,9 +111,9 @@ void WatchFaceDigital::Refresh() { if (batteryPercentRemaining.IsUpdated()) { auto batteryPercent = batteryPercentRemaining.Get(); if (batteryPercent == 100) { - lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); + lv_obj_set_style_text_color(batteryIcon, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_DEFAULT); } else { - lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_text_color(batteryIcon, lv_color_white(), LV_PART_MAIN | LV_STATE_DEFAULT); } lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); } @@ -122,9 +122,9 @@ void WatchFaceDigital::Refresh() { if (bleState.IsUpdated()) { lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get())); } - lv_obj_align(batteryIcon, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); - lv_obj_align(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); - lv_obj_align(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align(batteryIcon, LV_ALIGN_TOP_RIGHT, 0, 0); + lv_obj_align(batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align(bleIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); notificationState = notificatioManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { @@ -188,9 +188,9 @@ void WatchFaceDigital::Refresh() { lv_label_set_text_fmt(label_time, "%s:%s", hoursChar, minutesChar); if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { - lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0); + lv_obj_align(label_time, LV_ALIGN_RIGHT_MID, 0, 0); } else { - lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + lv_obj_align(label_time, LV_ALIGN_CENTER, 0, 0); } } @@ -200,7 +200,7 @@ void WatchFaceDigital::Refresh() { } else { lv_label_set_text_fmt(label_date, "%s %s %d %d", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString(), day, year); } - lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); + lv_obj_align(label_date, LV_ALIGN_CENTER, 0, 60); currentYear = year; currentMonth = month; @@ -213,22 +213,22 @@ void WatchFaceDigital::Refresh() { heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { if (heartbeatRunning.Get()) { - lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); + lv_obj_set_style_text_color(heartbeatIcon, lv_color_hex(0xCE1B1B), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get()); } else { - lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B)); + lv_obj_set_style_text_color(heartbeatIcon, lv_color_hex(0x1B1B1B), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(heartbeatValue, ""); } - lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); - lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0); + lv_obj_align(heartbeatIcon, LV_ALIGN_BOTTOM_LEFT, 0, 0); + lv_obj_align(heartbeatValue, LV_ALIGN_OUT_RIGHT_MID, 5, 0); } stepCount = motionController.NbSteps(); motionSensorOk = motionController.IsSensorOk(); if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); - lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align(stepValue, LV_ALIGN_BOTTOM_RIGHT, 0, 0); + lv_obj_align(stepIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); } } diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index e27545f3b8..16f904f406 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -74,7 +74,7 @@ namespace Pinetime { Controllers::HeartRateController& heartRateController; Controllers::MotionController& motionController; - lv_task_t* taskRefresh; + lv_timer_t* taskRefresh; }; } } diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index 691c40c848..82d1504351 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -6,12 +6,12 @@ using namespace Pinetime::Applications::Screens; namespace { - static void ButtonEventHandler(lv_obj_t* obj, lv_event_t event) { - auto* screen = static_cast(obj->user_data); - screen->OnButtonEvent(obj, event); + static void ButtonEventHandler(lv_event_t *event) { + auto* screen = static_cast(lv_event_get_user_data(event)); + screen->OnButtonEvent(lv_event_get_target(event), event); } - static void lv_update_task(struct _lv_task_t* task) { + static void lv_update_task(struct _lv_timer_t* task) { auto* user_data = static_cast(task->user_data); user_data->UpdateScreen(); } @@ -34,14 +34,14 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, static constexpr uint8_t innerDistance = 10; // Time - label_time = lv_label_create(lv_scr_act(), nullptr); + label_time = lv_label_create(lv_scr_act()); lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes()); - lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER); - lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 0, 0); + lv_obj_set_style_text_align(label_time, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(label_time, LV_ALIGN_TOP_LEFT, 0, 0); - batteryIcon = lv_label_create(lv_scr_act(), nullptr); + batteryIcon = lv_label_create(lv_scr_act()); lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining())); - lv_obj_align(batteryIcon, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0); + lv_obj_align(batteryIcon, LV_ALIGN_TOP_RIGHT, 0, 0); static constexpr uint8_t barHeight = 20 + innerDistance; static constexpr uint8_t buttonHeight = (LV_VER_RES_MAX - barHeight - innerDistance) / 2; @@ -50,43 +50,43 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, static constexpr uint8_t buttonXOffset = (LV_HOR_RES_MAX - buttonWidth * 2 - innerDistance) / 2; lv_style_init(&btn_style); - lv_style_set_radius(&btn_style, LV_STATE_DEFAULT, buttonHeight / 4); - lv_style_set_bg_color(&btn_style, LV_STATE_DEFAULT, lv_color_hex(0x111111)); + lv_style_set_radius(&btn_style, buttonHeight / 4); + lv_style_set_bg_color(&btn_style, lv_color_hex(0x111111)); - btn1 = lv_btn_create(lv_scr_act(), nullptr); + btn1 = lv_btn_create(lv_scr_act()); btn1->user_data = this; - lv_obj_set_event_cb(btn1, ButtonEventHandler); - lv_obj_add_style(btn1, LV_BTN_PART_MAIN, &btn_style); + lv_obj_add_event_cb(btn1, ButtonEventHandler, LV_EVENT_ALL, btn1->user_data); + lv_obj_add_style(btn1, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(btn1, buttonWidth, buttonHeight); - lv_obj_align(btn1, nullptr, LV_ALIGN_IN_TOP_LEFT, buttonXOffset, barHeight); + lv_obj_align(btn1, LV_ALIGN_TOP_LEFT, buttonXOffset, barHeight); - btn1_lvl = lv_label_create(btn1, nullptr); - lv_obj_set_style_local_text_font(btn1_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + btn1_lvl = lv_label_create(btn1); + lv_obj_set_style_text_font(btn1_lvl, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(btn1_lvl, brightness.GetIcon()); - btn2 = lv_btn_create(lv_scr_act(), nullptr); + btn2 = lv_btn_create(lv_scr_act()); btn2->user_data = this; - lv_obj_set_event_cb(btn2, ButtonEventHandler); - lv_obj_add_style(btn2, LV_BTN_PART_MAIN, &btn_style); + lv_obj_add_event_cb(btn2, ButtonEventHandler, LV_EVENT_ALL, btn2->user_data); + lv_obj_add_style(btn2, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(btn2, buttonWidth, buttonHeight); - lv_obj_align(btn2, nullptr, LV_ALIGN_IN_TOP_RIGHT, - buttonXOffset, barHeight); + lv_obj_align(btn2, LV_ALIGN_TOP_RIGHT, - buttonXOffset, barHeight); lv_obj_t* lbl_btn; - lbl_btn = lv_label_create(btn2, nullptr); - lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + lbl_btn = lv_label_create(btn2); + lv_obj_set_style_text_font(lbl_btn, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(lbl_btn, Symbols::highlight); - btn3 = lv_btn_create(lv_scr_act(), nullptr); + btn3 = lv_btn_create(lv_scr_act()); btn3->user_data = this; - lv_obj_set_event_cb(btn3, ButtonEventHandler); - lv_btn_set_checkable(btn3, true); - lv_obj_add_style(btn3, LV_BTN_PART_MAIN, &btn_style); - lv_obj_set_style_local_bg_color(btn3, LV_BTN_PART_MAIN, LV_STATE_CHECKED, LV_COLOR_GREEN); + lv_obj_add_event_cb(btn3, ButtonEventHandler, LV_EVENT_ALL, btn3->user_data); + lv_obj_add_flag(btn3, LV_OBJ_FLAG_CHECKABLE); + lv_obj_add_style(btn3, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(btn3, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_CHECKED); lv_obj_set_size(btn3, buttonWidth, buttonHeight); - lv_obj_align(btn3, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, buttonXOffset, 0); + lv_obj_align(btn3, LV_ALIGN_BOTTOM_LEFT, buttonXOffset, 0); - btn3_lvl = lv_label_create(btn3, nullptr); - lv_obj_set_style_local_text_font(btn3_lvl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + btn3_lvl = lv_label_create(btn3); + lv_obj_set_style_text_font(btn3_lvl, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); if (settingsController.GetNotificationStatus() == Controllers::Settings::Notification::ON) { lv_obj_add_state(btn3, LV_STATE_CHECKED); @@ -95,29 +95,29 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff); } - btn4 = lv_btn_create(lv_scr_act(), nullptr); + btn4 = lv_btn_create(lv_scr_act()); btn4->user_data = this; - lv_obj_set_event_cb(btn4, ButtonEventHandler); - lv_obj_add_style(btn4, LV_BTN_PART_MAIN, &btn_style); + lv_obj_add_event_cb(btn4, ButtonEventHandler, LV_EVENT_ALL, btn4->user_data); + lv_obj_add_style(btn4, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(btn4, buttonWidth, buttonHeight); - lv_obj_align(btn4, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, - buttonXOffset, 0); + lv_obj_align(btn4, LV_ALIGN_BOTTOM_RIGHT, - buttonXOffset, 0); - lbl_btn = lv_label_create(btn4, nullptr); - lv_obj_set_style_local_text_font(lbl_btn, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &lv_font_sys_48); + lbl_btn = lv_label_create(btn4); + lv_obj_set_style_text_font(lbl_btn, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(lbl_btn, Symbols::settings); - lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text_static(backgroundLabel, ""); - taskUpdate = lv_task_create(lv_update_task, 5000, LV_TASK_PRIO_MID, this); + taskUpdate = lv_timer_create(lv_update_task, 5000, this); } QuickSettings::~QuickSettings() { lv_style_reset(&btn_style); - lv_task_del(taskUpdate); + lv_timer_del(taskUpdate); lv_obj_clean(lv_scr_act()); settingsController.SaveSettings(); } @@ -127,21 +127,21 @@ void QuickSettings::UpdateScreen() { lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining())); } -void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) { - if (object == btn2 && event == LV_EVENT_CLICKED) { +void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t* event) { + if (object == btn2 && lv_event_get_code(event) == LV_EVENT_CLICKED) { running = false; app->StartApp(Apps::FlashLight, DisplayApp::FullRefreshDirections::None); - } else if (object == btn1 && event == LV_EVENT_CLICKED) { + } else if (object == btn1 && lv_event_get_code(event) == LV_EVENT_CLICKED) { brightness.Step(); lv_label_set_text_static(btn1_lvl, brightness.GetIcon()); settingsController.SetBrightness(brightness.Level()); - } else if (object == btn3 && event == LV_EVENT_VALUE_CHANGED) { + } else if (object == btn3 && lv_event_get_code(event) == LV_EVENT_VALUE_CHANGED) { - if (lv_obj_get_state(btn3, LV_BTN_PART_MAIN) & LV_STATE_CHECKED) { + if (lv_obj_get_state(btn3) & LV_STATE_CHECKED) { settingsController.SetNotificationStatus(Controllers::Settings::Notification::ON); motorController.RunForDuration(35); lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn); @@ -150,7 +150,7 @@ void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t event) { lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff); } - } else if (object == btn4 && event == LV_EVENT_CLICKED) { + } else if (object == btn4 && lv_event_get_code(event) == LV_EVENT_CLICKED) { running = false; settingsController.SetSettingsMenu(0); app->StartApp(Apps::Settings, DisplayApp::FullRefreshDirections::Up); diff --git a/src/displayapp/screens/settings/QuickSettings.h b/src/displayapp/screens/settings/QuickSettings.h index c036fa5cf4..7c38cce1fc 100644 --- a/src/displayapp/screens/settings/QuickSettings.h +++ b/src/displayapp/screens/settings/QuickSettings.h @@ -27,7 +27,7 @@ namespace Pinetime { ~QuickSettings() override; - void OnButtonEvent(lv_obj_t* object, lv_event_t event); + void OnButtonEvent(lv_obj_t* object, lv_event_t* event); void UpdateScreen(); @@ -38,7 +38,7 @@ namespace Pinetime { Controllers::MotorController& motorController; Controllers::Settings& settingsController; - lv_task_t* taskUpdate; + lv_timer_t* taskUpdate; lv_obj_t* batteryIcon; lv_obj_t* label_time; diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp index d8d6c767e5..f996da7508 100644 --- a/src/displayapp/screens/settings/SettingDisplay.cpp +++ b/src/displayapp/screens/settings/SettingDisplay.cpp @@ -8,69 +8,73 @@ using namespace Pinetime::Applications::Screens; namespace { - static void event_handler(lv_obj_t* obj, lv_event_t event) { - SettingDisplay* screen = static_cast(obj->user_data); - screen->UpdateSelected(obj, event); + static void event_handler(lv_event_t *event) { + SettingDisplay* screen = static_cast(lv_event_get_user_data(event)); + screen->UpdateSelected(lv_event_get_target(event), event); } } SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) : Screen(app), settingsController {settingsController} { - lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr); + lv_obj_t* container1 = lv_obj_create(lv_scr_act()); - lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10); - lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); - lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); +lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT);; + lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 10, 60); lv_obj_set_width(container1, LV_HOR_RES - 20); lv_obj_set_height(container1, LV_VER_RES - 50); - lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); + lv_obj_set_layout(container1, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); - lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr); + + lv_obj_t* title = lv_label_create(lv_scr_act()); lv_label_set_text_static(title, "Display timeout"); - lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); - lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 10, 15); + lv_obj_set_style_text_align(title, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(title, LV_ALIGN_TOP_MID, 10, 15); - lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_obj_t* icon = lv_label_create(title); + lv_obj_set_style_text_color(icon, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(icon, Symbols::sun); - lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); - lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); + lv_obj_set_style_text_align(icon, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(icon, LV_ALIGN_OUT_LEFT_MID, -10, 0); optionsTotal = 0; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + cbOption[optionsTotal] = lv_checkbox_create(container1); lv_checkbox_set_text_static(cbOption[optionsTotal], " 5 seconds"); cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + lv_obj_add_event_cb(cbOption[optionsTotal], event_handler, LV_EVENT_ALL, cbOption[optionsTotal]->user_data); if (settingsController.GetScreenTimeOut() == 5000) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); + lv_obj_add_state(cbOption[optionsTotal], LV_STATE_CHECKED); } optionsTotal++; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + cbOption[optionsTotal] = lv_checkbox_create(container1); lv_checkbox_set_text_static(cbOption[optionsTotal], " 15 seconds"); cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + lv_obj_add_event_cb(cbOption[optionsTotal], event_handler, LV_EVENT_ALL, cbOption[optionsTotal]->user_data); if (settingsController.GetScreenTimeOut() == 15000) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); + lv_obj_add_state(cbOption[optionsTotal], LV_STATE_CHECKED); } optionsTotal++; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + cbOption[optionsTotal] = lv_checkbox_create(container1); lv_checkbox_set_text_static(cbOption[optionsTotal], " 20 seconds"); cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + lv_obj_add_event_cb(cbOption[optionsTotal], event_handler, LV_EVENT_ALL, cbOption[optionsTotal]->user_data); if (settingsController.GetScreenTimeOut() == 20000) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); + lv_obj_add_state(cbOption[optionsTotal], LV_STATE_CHECKED); } optionsTotal++; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + cbOption[optionsTotal] = lv_checkbox_create(container1); lv_checkbox_set_text_static(cbOption[optionsTotal], " 30 seconds"); cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + lv_obj_add_event_cb(cbOption[optionsTotal], event_handler, LV_EVENT_ALL, cbOption[optionsTotal]->user_data); if (settingsController.GetScreenTimeOut() == 30000) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); + lv_obj_add_state(cbOption[optionsTotal], LV_STATE_CHECKED); } optionsTotal++; } @@ -80,11 +84,11 @@ SettingDisplay::~SettingDisplay() { settingsController.SaveSettings(); } -void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) { - if (event == LV_EVENT_CLICKED) { +void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t* event) { + if (lv_event_get_code(event) == LV_EVENT_CLICKED) { for (int i = 0; i < optionsTotal; i++) { if (object == cbOption[i]) { - lv_checkbox_set_checked(cbOption[i], true); + lv_obj_add_state(cbOption[i], LV_STATE_CHECKED); if (i == 0) { settingsController.SetScreenTimeOut(5000); @@ -102,7 +106,7 @@ void SettingDisplay::UpdateSelected(lv_obj_t* object, lv_event_t event) { app->PushMessage(Applications::Display::Messages::UpdateTimeOut); } else { - lv_checkbox_set_checked(cbOption[i], false); + lv_obj_clear_state(cbOption[i], LV_STATE_CHECKED); } } } diff --git a/src/displayapp/screens/settings/SettingDisplay.h b/src/displayapp/screens/settings/SettingDisplay.h index 51b23aca4e..972602a475 100644 --- a/src/displayapp/screens/settings/SettingDisplay.h +++ b/src/displayapp/screens/settings/SettingDisplay.h @@ -15,7 +15,7 @@ namespace Pinetime { SettingDisplay(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); ~SettingDisplay() override; - void UpdateSelected(lv_obj_t* object, lv_event_t event); + void UpdateSelected(lv_obj_t* object, lv_event_t* event); private: Controllers::Settings& settingsController; diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index c9af19b628..a3a183622c 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -7,208 +7,222 @@ using namespace Pinetime::Applications::Screens; namespace { - static void event_handler(lv_obj_t* obj, lv_event_t event) { - SettingPineTimeStyle* screen = static_cast(obj->user_data); - screen->UpdateSelected(obj, event); + static void event_handler(lv_event_t *event) { + SettingPineTimeStyle* screen = static_cast(lv_event_get_user_data(event)); + screen->UpdateSelected(lv_event_get_target(event), event); } } SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) : Screen(app), settingsController {settingsController} { - timebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBG())); - lv_obj_set_style_local_radius(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + timebar = lv_obj_create(lv_scr_act()); + lv_obj_set_style_bg_color(timebar, Convert(settingsController.GetPTSColorBG()), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(timebar, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(timebar, 200, 240); - lv_obj_align(timebar, lv_scr_act(), LV_ALIGN_IN_TOP_LEFT, 5, 0); + lv_obj_align(timebar, LV_ALIGN_TOP_LEFT, 5, 0); // Display the time - timeDD1 = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); + timeDD1 = lv_label_create(timebar); + lv_obj_set_style_text_font(timeDD1, &open_sans_light, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(timeDD1, Convert(settingsController.GetPTSColorTime()), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(timeDD1, "12"); - lv_obj_align(timeDD1, timebar, LV_ALIGN_IN_TOP_MID, 5, 5); + lv_obj_align(timeDD1, LV_ALIGN_TOP_MID, 5, 5); - timeDD2 = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &open_sans_light); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); + timeDD2 = lv_label_create(timebar); + lv_obj_set_style_text_font(timeDD2, &open_sans_light, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(timeDD2, Convert(settingsController.GetPTSColorTime()), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(timeDD2, "34"); - lv_obj_align(timeDD2, timebar, LV_ALIGN_IN_BOTTOM_MID, 5, -5); + lv_obj_align(timeDD2, LV_ALIGN_BOTTOM_MID, 5, -5); - timeAMPM = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorTime())); - lv_obj_set_style_local_text_line_space(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, -3); + timeAMPM = lv_label_create(timebar); + lv_obj_set_style_text_color(timeAMPM, Convert(settingsController.GetPTSColorTime()), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_line_space(timeAMPM, -3, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(timeAMPM, "A\nM"); - lv_obj_align(timeAMPM, timebar, LV_ALIGN_IN_BOTTOM_LEFT, 2, -20); + lv_obj_align(timeAMPM, LV_ALIGN_BOTTOM_LEFT, 2, -20); // Create a 40px wide bar down the right side of the screen - sidebar = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(settingsController.GetPTSColorBar())); - lv_obj_set_style_local_radius(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + sidebar = lv_obj_create(lv_scr_act()); + lv_obj_set_style_bg_color(sidebar, Convert(settingsController.GetPTSColorBar()), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(sidebar, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(sidebar, 40, 240); - lv_obj_align(sidebar, lv_scr_act(), LV_ALIGN_IN_TOP_RIGHT, 0, 0); + lv_obj_align(sidebar, LV_ALIGN_TOP_RIGHT, 0, 0); // Display icons - batteryIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(batteryIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + batteryIcon = lv_label_create(sidebar); + lv_obj_set_style_text_color(batteryIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(batteryIcon, Symbols::batteryFull); - lv_obj_align(batteryIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 2); + lv_obj_align(batteryIcon, LV_ALIGN_TOP_MID, 0, 2); - bleIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + bleIcon = lv_label_create(sidebar); + lv_obj_set_style_text_color(bleIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(bleIcon, Symbols::bluetooth); - lv_obj_align(bleIcon, sidebar, LV_ALIGN_IN_TOP_MID, 0, 25); + lv_obj_align(bleIcon, LV_ALIGN_TOP_MID, 0, 25); // Calendar icon - calendarOuter = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_set_style_local_radius(calendarOuter, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + calendarOuter = lv_obj_create(sidebar); + lv_obj_set_style_bg_color(calendarOuter, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(calendarOuter, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarOuter, 34, 34); - lv_obj_align(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(calendarOuter, LV_ALIGN_CENTER, 0, 0); - calendarInner = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff)); - lv_obj_set_style_local_radius(calendarInner, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + calendarInner = lv_obj_create(calendarOuter); + lv_obj_set_style_bg_color(calendarInner, lv_color_hex(0xffffff), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(calendarInner, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarInner, 27, 27); - lv_obj_align(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(calendarInner, LV_ALIGN_CENTER, 0, 0); - calendarBar1 = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_set_style_local_radius(calendarBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + calendarBar1 = lv_obj_create(calendarOuter); + lv_obj_set_style_bg_color(calendarBar1, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(calendarBar1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarBar1, 3, 12); - lv_obj_align(calendarBar1, calendarOuter, LV_ALIGN_IN_TOP_MID, -6, -3); + lv_obj_align(calendarBar1, LV_ALIGN_TOP_MID, -6, -3); - calendarBar2 = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_set_style_local_radius(calendarBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + calendarBar2 = lv_obj_create(calendarOuter); + lv_obj_set_style_bg_color(calendarBar2, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(calendarBar2, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarBar2, 3, 12); - lv_obj_align(calendarBar2, calendarOuter, LV_ALIGN_IN_TOP_MID, 6, -3); + lv_obj_align(calendarBar2, LV_ALIGN_TOP_MID, 6, -3); - calendarCrossBar1 = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_set_style_local_radius(calendarCrossBar1, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + calendarCrossBar1 = lv_obj_create(calendarBar1); + lv_obj_set_style_bg_color(calendarCrossBar1, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(calendarCrossBar1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarCrossBar1, 8, 3); - lv_obj_align(calendarCrossBar1, calendarBar1, LV_ALIGN_IN_BOTTOM_MID, 0, 0); + lv_obj_align(calendarCrossBar1, LV_ALIGN_BOTTOM_MID, 0, 0); - calendarCrossBar2 = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_bg_color(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - lv_obj_set_style_local_radius(calendarCrossBar2, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, 0); + calendarCrossBar2 = lv_obj_create(calendarBar2); + lv_obj_set_style_bg_color(calendarCrossBar2, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(calendarCrossBar2, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarCrossBar2, 8, 3); - lv_obj_align(calendarCrossBar2, calendarBar2, LV_ALIGN_IN_BOTTOM_MID, 0, 0); + lv_obj_align(calendarCrossBar2, LV_ALIGN_BOTTOM_MID, 0, 0); // Display date - dateDayOfWeek = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(dateDayOfWeek, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + dateDayOfWeek = lv_label_create(sidebar); + lv_obj_set_style_text_color(dateDayOfWeek, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateDayOfWeek, "THU"); - lv_obj_align(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34); + lv_obj_align(dateDayOfWeek, LV_ALIGN_CENTER, 0, -34); - dateDay = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(dateDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + dateDay = lv_label_create(sidebar); + lv_obj_set_style_text_color(dateDay, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateDay, "25"); - lv_obj_align(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3); + lv_obj_align(dateDay, LV_ALIGN_CENTER, 0, 3); - dateMonth = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(dateMonth, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + dateMonth = lv_label_create(sidebar); + lv_obj_set_style_text_color(dateMonth, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateMonth, "MAR"); - lv_obj_align(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32); + lv_obj_align(dateMonth, LV_ALIGN_CENTER, 0, 32); // Step count gauge - needle_colors[0] = LV_COLOR_WHITE; - stepGauge = lv_gauge_create(lv_scr_act(), nullptr); - lv_gauge_set_needle_count(stepGauge, 1, needle_colors); - lv_obj_set_size(stepGauge, 40, 40); - lv_obj_align(stepGauge, sidebar, LV_ALIGN_IN_BOTTOM_MID, 0, 0); - lv_gauge_set_scale(stepGauge, 360, 11, 0); - lv_gauge_set_angle_offset(stepGauge, 180); - lv_gauge_set_critical_value(stepGauge, (100)); - lv_gauge_set_range(stepGauge, 0, (100)); - lv_gauge_set_value(stepGauge, 0, 0); - - lv_obj_set_style_local_pad_right(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_pad_left(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_pad_bottom(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_obj_set_style_local_scale_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4); - lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, 4); - lv_obj_set_style_local_line_color(stepGauge, LV_GAUGE_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); - lv_obj_set_style_local_line_opa(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, LV_OPA_COVER); - lv_obj_set_style_local_line_width(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 3); - lv_obj_set_style_local_pad_inner(stepGauge, LV_GAUGE_PART_NEEDLE, LV_STATE_DEFAULT, 4); - - backgroundLabel = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_click(backgroundLabel, true); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CROP); + needle_color = lv_color_white(); + stepMeter = lv_meter_create(sidebar); + stepScale = lv_meter_add_scale(stepMeter); + stepIndicator = lv_meter_add_needle_line(stepMeter, stepScale, 3, needle_color, 0); + lv_meter_set_scale_range(stepMeter, stepScale, 0, 100, 360, 180); + lv_meter_set_scale_ticks(stepMeter, stepScale, 11, 4, 4, lv_color_black()); + lv_obj_set_size(stepMeter, 40, 40); + lv_obj_align(stepMeter, LV_ALIGN_BOTTOM_MID, 0, 0); + lv_meter_set_indicator_value(stepMeter, stepIndicator, 0); + + lv_obj_set_style_pad_right(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_left(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_bottom(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_opa(stepMeter, LV_OPA_COVER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_width(stepMeter, 4, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_color(stepMeter, lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_opa(stepMeter, LV_OPA_COVER, LV_PART_INDICATOR | LV_STATE_DEFAULT); + lv_obj_set_style_pad_row(stepMeter, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT); + lv_obj_set_style_pad_column(stepMeter, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT);; + + backgroundLabel = lv_label_create(lv_scr_act()); + lv_obj_add_flag(backgroundLabel, LV_OBJ_FLAG_CLICKABLE); + lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text(backgroundLabel, ""); - btnNextTime = lv_btn_create(lv_scr_act(), nullptr); + btnNextTime = lv_btn_create(lv_scr_act()); btnNextTime->user_data = this; lv_obj_set_size(btnNextTime, 60, 60); - lv_obj_align(btnNextTime, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, -80); - lv_obj_set_style_local_bg_opa(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); - lv_obj_set_style_local_value_str(btnNextTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">"); - lv_obj_set_event_cb(btnNextTime, event_handler); - - btnPrevTime = lv_btn_create(lv_scr_act(), nullptr); + lv_obj_align(btnNextTime, LV_ALIGN_RIGHT_MID, -15, -80); + lv_obj_set_style_bg_opa(btnNextTime, LV_OPA_30, LV_PART_MAIN | LV_STATE_DEFAULT); + txtNextTime = lv_label_create(btnNextTime); + lv_label_set_text(txtNextTime, ">"); + lv_obj_center(txtNextTime); + lv_obj_add_event_cb(btnNextTime, event_handler, LV_EVENT_ALL, btnNextTime->user_data); + + btnPrevTime = lv_btn_create(lv_scr_act()); btnPrevTime->user_data = this; lv_obj_set_size(btnPrevTime, 60, 60); - lv_obj_align(btnPrevTime, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, -80); - lv_obj_set_style_local_bg_opa(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); - lv_obj_set_style_local_value_str(btnPrevTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); - lv_obj_set_event_cb(btnPrevTime, event_handler); - - btnNextBar = lv_btn_create(lv_scr_act(), nullptr); + lv_obj_align(btnPrevTime, LV_ALIGN_LEFT_MID, 15, -80); + lv_obj_set_style_bg_opa(btnPrevTime, LV_OPA_30, LV_PART_MAIN | LV_STATE_DEFAULT); + txtPrevTime = lv_label_create(btnPrevTime); + lv_label_set_text(txtPrevTime, "<"); + lv_obj_center(txtPrevTime); + lv_obj_add_event_cb(btnPrevTime, event_handler, LV_EVENT_ALL, btnPrevTime->user_data); + + btnNextBar = lv_btn_create(lv_scr_act()); btnNextBar->user_data = this; lv_obj_set_size(btnNextBar, 60, 60); - lv_obj_align(btnNextBar, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 0); - lv_obj_set_style_local_bg_opa(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); - lv_obj_set_style_local_value_str(btnNextBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">"); - lv_obj_set_event_cb(btnNextBar, event_handler); - - btnPrevBar = lv_btn_create(lv_scr_act(), nullptr); + lv_obj_align(btnNextBar, LV_ALIGN_RIGHT_MID, -15, 0); + lv_obj_set_style_bg_opa(btnNextBar, LV_OPA_30, LV_PART_MAIN | LV_STATE_DEFAULT); + txtNextBar = lv_label_create(btnNextBar); + lv_label_set_text(txtNextBar, ">"); + lv_obj_center(txtNextBar); + lv_obj_add_event_cb(btnNextBar, event_handler, LV_EVENT_ALL, btnNextBar->user_data); + + btnPrevBar = lv_btn_create(lv_scr_act()); btnPrevBar->user_data = this; lv_obj_set_size(btnPrevBar, 60, 60); - lv_obj_align(btnPrevBar, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 0); - lv_obj_set_style_local_bg_opa(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); - lv_obj_set_style_local_value_str(btnPrevBar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); - lv_obj_set_event_cb(btnPrevBar, event_handler); - - btnNextBG = lv_btn_create(lv_scr_act(), nullptr); + lv_obj_align(btnPrevBar, LV_ALIGN_LEFT_MID, 15, 0); + lv_obj_set_style_bg_opa(btnPrevBar, LV_OPA_30, LV_PART_MAIN | LV_STATE_DEFAULT); + txtPrevBar = lv_label_create(btnPrevBar); + lv_label_set_text(txtPrevBar, "<"); + lv_obj_center(txtPrevBar); + lv_obj_add_event_cb(btnPrevBar, event_handler, LV_EVENT_ALL, btnPrevBar->user_data); + + btnNextBG = lv_btn_create(lv_scr_act()); btnNextBG->user_data = this; lv_obj_set_size(btnNextBG, 60, 60); - lv_obj_align(btnNextBG, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80); - lv_obj_set_style_local_bg_opa(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); - lv_obj_set_style_local_value_str(btnNextBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, ">"); - lv_obj_set_event_cb(btnNextBG, event_handler); - - btnPrevBG = lv_btn_create(lv_scr_act(), nullptr); + lv_obj_align(btnNextBG, LV_ALIGN_RIGHT_MID, -15, 80); + lv_obj_set_style_bg_opa(btnNextBG, LV_OPA_30, LV_PART_MAIN | LV_STATE_DEFAULT); + txtNextBG = lv_label_create(btnNextBG); + lv_label_set_text(txtNextBG, ">"); + lv_obj_center(txtNextBG); + lv_obj_add_event_cb(btnNextBG, event_handler, LV_EVENT_ALL, btnNextBG->user_data); + + btnPrevBG = lv_btn_create(lv_scr_act()); btnPrevBG->user_data = this; lv_obj_set_size(btnPrevBG, 60, 60); - lv_obj_align(btnPrevBG, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80); - lv_obj_set_style_local_bg_opa(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); - lv_obj_set_style_local_value_str(btnPrevBG, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "<"); - lv_obj_set_event_cb(btnPrevBG, event_handler); - - btnReset = lv_btn_create(lv_scr_act(), nullptr); + lv_obj_align(btnPrevBG, LV_ALIGN_LEFT_MID, 15, 80); + lv_obj_set_style_bg_opa(btnPrevBG, LV_OPA_30, LV_PART_MAIN | LV_STATE_DEFAULT); + txtPrevBG = lv_label_create(btnPrevBG); + lv_label_set_text(txtPrevBG, "<"); + lv_obj_center(txtPrevBG); + lv_obj_add_event_cb(btnPrevBG, event_handler, LV_EVENT_ALL, btnPrevBG->user_data); + + btnReset = lv_btn_create(lv_scr_act()); btnReset->user_data = this; lv_obj_set_size(btnReset, 60, 60); - lv_obj_align(btnReset, lv_scr_act(), LV_ALIGN_CENTER, 0, 80); - lv_obj_set_style_local_bg_opa(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); - lv_obj_set_style_local_value_str(btnReset, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rst"); - lv_obj_set_event_cb(btnReset, event_handler); - - btnRandom = lv_btn_create(lv_scr_act(), nullptr); + lv_obj_align(btnReset, LV_ALIGN_CENTER, 0, 80); + lv_obj_set_style_bg_opa(btnReset, LV_OPA_30, LV_PART_MAIN | LV_STATE_DEFAULT); + txtReset = lv_label_create(btnReset); + lv_label_set_text(txtReset, "Rst"); + lv_obj_center(txtReset); + lv_obj_add_event_cb(btnReset, event_handler, LV_EVENT_ALL, btnReset->user_data); + + btnRandom = lv_btn_create(lv_scr_act()); btnRandom->user_data = this; lv_obj_set_size(btnRandom, 60, 60); - lv_obj_align(btnRandom, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); - lv_obj_set_style_local_bg_opa(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_30); - lv_obj_set_style_local_value_str(btnRandom, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Rnd"); - lv_obj_set_event_cb(btnRandom, event_handler); + lv_obj_align(btnRandom, LV_ALIGN_CENTER, 0, 0); + lv_obj_set_style_bg_opa(btnRandom, LV_OPA_30, LV_PART_MAIN | LV_STATE_DEFAULT); + txtRandom = lv_label_create(btnRandom); + lv_label_set_text(txtRandom, "Rnd"); + lv_obj_center(txtRandom); + lv_obj_add_event_cb(btnRandom, event_handler, LV_EVENT_ALL, btnRandom->user_data); } SettingPineTimeStyle::~SettingPineTimeStyle() { @@ -216,60 +230,60 @@ SettingPineTimeStyle::~SettingPineTimeStyle() { settingsController.SaveSettings(); } -void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) { +void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t* event) { auto valueTime = settingsController.GetPTSColorTime(); auto valueBar = settingsController.GetPTSColorBar(); auto valueBG = settingsController.GetPTSColorBG(); - if (event == LV_EVENT_CLICKED) { + if (lv_event_get_code(event) == LV_EVENT_CLICKED) { if (object == btnNextTime) { valueTime = GetNext(valueTime); settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_text_color(timeDD1, Convert(valueTime), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(timeDD2, Convert(valueTime), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(timeAMPM, Convert(valueTime), LV_PART_MAIN | LV_STATE_DEFAULT); } if (object == btnPrevTime) { valueTime = GetPrevious(valueTime); settingsController.SetPTSColorTime(valueTime); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(valueTime)); + lv_obj_set_style_text_color(timeDD1, Convert(valueTime), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(timeDD2, Convert(valueTime), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(timeAMPM, Convert(valueTime), LV_PART_MAIN | LV_STATE_DEFAULT); } if (object == btnNextBar) { valueBar = GetNext(valueBar); if(valueBar == Controllers::Settings::Colors::Black) valueBar = GetNext(valueBar); settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar)); + lv_obj_set_style_bg_color(sidebar, Convert(valueBar), LV_PART_MAIN | LV_STATE_DEFAULT); } if (object == btnPrevBar) { valueBar = GetPrevious(valueBar); if(valueBar == Controllers::Settings::Colors::Black) valueBar = GetPrevious(valueBar); settingsController.SetPTSColorBar(valueBar); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBar)); + lv_obj_set_style_bg_color(sidebar, Convert(valueBar), LV_PART_MAIN | LV_STATE_DEFAULT); } if (object == btnNextBG) { valueBG = GetNext(valueBG); settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG)); + lv_obj_set_style_bg_color(timebar, Convert(valueBG), LV_PART_MAIN | LV_STATE_DEFAULT); } if (object == btnPrevBG) { valueBG = GetPrevious(valueBG); settingsController.SetPTSColorBG(valueBG); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(valueBG)); + lv_obj_set_style_bg_color(timebar, Convert(valueBG), LV_PART_MAIN | LV_STATE_DEFAULT); } if (object == btnReset) { settingsController.SetPTSColorTime(Controllers::Settings::Colors::Teal); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal)); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal)); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal)); + lv_obj_set_style_text_color(timeDD1, Convert(Controllers::Settings::Colors::Teal), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(timeDD2, Convert(Controllers::Settings::Colors::Teal), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(timeAMPM, Convert(Controllers::Settings::Colors::Teal), LV_PART_MAIN | LV_STATE_DEFAULT); settingsController.SetPTSColorBar(Controllers::Settings::Colors::Teal); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Teal)); + lv_obj_set_style_bg_color(sidebar, Convert(Controllers::Settings::Colors::Teal), LV_PART_MAIN | LV_STATE_DEFAULT); settingsController.SetPTSColorBG(Controllers::Settings::Colors::Black); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(Controllers::Settings::Colors::Black)); + lv_obj_set_style_bg_color(timebar, Convert(Controllers::Settings::Colors::Black), LV_PART_MAIN | LV_STATE_DEFAULT); } if (object == btnRandom) { uint8_t randTime = rand() % 17; @@ -283,13 +297,13 @@ void SettingPineTimeStyle::UpdateSelected(lv_obj_t* object, lv_event_t event) { randBar -= 1; } settingsController.SetPTSColorTime(static_cast(randTime)); - lv_obj_set_style_local_text_color(timeDD1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randTime))); - lv_obj_set_style_local_text_color(timeDD2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randTime))); - lv_obj_set_style_local_text_color(timeAMPM, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randTime))); + lv_obj_set_style_text_color(timeDD1, Convert(static_cast(randTime)), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(timeDD2, Convert(static_cast(randTime)), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_color(timeAMPM, Convert(static_cast(randTime)), LV_PART_MAIN | LV_STATE_DEFAULT); settingsController.SetPTSColorBar(static_cast(randBar)); - lv_obj_set_style_local_bg_color(sidebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randBar))); + lv_obj_set_style_bg_color(sidebar, Convert(static_cast(randBar)), LV_PART_MAIN | LV_STATE_DEFAULT); settingsController.SetPTSColorBG(static_cast(randBG)); - lv_obj_set_style_local_bg_color(timebar, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Convert(static_cast(randBG))); + lv_obj_set_style_bg_color(timebar, Convert(static_cast(randBG)), LV_PART_MAIN | LV_STATE_DEFAULT); } } } diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h index 397bd86d46..cd281fb6c9 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.h +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -15,7 +15,7 @@ namespace Pinetime { SettingPineTimeStyle(DisplayApp* app, Pinetime::Controllers::Settings &settingsController); ~SettingPineTimeStyle() override; - void UpdateSelected(lv_obj_t *object, lv_event_t event); + void UpdateSelected(lv_obj_t *object, lv_event_t *event); private: Controllers::Settings& settingsController; @@ -23,14 +23,14 @@ namespace Pinetime { Pinetime::Controllers::Settings::Colors GetNext(Controllers::Settings::Colors color); Pinetime::Controllers::Settings::Colors GetPrevious(Controllers::Settings::Colors color); - lv_obj_t * btnNextTime; - lv_obj_t * btnPrevTime; - lv_obj_t * btnNextBar; - lv_obj_t * btnPrevBar; - lv_obj_t * btnNextBG; - lv_obj_t * btnPrevBG; - lv_obj_t * btnReset; - lv_obj_t * btnRandom; + lv_obj_t * btnNextTime, * txtNextTime; + lv_obj_t * btnPrevTime, * txtPrevTime; + lv_obj_t * btnNextBar, * txtNextBar; + lv_obj_t * btnPrevBar, * txtPrevBar; + lv_obj_t * btnNextBG, * txtNextBG; + lv_obj_t * btnPrevBG, * txtPrevBG; + lv_obj_t * btnReset, * txtReset; + lv_obj_t * btnRandom, * txtRandom; lv_obj_t * timebar; lv_obj_t * sidebar; lv_obj_t * timeDD1; @@ -48,8 +48,10 @@ namespace Pinetime { lv_obj_t * calendarBar2; lv_obj_t * calendarCrossBar1; lv_obj_t * calendarCrossBar2; - lv_obj_t * stepGauge; - lv_color_t needle_colors[1]; + lv_obj_t * stepMeter; + lv_meter_scale_t * stepScale; + lv_meter_indicator_t * stepIndicator; + lv_color_t needle_color; }; } } diff --git a/src/displayapp/screens/settings/SettingSteps.cpp b/src/displayapp/screens/settings/SettingSteps.cpp index bec7972b8f..64cefd43ff 100644 --- a/src/displayapp/screens/settings/SettingSteps.cpp +++ b/src/displayapp/screens/settings/SettingSteps.cpp @@ -6,9 +6,9 @@ using namespace Pinetime::Applications::Screens; namespace { - static void event_handler(lv_obj_t * obj, lv_event_t event) { - SettingSteps* screen = static_cast(obj->user_data); - screen->UpdateSelected(obj, event); + static void event_handler(lv_event_t *event) { + SettingSteps* screen = static_cast(lv_event_get_user_data(event)); + screen->UpdateSelected(lv_event_get_target(event), event); } } @@ -18,50 +18,54 @@ SettingSteps::SettingSteps( settingsController{settingsController} { - lv_obj_t * container1 = lv_cont_create(lv_scr_act(), nullptr); + lv_obj_t * container1 = lv_obj_create(lv_scr_act()); - //lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); - lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10); - lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); - lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 30, 60); lv_obj_set_width(container1, LV_HOR_RES - 50); lv_obj_set_height(container1, LV_VER_RES - 60); - lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); + lv_obj_set_layout(container1, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); - lv_obj_t * title = lv_label_create(lv_scr_act(), NULL); + lv_obj_t * title = lv_label_create(lv_scr_act()); lv_label_set_text_static(title,"Daily steps goal"); - lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); - lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15); + lv_obj_set_style_text_align(title, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(title, LV_ALIGN_TOP_MID, 15, 15); - lv_obj_t * icon = lv_label_create(lv_scr_act(), NULL); - lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_obj_t * icon = lv_label_create(title); + lv_obj_set_style_text_color(icon, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(icon, Symbols::shoe); - lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); - lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); + lv_obj_set_style_text_align(icon, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(icon, LV_ALIGN_OUT_LEFT_MID, -10, 0); - stepValue = lv_label_create(lv_scr_act(), NULL); - lv_obj_set_style_local_text_font(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + stepValue = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(stepValue, &jetbrains_mono_42, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_fmt(stepValue, "%lu", settingsController.GetStepsGoal()); - lv_label_set_align(stepValue, LV_LABEL_ALIGN_CENTER); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); + lv_obj_set_style_text_align(stepValue, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(stepValue, LV_ALIGN_CENTER, 0, -10); - btnPlus = lv_btn_create(lv_scr_act(), NULL); + btnPlus = lv_btn_create(lv_scr_act()); btnPlus->user_data = this; lv_obj_set_size(btnPlus, 80, 50); - lv_obj_align(btnPlus, lv_scr_act(), LV_ALIGN_CENTER, 55, 80); - lv_obj_set_style_local_value_str(btnPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+"); - lv_obj_set_event_cb(btnPlus, event_handler); + lv_obj_align(btnPlus, LV_ALIGN_CENTER, 55, 80); + txtBtnPlus = lv_label_create(btnPlus); + lv_label_set_text(txtBtnPlus, "+"); + lv_obj_add_event_cb(btnPlus, event_handler, LV_EVENT_ALL, btnPlus->user_data); - btnMinus = lv_btn_create(lv_scr_act(), NULL); + btnMinus = lv_btn_create(lv_scr_act()); btnMinus->user_data = this; lv_obj_set_size(btnMinus, 80, 50); - lv_obj_set_event_cb(btnMinus, event_handler); - lv_obj_align(btnMinus, lv_scr_act(), LV_ALIGN_CENTER, -55, 80); - lv_obj_set_style_local_value_str(btnMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-"); + lv_obj_align(btnMinus, LV_ALIGN_CENTER, -55, 80); + txtBtnMinus = lv_label_create(btnMinus); + lv_label_set_text(txtBtnMinus, "-"); + lv_obj_add_event_cb(btnMinus, event_handler, LV_EVENT_ALL, btnMinus->user_data); } @@ -70,23 +74,23 @@ SettingSteps::~SettingSteps() { settingsController.SaveSettings(); } -void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t event) { +void SettingSteps::UpdateSelected(lv_obj_t *object, lv_event_t* event) { uint32_t value = settingsController.GetStepsGoal(); - if(object == btnPlus && (event == LV_EVENT_PRESSED)) { + if(object == btnPlus && (lv_event_get_code(event) == LV_EVENT_PRESSED)) { value += 1000; if ( value <= 500000 ) { settingsController.SetStepsGoal(value); lv_label_set_text_fmt(stepValue, "%lu", settingsController.GetStepsGoal()); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); + lv_obj_align(stepValue, LV_ALIGN_CENTER, 0, -10); } } - if(object == btnMinus && (event == LV_EVENT_PRESSED)) { + if(object == btnMinus && (lv_event_get_code(event) == LV_EVENT_PRESSED)) { value -= 1000; if ( value >= 1000 ) { settingsController.SetStepsGoal(value); lv_label_set_text_fmt(stepValue, "%lu", settingsController.GetStepsGoal()); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -10); + lv_obj_align(stepValue, LV_ALIGN_CENTER, 0, -10); } } diff --git a/src/displayapp/screens/settings/SettingSteps.h b/src/displayapp/screens/settings/SettingSteps.h index 5fc05dee90..8526e47290 100644 --- a/src/displayapp/screens/settings/SettingSteps.h +++ b/src/displayapp/screens/settings/SettingSteps.h @@ -15,14 +15,14 @@ namespace Pinetime { SettingSteps(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); ~SettingSteps() override; - void UpdateSelected(lv_obj_t* object, lv_event_t event); + void UpdateSelected(lv_obj_t* object, lv_event_t* event); private: Controllers::Settings& settingsController; lv_obj_t* stepValue; - lv_obj_t* btnPlus; - lv_obj_t* btnMinus; + lv_obj_t* btnPlus, *txtBtnPlus; + lv_obj_t* btnMinus, *txtBtnMinus; }; } } diff --git a/src/displayapp/screens/settings/SettingTimeFormat.cpp b/src/displayapp/screens/settings/SettingTimeFormat.cpp index c99e3a0e2a..babee69c03 100644 --- a/src/displayapp/screens/settings/SettingTimeFormat.cpp +++ b/src/displayapp/screens/settings/SettingTimeFormat.cpp @@ -7,54 +7,57 @@ using namespace Pinetime::Applications::Screens; namespace { - static void event_handler(lv_obj_t* obj, lv_event_t event) { - SettingTimeFormat* screen = static_cast(obj->user_data); - screen->UpdateSelected(obj, event); + static void event_handler(lv_event_t *event) { + SettingTimeFormat* screen = static_cast(lv_event_get_user_data(event)); + screen->UpdateSelected(lv_event_get_target(event), event); } } SettingTimeFormat::SettingTimeFormat(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) : Screen(app), settingsController {settingsController} { - lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr); + lv_obj_t* container1 = lv_obj_create(lv_scr_act()); - lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10); - lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); - lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 10, 60); lv_obj_set_width(container1, LV_HOR_RES - 20); lv_obj_set_height(container1, LV_VER_RES - 50); - lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); + lv_obj_set_layout(container1, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); - lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr); + lv_obj_t* title = lv_label_create(lv_scr_act()); lv_label_set_text_static(title, "Time format"); - lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); - lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15); + lv_obj_set_style_text_align(title, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(title, LV_ALIGN_TOP_MID, 15, 15); - lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_obj_t* icon = lv_label_create(title); + lv_obj_set_style_text_color(icon, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(icon, Symbols::clock); - lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); - lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); + lv_obj_set_style_text_align(icon, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(icon, LV_ALIGN_OUT_LEFT_MID, -10, 0); optionsTotal = 0; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + cbOption[optionsTotal] = lv_checkbox_create(container1); lv_checkbox_set_text_static(cbOption[optionsTotal], " 12-hour"); cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + lv_obj_add_event_cb(cbOption[optionsTotal], event_handler, LV_EVENT_ALL, cbOption[optionsTotal]->user_data); if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); + lv_obj_add_state(cbOption[optionsTotal], LV_STATE_CHECKED); } optionsTotal++; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + cbOption[optionsTotal] = lv_checkbox_create(container1); lv_checkbox_set_text_static(cbOption[optionsTotal], " 24-hour"); cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + lv_obj_add_event_cb(cbOption[optionsTotal], event_handler, LV_EVENT_ALL, cbOption[optionsTotal]->user_data); if (settingsController.GetClockType() == Controllers::Settings::ClockType::H24) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); + lv_obj_add_state(cbOption[optionsTotal], LV_STATE_CHECKED); } optionsTotal++; } @@ -64,11 +67,11 @@ SettingTimeFormat::~SettingTimeFormat() { settingsController.SaveSettings(); } -void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) { - if (event == LV_EVENT_VALUE_CHANGED) { +void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t* event) { + if (lv_event_get_code(event) == LV_EVENT_VALUE_CHANGED) { for (int i = 0; i < optionsTotal; i++) { if (object == cbOption[i]) { - lv_checkbox_set_checked(cbOption[i], true); + lv_obj_add_state(cbOption[i], LV_STATE_CHECKED); if (i == 0) { settingsController.SetClockType(Controllers::Settings::ClockType::H12); @@ -78,7 +81,7 @@ void SettingTimeFormat::UpdateSelected(lv_obj_t* object, lv_event_t event) { }; } else { - lv_checkbox_set_checked(cbOption[i], false); + lv_obj_clear_state(cbOption[i], LV_STATE_CHECKED); } } } diff --git a/src/displayapp/screens/settings/SettingTimeFormat.h b/src/displayapp/screens/settings/SettingTimeFormat.h index eac4bdc9fd..2c12f3cda4 100644 --- a/src/displayapp/screens/settings/SettingTimeFormat.h +++ b/src/displayapp/screens/settings/SettingTimeFormat.h @@ -15,7 +15,7 @@ namespace Pinetime { SettingTimeFormat(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); ~SettingTimeFormat() override; - void UpdateSelected(lv_obj_t* object, lv_event_t event); + void UpdateSelected(lv_obj_t* object, lv_event_t* event); private: Controllers::Settings& settingsController; diff --git a/src/displayapp/screens/settings/SettingWakeUp.cpp b/src/displayapp/screens/settings/SettingWakeUp.cpp index d999004b5d..e41da09462 100644 --- a/src/displayapp/screens/settings/SettingWakeUp.cpp +++ b/src/displayapp/screens/settings/SettingWakeUp.cpp @@ -8,61 +8,65 @@ using namespace Pinetime::Applications::Screens; namespace { - static void event_handler(lv_obj_t* obj, lv_event_t event) { - SettingWakeUp* screen = static_cast(obj->user_data); - screen->UpdateSelected(obj, event); + static void event_handler(lv_event_t *event) { + SettingWakeUp* screen = static_cast(lv_event_get_user_data(event)); + screen->UpdateSelected(lv_event_get_target(event), event); } } SettingWakeUp::SettingWakeUp(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) : Screen(app), settingsController {settingsController} { ignoringEvents = false; - lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr); + lv_obj_t* container1 = lv_obj_create(lv_scr_act()); - lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10); - lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); - lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT);; + lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 10, 60); lv_obj_set_width(container1, LV_HOR_RES - 20); lv_obj_set_height(container1, LV_VER_RES - 50); - lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); + lv_obj_set_layout(container1, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); - lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr); + + lv_obj_t* title = lv_label_create(lv_scr_act()); lv_label_set_text_static(title, "Wake Up"); - lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); - lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15); + lv_obj_set_style_text_align(title, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(title, LV_ALIGN_TOP_MID, 15, 15); - lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_obj_t* icon = lv_label_create(title); + lv_obj_set_style_text_color(icon, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(icon, Symbols::eye); - lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); - lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); + lv_obj_set_style_text_align(icon, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(icon, LV_ALIGN_OUT_LEFT_MID, -10, 0); optionsTotal = 0; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + cbOption[optionsTotal] = lv_checkbox_create(container1); lv_checkbox_set_text_static(cbOption[optionsTotal], " Single Tap"); cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + lv_obj_add_event_cb(cbOption[optionsTotal], event_handler, LV_EVENT_ALL, cbOption[optionsTotal]->user_data); if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); + lv_obj_add_state(cbOption[optionsTotal], LV_STATE_CHECKED); } optionsTotal++; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + cbOption[optionsTotal] = lv_checkbox_create(container1); lv_checkbox_set_text_static(cbOption[optionsTotal], " Double Tap"); cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + lv_obj_add_event_cb(cbOption[optionsTotal], event_handler, LV_EVENT_ALL, cbOption[optionsTotal]->user_data); if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); + lv_obj_add_state(cbOption[optionsTotal], LV_STATE_CHECKED); } optionsTotal++; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + cbOption[optionsTotal] = lv_checkbox_create(container1); lv_checkbox_set_text_static(cbOption[optionsTotal], " Raise Wrist"); cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + lv_obj_add_event_cb(cbOption[optionsTotal], event_handler, LV_EVENT_ALL, cbOption[optionsTotal]->user_data); if (settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::RaiseWrist)) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); + lv_obj_add_state(cbOption[optionsTotal], LV_STATE_CHECKED); } optionsTotal++; } @@ -72,9 +76,9 @@ SettingWakeUp::~SettingWakeUp() { settingsController.SaveSettings(); } -void SettingWakeUp::UpdateSelected(lv_obj_t* object, lv_event_t event) { +void SettingWakeUp::UpdateSelected(lv_obj_t* object, lv_event_t* event) { using WakeUpMode = Pinetime::Controllers::Settings::WakeUpMode; - if (event == LV_EVENT_VALUE_CHANGED && !ignoringEvents) { + if (lv_event_get_code(event) == LV_EVENT_VALUE_CHANGED && !ignoringEvents) { ignoringEvents = true; // Find the index of the checkbox that triggered the event @@ -95,7 +99,11 @@ void SettingWakeUp::UpdateSelected(lv_obj_t* object, lv_event_t event) { // for example, when setting SingleTap, DoubleTap is unset and vice versa. auto modes = settingsController.getWakeUpModes(); for (int i = 0; i < optionsTotal; ++i) { - lv_checkbox_set_checked(cbOption[i], modes[i]); + if (modes[i]){ + lv_obj_add_state(cbOption[i], LV_STATE_CHECKED); + } else{ + lv_obj_clear_state(cbOption[i], LV_STATE_CHECKED); + } } ignoringEvents = false; diff --git a/src/displayapp/screens/settings/SettingWakeUp.h b/src/displayapp/screens/settings/SettingWakeUp.h index b9a31dc9e5..8177dcf5a3 100644 --- a/src/displayapp/screens/settings/SettingWakeUp.h +++ b/src/displayapp/screens/settings/SettingWakeUp.h @@ -15,7 +15,7 @@ namespace Pinetime { SettingWakeUp(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); ~SettingWakeUp() override; - void UpdateSelected(lv_obj_t* object, lv_event_t event); + void UpdateSelected(lv_obj_t* object, lv_event_t* event); private: Controllers::Settings& settingsController; diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp index cdec704cf3..2ea3da0d1f 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.cpp +++ b/src/displayapp/screens/settings/SettingWatchFace.cpp @@ -7,64 +7,66 @@ using namespace Pinetime::Applications::Screens; namespace { - static void event_handler(lv_obj_t* obj, lv_event_t event) { - SettingWatchFace* screen = static_cast(obj->user_data); - screen->UpdateSelected(obj, event); + static void event_handler(lv_event_t *event) { + SettingWatchFace* screen = static_cast(lv_event_get_user_data(event)); + screen->UpdateSelected(lv_event_get_target(event), event); } } SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Settings& settingsController) : Screen(app), settingsController {settingsController} { - lv_obj_t* container1 = lv_cont_create(lv_scr_act(), nullptr); + lv_obj_t* container1 = lv_obj_create(lv_scr_act()); - // lv_obj_set_style_local_bg_color(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); - lv_obj_set_style_local_bg_opa(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP); - lv_obj_set_style_local_pad_all(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 10); - lv_obj_set_style_local_pad_inner(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 5); - lv_obj_set_style_local_border_width(container1, LV_CONT_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 10, 60); lv_obj_set_width(container1, LV_HOR_RES - 20); lv_obj_set_height(container1, LV_VER_RES - 50); - lv_cont_set_layout(container1, LV_LAYOUT_COLUMN_LEFT); + lv_obj_set_layout(container1, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); - lv_obj_t* title = lv_label_create(lv_scr_act(), nullptr); + lv_obj_t* title = lv_label_create(lv_scr_act()); lv_label_set_text_static(title, "Watch face"); - lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); - lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 10, 15); + lv_obj_set_style_text_align(title, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(title, LV_ALIGN_TOP_MID, 10, 15); - lv_obj_t* icon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_obj_t* icon = lv_label_create(title); + lv_obj_set_style_text_color(icon, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(icon, Symbols::home); - lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); - lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); + lv_obj_set_style_text_align(icon, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(icon, LV_ALIGN_OUT_LEFT_MID, -10, 0); optionsTotal = 0; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + cbOption[optionsTotal] = lv_checkbox_create(container1); lv_checkbox_set_text_static(cbOption[optionsTotal], " Digital face"); cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + lv_obj_add_event_cb(cbOption[optionsTotal], event_handler, LV_EVENT_ALL, cbOption[optionsTotal]->user_data); if (settingsController.GetClockFace() == 0) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); + lv_obj_add_state(cbOption[optionsTotal], LV_STATE_CHECKED); } optionsTotal++; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + cbOption[optionsTotal] = lv_checkbox_create(container1); lv_checkbox_set_text_static(cbOption[optionsTotal], " Analog face"); cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + lv_obj_add_event_cb(cbOption[optionsTotal], event_handler, LV_EVENT_ALL, cbOption[optionsTotal]->user_data); if (settingsController.GetClockFace() == 1) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); + lv_obj_add_state(cbOption[optionsTotal], LV_STATE_CHECKED); } optionsTotal++; - cbOption[optionsTotal] = lv_checkbox_create(container1, nullptr); + cbOption[optionsTotal] = lv_checkbox_create(container1); lv_checkbox_set_text_static(cbOption[optionsTotal], " PineTimeStyle"); cbOption[optionsTotal]->user_data = this; - lv_obj_set_event_cb(cbOption[optionsTotal], event_handler); + lv_obj_add_event_cb(cbOption[optionsTotal], event_handler, LV_EVENT_ALL, cbOption[optionsTotal]->user_data); if (settingsController.GetClockFace() == 2) { - lv_checkbox_set_checked(cbOption[optionsTotal], true); + lv_obj_add_state(cbOption[optionsTotal], LV_STATE_CHECKED); } optionsTotal++; @@ -75,14 +77,14 @@ SettingWatchFace::~SettingWatchFace() { settingsController.SaveSettings(); } -void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t event) { - if (event == LV_EVENT_VALUE_CHANGED) { +void SettingWatchFace::UpdateSelected(lv_obj_t* object, lv_event_t* event) { + if (lv_event_get_code(event) == LV_EVENT_VALUE_CHANGED) { for (uint8_t i = 0; i < optionsTotal; i++) { if (object == cbOption[i]) { - lv_checkbox_set_checked(cbOption[i], true); + lv_obj_add_state(cbOption[i], LV_STATE_CHECKED); settingsController.SetClockFace(i); } else { - lv_checkbox_set_checked(cbOption[i], false); + lv_obj_clear_state(cbOption[i], LV_STATE_CHECKED); } } } diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h index d4a96c6df9..b1baf4ca79 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.h +++ b/src/displayapp/screens/settings/SettingWatchFace.h @@ -15,7 +15,7 @@ namespace Pinetime { SettingWatchFace(DisplayApp* app, Pinetime::Controllers::Settings& settingsController); ~SettingWatchFace() override; - void UpdateSelected(lv_obj_t* object, lv_event_t event); + void UpdateSelected(lv_obj_t* object, lv_event_t* event); private: Controllers::Settings& settingsController; diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index 73109c5af9..3a47b8e5bb 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -1,16 +1,16 @@ /** * @file lv_conf.h - * Configuration file for v7.7.0-dev + * Configuration file for v8.0.2 */ #ifndef LV_CONF_H #define LV_CONF_H -/* clang-format off */ +/*clang-format off*/ #include /*==================== - Graphical settings + COLOR SETTINGS *====================*/ /* Maximal horizontal and vertical resolution to support by the library.*/ @@ -29,49 +29,20 @@ * Useful if the display has a 8 bit interface (e.g. SPI)*/ #define LV_COLOR_16_SWAP 1 -/* 1: Enable screen transparency. - * Useful for OSD or other overlapping GUIs. - * Requires `LV_COLOR_DEPTH = 32` colors and the screen's style should be modified: `style.body.opa = ...`*/ +/*Enable more complex drawing routines to manage screens transparency. + *Can be used if the UI is above another layer, e.g. an OSD menu or video player. + *Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to non LV_OPA_COVER value*/ #define LV_COLOR_SCREEN_TRANSP 0 -/*Images pixels with this color will not be drawn (with chroma keying)*/ -#define LV_COLOR_TRANSP LV_COLOR_MAKE(0x6c, 0xFc, 0x6a) /*LV_COLOR_LIME: pure green*/ - -/* Enable anti-aliasing (lines, and radiuses will be smoothed) */ -#define LV_ANTIALIAS 1 - -/* Default display refresh period. - * Can be changed in the display driver (`lv_disp_drv_t`).*/ -#define LV_DISP_DEF_REFR_PERIOD 20 /*[ms]*/ - -/* Dot Per Inch: used to initialize default sizes. - * E.g. a button with width = LV_DPI / 2 -> half inch wide - * (Not so important, you can adjust it to modify default sizes and spaces)*/ -#define LV_DPI 100 /*[px]*/ - -/* The the real width of the display changes some default values: - * default object sizes, layout of examples, etc. - * According to the width of the display (hor. res. / dpi) - * the displays fall in 4 categories. - * The 4th is extra large which has no upper limit so not listed here - * The upper limit of the categories are set below in 0.1 inch unit. - */ -#define LV_DISP_SMALL_LIMIT 30 -#define LV_DISP_MEDIUM_LIMIT 50 -#define LV_DISP_LARGE_LIMIT 70 - -/* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */ -typedef int16_t lv_coord_t; +/*Images pixels with this color will not be drawn if they are chroma keyed)*/ +#define LV_COLOR_CHROMA_KEY lv_color_hex(0x6CFC6A) /*pure green*/ /*========================= - Memory manager settings + MEMORY SETTINGS *=========================*/ -/* LittelvGL's internal memory manager's settings. - * The graphical objects and other related data are stored here. */ - -/* 1: use custom malloc/free, 0: use the built-in `lv_mem_alloc` and `lv_mem_free` */ -#define LV_MEM_CUSTOM 0 +/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ +#define LV_MEM_CUSTOM 0 #if LV_MEM_CUSTOM == 0 /* Size of the memory used by `lv_mem_alloc` in bytes (>= 2kB)*/ #define LV_MEM_SIZE (14U * 1024U) @@ -79,301 +50,224 @@ typedef int16_t lv_coord_t; /* Complier prefix for a big array declaration */ #define LV_MEM_ATTR -/* Set an address for the memory pool instead of allocating it as an array. - * Can be in external SRAM too. */ -#define LV_MEM_ADR 0 - -/* Automatically defrag. on free. Defrag. means joining the adjacent free cells. */ -#define LV_MEM_AUTO_DEFRAG 1 +/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ +# define LV_MEM_ADR 0 /*0: unused*/ #else /*LV_MEM_CUSTOM*/ #define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ #define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/ #define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/ #endif /*LV_MEM_CUSTOM*/ -/* Use the standard memcpy and memset instead of LVGL's own functions. - * The standard functions might or might not be faster depending on their implementation. */ +/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/ #define LV_MEMCPY_MEMSET_STD 1 -/* Garbage Collector settings - * Used if lvgl is binded to higher level language and the memory is managed by that language */ -#define LV_ENABLE_GC 0 -#if LV_ENABLE_GC != 0 -#define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ -#define LV_MEM_CUSTOM_REALLOC your_realloc /*Wrapper to realloc*/ -#define LV_MEM_CUSTOM_GET_SIZE your_mem_get_size /*Wrapper to lv_mem_get_size*/ -#endif /* LV_ENABLE_GC */ - -/*======================= - Input device settings - *=======================*/ - -/* Input device default settings. - * Can be changed in the Input device driver (`lv_indev_drv_t`)*/ - -/* Input device read period in milliseconds */ -#define LV_INDEV_DEF_READ_PERIOD 20 - -/* Drag threshold in pixels */ -#define LV_INDEV_DEF_DRAG_LIMIT 10 - -/* Drag throw slow-down in [%]. Greater value -> faster slow-down */ -#define LV_INDEV_DEF_DRAG_THROW 20 - -/* Long press time in milliseconds. - * Time to send `LV_EVENT_LONG_PRESSSED`) */ -#define LV_INDEV_DEF_LONG_PRESS_TIME 400 +/*==================== + HAL SETTINGS + *====================*/ -/* Repeated trigger period in long press [ms] - * Time between `LV_EVENT_LONG_PRESSED_REPEAT */ -#define LV_INDEV_DEF_LONG_PRESS_REP_TIME 100 +/*Default display refresh period. LVG will redraw changed ares with this period time*/ +#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/ -/* Gesture threshold in pixels */ -#define LV_INDEV_DEF_GESTURE_LIMIT 50 +/*Input device read period in milliseconds*/ +#define LV_INDEV_DEF_READ_PERIOD 20 /*[ms]*/ -/* Gesture min velocity at release before swipe (pixels)*/ -#define LV_INDEV_DEF_GESTURE_MIN_VELOCITY 3 +/*Use a custom tick source that tells the elapsed time in milliseconds. + *It removes the need to manually update the tick with `lv_tick_inc()`)*/ +#define LV_TICK_CUSTOM 1 +#if LV_TICK_CUSTOM +#define LV_TICK_CUSTOM_INCLUDE "FreeRTOS.h" /*Header for the system time function*/ +uint32_t xTaskGetTickCount(); /*Forward declare to avoid compiler warning*/ +#define LV_TICK_CUSTOM_SYS_TIME_EXPR (xTaskGetTickCount()) /*Expression evaluating to current system time in ms*/ +#endif /*LV_TICK_CUSTOM*/ -/*================== - * Feature usage - *==================*/ +/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. + *(Not so important, you can adjust it to modify default sizes and spaces)*/ +#define LV_DPI_DEF 100 /*[px/inch]*/ -/*1: Enable the Animations */ -#define LV_USE_ANIMATION 1 -#if LV_USE_ANIMATION +/*======================= + * FEATURE CONFIGURATION + *=======================*/ -/*Declare the type of the user data of animations (can be e.g. `void *`, `int`, `struct`)*/ -typedef void* lv_anim_user_data_t; +/*------------- + * Drawing + *-----------*/ -#endif +/*Enable complex draw engine. + *Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/ +#define LV_DRAW_COMPLEX 1 +#if LV_DRAW_COMPLEX != 0 -/* 1: Enable shadow drawing on rectangles*/ -#define LV_USE_SHADOW 0 -#if LV_USE_SHADOW -/* Allow buffering some shadow calculation - * LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, - * where shadow size is `shadow_width + radius` - * Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ +/*Allow buffering some shadow calculation. + *LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` + *Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ #define LV_SHADOW_CACHE_SIZE 0 -#endif - -/*1: enable outline drawing on rectangles*/ -#define LV_USE_OUTLINE 0 - -/*1: enable pattern drawing on rectangles*/ -#define LV_USE_PATTERN 0 - -/*1: enable value string drawing on rectangles*/ -#define LV_USE_VALUE_STR 1 - -/* 1: Use other blend modes than normal (`LV_BLEND_MODE_...`)*/ -#define LV_USE_BLEND_MODES 0 - -/* 1: Use the `opa_scale` style property to set the opacity of an object and its children at once*/ -#define LV_USE_OPA_SCALE 0 - -/* 1: Use image zoom and rotation*/ -#define LV_USE_IMG_TRANSFORM 0 - -/* 1: Enable object groups (for keyboard/encoder navigation) */ -#define LV_USE_GROUP 0 -#if LV_USE_GROUP -typedef void* lv_group_user_data_t; -#endif /*LV_USE_GROUP*/ - -/* 1: Enable GPU interface*/ -#define LV_USE_GPU 0 /*Only enables `gpu_fill_cb` and `gpu_blend_cb` in the disp. drv- */ +#endif /*LV_DRAW_COMPLEX*/ + +/*Default image cache size. Image caching keeps the images opened. + *If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added) + *With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. + *However the opened images might consume additional RAM. + *0: to disable caching*/ +#define LV_IMG_CACHE_DEF_SIZE 0 + +/*Maximum buffer size to allocate for rotation. Only used if software rotation is enabled in the display driver.*/ +#define LV_DISP_ROT_MAX_BUF (10*1024) +/*------------- + * GPU + *-----------*/ + +/*Use STM32's DMA2D (aka Chrom Art) GPU*/ #define LV_USE_GPU_STM32_DMA2D 0 -/*If enabling LV_USE_GPU_STM32_DMA2D, LV_GPU_DMA2D_CMSIS_INCLUDE must be defined to include path of CMSIS header of target processor -e.g. "stm32f769xx.h" or "stm32f429xx.h" */ +#if LV_USE_GPU_STM32_DMA2D +/*Must be defined to include path of CMSIS header of target processor +e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ #define LV_GPU_DMA2D_CMSIS_INCLUDE +#endif -/*1: Use PXP for CPU off-load on NXP RTxxx platforms */ +/*Use NXP's PXP GPU iMX RTxxx platforms*/ #define LV_USE_GPU_NXP_PXP 0 - +#if LV_USE_GPU_NXP_PXP /*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) - * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol FSL_RTOS_FREE_RTOS + * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() - * */ + */ #define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 +#endif -/*1: Use VG-Lite for CPU offload on NXP RTxxx platforms */ +/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/ #define LV_USE_GPU_NXP_VG_LITE 0 -/* 1: Enable file system (might be required for images */ -// TODO: Enable FS -#define LV_USE_FILESYSTEM 1 -#if LV_USE_FILESYSTEM -/*Declare the type of the user data of file system drivers (can be e.g. `void *`, `int`, `struct`)*/ -typedef void * lv_fs_drv_user_data_t; -#endif +/*------------- + * Logging + *-----------*/ -/*1: Add a `user_data` to drivers and objects*/ -#define LV_USE_USER_DATA 1 +/*Enable the log module*/ +#define LV_USE_LOG 1 +#if LV_USE_LOG + +/*How important log should be added: + *LV_LOG_LEVEL_TRACE A lot of logs to give detailed information + *LV_LOG_LEVEL_INFO Log important events + *LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem + *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail + *LV_LOG_LEVEL_USER Only logs added by the user + *LV_LOG_LEVEL_NONE Do not log anything*/ +# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN + +/*1: Print the log with 'printf'; + *0: User need to register a callback with `lv_log_register_print_cb()`*/ +# define LV_LOG_PRINTF 0 + +/*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ +# define LV_LOG_TRACE_MEM 1 +# define LV_LOG_TRACE_TIMER 1 +# define LV_LOG_TRACE_INDEV 1 +# define LV_LOG_TRACE_DISP_REFR 1 +# define LV_LOG_TRACE_EVENT 1 +# define LV_LOG_TRACE_OBJ_CREATE 1 +# define LV_LOG_TRACE_LAYOUT 1 +# define LV_LOG_TRACE_ANIM 1 + +#endif /*LV_USE_LOG*/ + +/*------------- + * Asserts + *-----------*/ + +/*Enable asserts if an operation is failed or an invalid data is found. + *If LV_USE_LOG is enabled an error message will be printed on failure*/ +#define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ +#define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ +#define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ +#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/ + +/*Add a custom handler when assert happens e.g. to restart the MCU*/ +#define LV_ASSERT_HANDLER_INCLUDE +#define LV_ASSERT_HANDLER while(1); /*Halt by default*/ + +/*------------- + * Others + *-----------*/ /*1: Show CPU usage and FPS count in the right bottom corner*/ #define LV_USE_PERF_MONITOR 0 -/*1: Use the functions and types from the older API if possible */ -#define LV_USE_API_EXTENSION_V6 0 -#define LV_USE_API_EXTENSION_V7 1 - -/*======================== - * Image decoder and cache - *========================*/ +/*1: Show the used memory and the memory fragmentation in the left bottom corner + * Requires LV_MEM_CUSTOM = 0*/ +#define LV_USE_MEM_MONITOR 0 -/* 1: Enable indexed (palette) images */ -#define LV_IMG_CF_INDEXED 1 +/*1: Draw random colored rectangles over the redrawn areas*/ +#define LV_USE_REFR_DEBUG 0 -/* 1: Enable alpha indexed images */ -#define LV_IMG_CF_ALPHA 0 +/*Change the built in (v)snprintf functions*/ +#define LV_SPRINTF_CUSTOM 0 +#if LV_SPRINTF_CUSTOM +# define LV_SPRINTF_INCLUDE +# define lv_snprintf snprintf +# define lv_vsnprintf vsnprintf +#else /*LV_SPRINTF_CUSTOM*/ +# define LV_SPRINTF_USE_FLOAT 0 +#endif /*LV_SPRINTF_CUSTOM*/ -/* Default image cache size. Image caching keeps the images opened. - * If only the built-in image formats are used there is no real advantage of caching. - * (I.e. no new image decoder is added) - * With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. - * However the opened images might consume additional RAM. - * LV_IMG_CACHE_DEF_SIZE must be >= 1 */ -#define LV_IMG_CACHE_DEF_SIZE 6 +#define LV_USE_USER_DATA 1 -/*Declare the type of the user data of image decoder (can be e.g. `void *`, `int`, `struct`)*/ -typedef void* lv_img_decoder_user_data_t; +/*Garbage Collector settings + *Used if lvgl is binded to higher level language and the memory is managed by that language*/ +#define LV_ENABLE_GC 0 +#if LV_ENABLE_GC != 0 +# define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ +#endif /*LV_ENABLE_GC*/ /*===================== - * Compiler settings + * COMPILER SETTINGS *====================*/ -/* For big endian systems set to 1 */ +/*For big endian systems set to 1*/ #define LV_BIG_ENDIAN_SYSTEM 0 -/* Define a custom attribute to `lv_tick_inc` function */ +/*Define a custom attribute to `lv_tick_inc` function*/ #define LV_ATTRIBUTE_TICK_INC -/* Define a custom attribute to `lv_task_handler` function */ -#define LV_ATTRIBUTE_TASK_HANDLER +/*Define a custom attribute to `lv_timer_handler` function*/ +#define LV_ATTRIBUTE_TIMER_HANDLER -/* Define a custom attribute to `lv_disp_flush_ready` function */ +/*Define a custom attribute to `lv_disp_flush_ready` function*/ #define LV_ATTRIBUTE_FLUSH_READY -/* Required alignment size for buffers */ +/*Required alignment size for buffers*/ #define LV_ATTRIBUTE_MEM_ALIGN_SIZE -/* With size optimization (-Os) the compiler might not align data to - * 4 or 8 byte boundary. Some HW may need even 32 or 64 bytes. - * This alignment will be explicitly applied where needed. - * LV_ATTRIBUTE_MEM_ALIGN_SIZE should be used to specify required align size. - * E.g. __attribute__((aligned(LV_ATTRIBUTE_MEM_ALIGN_SIZE))) */ +/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default). + * E.g. __attribute__((aligned(4)))*/ #define LV_ATTRIBUTE_MEM_ALIGN -/* Attribute to mark large constant arrays for example - * font's bitmaps */ +/*Attribute to mark large constant arrays for example font's bitmaps*/ #define LV_ATTRIBUTE_LARGE_CONST -/* Prefix performance critical functions to place them into a faster memory (e.g RAM) - * Uses 15-20 kB extra memory */ -//#define LV_ATTRIBUTE_FAST_MEM +/*Complier prefix for a big array declaration in RAM*/ +#define LV_ATTRIBUTE_LARGE_RAM_ARRAY -/* Export integer constant to binding. - * This macro is used with constants in the form of LV_ that - * should also appear on lvgl binding API such as Micropython - * - * The default value just prevents a GCC warning. - */ -#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning +/*Place performance critical functions into a faster memory (e.g RAM)*/ +//#define LV_ATTRIBUTE_FAST_MEM -/* Prefix variables that are used in GPU accelerated operations, often these need to be - * placed in RAM sections that are DMA accessible */ +/*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/ // #define LV_ATTRIBUTE_DMA -/*=================== - * HAL settings - *==================*/ - -/* 1: use a custom tick source. - * It removes the need to manually update the tick with `lv_tick_inc`) */ -#define LV_TICK_CUSTOM 1 -#if LV_TICK_CUSTOM == 1 -#define LV_TICK_CUSTOM_INCLUDE "FreeRTOS.h" /*Header for the system time function*/ -uint32_t xTaskGetTickCount(); /*Forward declare to avoid compiler warning*/ -#define LV_TICK_CUSTOM_SYS_TIME_EXPR (xTaskGetTickCount()) /*Expression evaluating to current system time in ms*/ -#endif /*LV_TICK_CUSTOM*/ - -typedef void* lv_disp_drv_user_data_t; /*Type of user data in the display driver*/ -typedef void* lv_indev_drv_user_data_t; /*Type of user data in the input device driver*/ - -/*================ - * Log settings - *===============*/ - -/*1: Enable the log module*/ -#define LV_USE_LOG 0 -#if LV_USE_LOG -/* How important log should be added: - * LV_LOG_LEVEL_TRACE A lot of logs to give detailed information - * LV_LOG_LEVEL_INFO Log important events - * LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem - * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail - * LV_LOG_LEVEL_NONE Do not log anything - */ -#define LV_LOG_LEVEL LV_LOG_LEVEL_WARN - -/* 1: Print the log with 'printf'; - * 0: user need to register a callback with `lv_log_register_print_cb`*/ -#define LV_LOG_PRINTF 0 -#endif /*LV_USE_LOG*/ - -/*================= - * Debug settings - *================*/ - -/* If Debug is enabled LittelvGL validates the parameters of the functions. - * If an invalid parameter is found an error log message is printed and - * the MCU halts at the error. (`LV_USE_LOG` should be enabled) - * If you are debugging the MCU you can pause - * the debugger to see exactly where the issue is. - * - * The behavior of asserts can be overwritten by redefining them here. - * E.g. #define LV_ASSERT_MEM(p) - */ -#define LV_USE_DEBUG 0 -#if LV_USE_DEBUG +/*Export integer constant to binding. This macro is used with constants in the form of LV_ that + *should also appear on LVGL binding API such as Micropython.*/ +#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ -/*Check if the parameter is NULL. (Quite fast) */ -#define LV_USE_ASSERT_NULL 1 - -/*Checks is the memory is successfully allocated or no. (Quite fast)*/ -#define LV_USE_ASSERT_MEM 1 - -/*Check the integrity of `lv_mem` after critical operations. (Slow)*/ -#define LV_USE_ASSERT_MEM_INTEGRITY 0 - -/* Check the strings. - * Search for NULL, very long strings, invalid characters, and unnatural repetitions. (Slow) - * If disabled `LV_USE_ASSERT_NULL` will be performed instead (if it's enabled) */ -#define LV_USE_ASSERT_STR 0 - -/* Check NULL, the object's type and existence (e.g. not deleted). (Quite slow) - * If disabled `LV_USE_ASSERT_NULL` will be performed instead (if it's enabled) */ -#define LV_USE_ASSERT_OBJ 0 - -/*Check if the styles are properly initialized. (Fast)*/ -#define LV_USE_ASSERT_STYLE 0 - -#endif /*LV_USE_DEBUG*/ +/*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/ +#define LV_USE_LARGE_COORD 0 /*================== - * FONT USAGE + * FONT USAGE *===================*/ -/* The built-in fonts contains the ASCII range and some Symbols with 4 bit-per-pixel. - * The symbols are available via `LV_SYMBOL_...` defines - * More info about fonts: https://docs.lvgl.io/v7/en/html/overview/font.html - * To create a new font go to: https://lvgl.com/ttf-font-to-c-array - */ - -/* Montserrat fonts with bpp = 4 - * https://fonts.google.com/specimen/Montserrat */ +/*Montserrat fonts with ASCII range and some symbols using bpp = 4 + *https://fonts.google.com/specimen/Montserrat*/ #define LV_FONT_MONTSERRAT_8 0 #define LV_FONT_MONTSERRAT_10 0 #define LV_FONT_MONTSERRAT_12 0 @@ -396,23 +290,19 @@ typedef void* lv_indev_drv_user_data_t; /*Type of user data in the in #define LV_FONT_MONTSERRAT_46 0 #define LV_FONT_MONTSERRAT_48 0 -/* Demonstrate special features */ +/*Demonstrate special features*/ #define LV_FONT_MONTSERRAT_12_SUBPX 0 #define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/ -#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, PErisan letters and all their forms*/ +#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Perisan letters and all their forms*/ #define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ -/*Pixel perfect monospace font - * http://pelulamu.net/unscii/ */ -#define LV_FONT_UNSCII_8 0 - -/* Optionally declare your custom fonts here. - * You can use these fonts as default font too - * and they will be available globally. E.g. - * #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \ - * LV_FONT_DECLARE(my_font_2) - */ +/*Pixel perfect monospace fonts*/ +#define LV_FONT_UNSCII_8 0 +#define LV_FONT_UNSCII_16 0 +/*Optionally declare custom fonts here. + *You can use these fonts as default font too and they will be available globally. + *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(jetbrains_mono_bold_20) \ LV_FONT_DECLARE(jetbrains_mono_extrabold_compressed) \ LV_FONT_DECLARE(jetbrains_mono_42) \ @@ -420,342 +310,211 @@ typedef void* lv_indev_drv_user_data_t; /*Type of user data in the in LV_FONT_DECLARE(open_sans_light) \ LV_FONT_DECLARE(lv_font_sys_48) -/* Enable it if you have fonts with a lot of characters. - * The limit depends on the font size, font face and bpp - * but with > 10,000 characters if you see issues probably you need to enable it.*/ +/*Always set a default font*/ +#define LV_FONT_DEFAULT &jetbrains_mono_bold_20 + +/*Enable handling large font and/or fonts with a lot of characters. + *The limit depends on the font size, font face and bpp. + *Compiler error will be triggered if a font needs it.*/ #define LV_FONT_FMT_TXT_LARGE 0 -/* Enables/disables support for compressed fonts. If it's disabled, compressed - * glyphs cannot be processed by the library and won't be rendered. - */ -#define LV_USE_FONT_COMPRESSED 1 +/*Enables/disables support for compressed fonts.*/ +#define LV_USE_FONT_COMPRESSED 1 -/* Enable subpixel rendering */ -#define LV_USE_FONT_SUBPX 0 +/*Enable subpixel rendering*/ +#define LV_USE_FONT_SUBPX 0 #if LV_USE_FONT_SUBPX -/* Set the pixel order of the display. - * Important only if "subpx fonts" are used. - * With "normal" font it doesn't matter. - */ -#define LV_FONT_SUBPX_BGR 0 +/*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/ +#define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ #endif -/*Declare the type of the user data of fonts (can be e.g. `void *`, `int`, `struct`)*/ -typedef void* lv_font_user_data_t; - -/*================ - * THEME USAGE - *================*/ - -/*Always enable at least on theme*/ - -/* No theme, you can apply your styles as you need - * No flags. Set LV_THEME_DEFAULT_FLAG 0 */ -#define LV_USE_THEME_EMPTY 1 - -/*Simple to the create your theme based on it - * No flags. Set LV_THEME_DEFAULT_FLAG 0 */ -#define LV_USE_THEME_TEMPLATE 0 - -/* A fast and impressive theme. - * Flags: - * LV_THEME_MATERIAL_FLAG_LIGHT: light theme - * LV_THEME_MATERIAL_FLAG_DARK: dark theme - * LV_THEME_MATERIAL_FLAG_NO_TRANSITION: disable transitions (state change animations) - * LV_THEME_MATERIAL_FLAG_NO_FOCUS: disable indication of focused state) - * */ -#define LV_USE_THEME_MATERIAL 0 - -/* Mono-color theme for monochrome displays. - * If LV_THEME_DEFAULT_COLOR_PRIMARY is LV_COLOR_BLACK the - * texts and borders will be black and the background will be - * white. Else the colors are inverted. - * No flags. Set LV_THEME_DEFAULT_FLAG 0 */ -#define LV_USE_THEME_MONO 0 - -#define LV_THEME_DEFAULT_INCLUDE /*Include a header for the init. function*/ -#define LV_THEME_DEFAULT_INIT lv_theme_empty_init//lv_theme_material_init -#define LV_THEME_DEFAULT_COLOR_PRIMARY lv_color_hex(0xffffff) -#define LV_THEME_DEFAULT_COLOR_SECONDARY lv_color_hex(0xaaaaaa) -#define LV_THEME_DEFAULT_FLAG 0//LV_THEME_MATERIAL_FLAG_DARK -#define LV_THEME_DEFAULT_FONT_SMALL &jetbrains_mono_bold_20 -#define LV_THEME_DEFAULT_FONT_NORMAL &jetbrains_mono_bold_20 -#define LV_THEME_DEFAULT_FONT_SUBTITLE &jetbrains_mono_bold_20 -#define LV_THEME_DEFAULT_FONT_TITLE &jetbrains_mono_bold_20 - /*================= - * Text settings + * TEXT SETTINGS *=================*/ -/* Select a character encoding for strings. +/** + * Select a character encoding for strings. * Your IDE or editor should have the same character encoding * - LV_TXT_ENC_UTF8 * - LV_TXT_ENC_ASCII - * */ + */ #define LV_TXT_ENC LV_TXT_ENC_UTF8 -/*Can break (wrap) texts on these chars*/ + /*Can break (wrap) texts on these chars*/ #define LV_TXT_BREAK_CHARS " ,.;:-_" -/* If a word is at least this long, will break wherever "prettiest" - * To disable, set to a value <= 0 */ +/*If a word is at least this long, will break wherever "prettiest" + *To disable, set to a value <= 0*/ #define LV_TXT_LINE_BREAK_LONG_LEN 12 -/* Minimum number of characters in a long word to put on a line before a break. - * Depends on LV_TXT_LINE_BREAK_LONG_LEN. */ +/*Minimum number of characters in a long word to put on a line before a break. + *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ #define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 -/* Minimum number of characters in a long word to put on a line after a break. - * Depends on LV_TXT_LINE_BREAK_LONG_LEN. */ +/*Minimum number of characters in a long word to put on a line after a break. + *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 -/* The control character to use for signalling text recoloring. */ +/*The control character to use for signalling text recoloring.*/ #define LV_TXT_COLOR_CMD "#" -/* Support bidirectional texts. - * Allows mixing Left-to-Right and Right-to-Left texts. - * The direction will be processed according to the Unicode Bidirectioanl Algorithm: - * https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ -#define LV_USE_BIDI 0 +/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. + *The direction will be processed according to the Unicode Bidirectioanl Algorithm: + *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ +#define LV_USE_BIDI 0 #if LV_USE_BIDI -/* Set the default direction. Supported values: - * `LV_BIDI_DIR_LTR` Left-to-Right - * `LV_BIDI_DIR_RTL` Right-to-Left - * `LV_BIDI_DIR_AUTO` detect texts base direction */ -#define LV_BIDI_BASE_DIR_DEF LV_BIDI_DIR_AUTO +/*Set the default direction. Supported values: + *`LV_BASE_DIR_LTR` Left-to-Right + *`LV_BASE_DIR_RTL` Right-to-Left + *`LV_BASE_DIR_AUTO` detect texts base direction*/ +#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO #endif -/* Enable Arabic/Persian processing - * In these languages characters should be replaced with - * an other form based on their position in the text */ +/*Enable Arabic/Persian processing + *In these languages characters should be replaced with an other form based on their position in the text*/ #define LV_USE_ARABIC_PERSIAN_CHARS 0 -/*Change the built in (v)snprintf functions*/ -#define LV_SPRINTF_CUSTOM 0 -#if LV_SPRINTF_CUSTOM -#define LV_SPRINTF_INCLUDE -#define lv_snprintf snprintf -#define lv_vsnprintf vsnprintf -#else /*!LV_SPRINTF_CUSTOM*/ -#define LV_SPRINTF_DISABLE_FLOAT 1 -#endif /*LV_SPRINTF_CUSTOM*/ +/*================== + * WIDGET USAGE + *================*/ -/*=================== - * LV_OBJ SETTINGS - *==================*/ +/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ -#if LV_USE_USER_DATA -/*Declare the type of the user data of object (can be e.g. `void *`, `int`, `struct`)*/ -typedef void* lv_obj_user_data_t; -/*Provide a function to free user data*/ -#define LV_USE_USER_DATA_FREE 0 -#if LV_USE_USER_DATA_FREE -#define LV_USER_DATA_FREE_INCLUDE "something.h" /*Header for user data free function*/ -/* Function prototype : void user_data_free(lv_obj_t * obj); */ -#define LV_USER_DATA_FREE (user_data_free) /*Invoking for user data free function*/ -#endif -#endif +#define LV_USE_ARC 1 -/*1: enable `lv_obj_realign()` based on `lv_obj_align()` parameters*/ -#define LV_USE_OBJ_REALIGN 1 +#define LV_USE_ANIMIMG 0 -/* Enable to make the object clickable on a larger area. - * LV_EXT_CLICK_AREA_OFF or 0: Disable this feature - * LV_EXT_CLICK_AREA_TINY: The extra area can be adjusted horizontally and vertically (0..255 px) - * LV_EXT_CLICK_AREA_FULL: The extra area can be adjusted in all 4 directions (-32k..+32k px) - */ -#define LV_USE_EXT_CLICK_AREA LV_EXT_CLICK_AREA_TINY +#define LV_USE_BAR 1 -/*================== - * LV OBJ X USAGE - *================*/ -/* - * Documentation of the object types: https://docs.lvgl.com/#Object-types - */ +#define LV_USE_BTN 1 -/*Arc (dependencies: -)*/ -#define LV_USE_ARC 1 +#define LV_USE_BTNMATRIX 1 -/*Bar (dependencies: -)*/ -#define LV_USE_BAR 1 +#define LV_USE_CANVAS 0 -/*Button (dependencies: lv_cont*/ -#define LV_USE_BTN 1 +#define LV_USE_CHECKBOX 1 -/*Button matrix (dependencies: -)*/ -#define LV_USE_BTNMATRIX 1 -/*Calendar (dependencies: -)*/ -#define LV_USE_CALENDAR 1 -#if LV_USE_CALENDAR -#define LV_CALENDAR_WEEK_STARTS_MONDAY 0 -#endif +#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/ -/*Canvas (dependencies: lv_img)*/ -#define LV_USE_CANVAS 0 +#define LV_USE_IMG 1 /*Requires: lv_label*/ -/*Check box (dependencies: lv_btn, lv_label)*/ -#define LV_USE_CHECKBOX 1 +#define LV_USE_LABEL 1 +#if LV_USE_LABEL +# define LV_LABEL_TEXT_SELECTION 0 /*Enable selecting text of the label*/ +# define LV_LABEL_LONG_TXT_HINT 0 /*Store some extra info in labels to speed up drawing of very long texts*/ +#endif + +#define LV_USE_LINE 1 -/*Chart (dependencies: -)*/ -#define LV_USE_CHART 1 -#if LV_USE_CHART -#define LV_CHART_AXIS_TICK_LABEL_MAX_LEN 256 +#define LV_USE_ROLLER 1 /*Requires: lv_label*/ +#if LV_USE_ROLLER +# define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/ #endif -/*Container (dependencies: -*/ -#define LV_USE_CONT 1 +#define LV_USE_SLIDER 1 /*Requires: lv_bar*/ -/*Color picker (dependencies: -*/ -#define LV_USE_CPICKER 0 +#define LV_USE_SWITCH 0 -/*Drop down list (dependencies: lv_page, lv_label, lv_symbol_def.h)*/ -#define LV_USE_DROPDOWN 1 -#if LV_USE_DROPDOWN != 0 -/*Open and close default animation time [ms] (0: no animation)*/ -#define LV_DROPDOWN_DEF_ANIM_TIME 200 +#define LV_USE_TEXTAREA 0 /*Requires: lv_label*/ +#if LV_USE_TEXTAREA != 0 +# define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ #endif -/*Gauge (dependencies:lv_bar, lv_linemeter)*/ -#define LV_USE_GAUGE 1 +#define LV_USE_TABLE 1 -/*Image (dependencies: lv_label*/ -#define LV_USE_IMG 1 +/*================== + * EXTRA COMPONENTS + *==================*/ -/*Image Button (dependencies: lv_btn*/ -#define LV_USE_IMGBTN 1 -#if LV_USE_IMGBTN -/*1: The imgbtn requires left, mid and right parts and the width can be set freely*/ -#define LV_IMGBTN_TILED 0 -#endif +/*----------- + * Widgets + *----------*/ +#define LV_USE_CALENDAR 1 +#if LV_USE_CALENDAR +# define LV_CALENDAR_WEEK_STARTS_MONDAY 0 +# if LV_CALENDAR_WEEK_STARTS_MONDAY +# define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} +# else +# define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} +# endif -/*Keyboard (dependencies: lv_btnm)*/ -#define LV_USE_KEYBOARD 0 +# define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} +# define LV_USE_CALENDAR_HEADER_ARROW 0 +# define LV_USE_CALENDAR_HEADER_DROPDOWN 0 +#endif /*LV_USE_CALENDAR*/ -/*Label (dependencies: -*/ -#define LV_USE_LABEL 1 -#if LV_USE_LABEL != 0 -/*Hor, or ver. scroll speed [px/sec] in 'LV_LABEL_LONG_ROLL/ROLL_CIRC' mode*/ -#define LV_LABEL_DEF_SCROLL_SPEED 25 +#define LV_USE_CHART 1 -/* Waiting period at beginning/end of animation cycle */ -#define LV_LABEL_WAIT_CHAR_COUNT 3 +#define LV_USE_COLORWHEEL 0 -/*Enable selecting text of the label */ -#define LV_LABEL_TEXT_SEL 0 +#define LV_USE_IMGBTN 0 -/*Store extra some info in labels (12 bytes) to speed up drawing of very long texts*/ -#define LV_LABEL_LONG_TXT_HINT 0 -#endif +#define LV_USE_KEYBOARD 0 -/*LED (dependencies: -)*/ -#define LV_USE_LED 0 -#if LV_USE_LED -#define LV_LED_BRIGHT_MIN 120 /*Minimal brightness*/ -#define LV_LED_BRIGHT_MAX 255 /*Maximal brightness*/ -#endif +#define LV_USE_LED 0 -/*Line (dependencies: -*/ -#define LV_USE_LINE 1 +#define LV_USE_LIST 1 -/*List (dependencies: lv_page, lv_btn, lv_label, (lv_img optionally for icons ))*/ -#define LV_USE_LIST 1 -#if LV_USE_LIST != 0 -/*Default animation time of focusing to a list element [ms] (0: no animation) */ -#define LV_LIST_DEF_ANIM_TIME 100 -#endif +#define LV_USE_METER 1 -/*Line meter (dependencies: *;)*/ -#define LV_USE_LINEMETER 1 -#if LV_USE_LINEMETER -/* Draw line more precisely at cost of performance. - * Useful if there are lot of lines any minor are visible - * 0: No extra precision - * 1: Some extra precision - * 2: Best precision - */ -#define LV_LINEMETER_PRECISE 0 -#endif +#define LV_USE_MSGBOX 0 -/*Mask (dependencies: -)*/ -#define LV_USE_OBJMASK 0 +#define LV_USE_SPINBOX 0 -/*Message box (dependencies: lv_rect, lv_btnm, lv_label)*/ -#define LV_USE_MSGBOX 0 +#define LV_USE_SPINNER 1 -/*Page (dependencies: lv_cont)*/ -#define LV_USE_PAGE 1 -#if LV_USE_PAGE != 0 -/*Focus default animation time [ms] (0: no animation)*/ -#define LV_PAGE_DEF_ANIM_TIME 400 -#endif +#define LV_USE_TABVIEW 0 -/*Preload (dependencies: lv_arc, lv_anim)*/ -#define LV_USE_SPINNER 0 -#if LV_USE_SPINNER != 0 -#define LV_SPINNER_DEF_ARC_LENGTH 60 /*[deg]*/ -#define LV_SPINNER_DEF_SPIN_TIME 1000 /*[ms]*/ -#define LV_SPINNER_DEF_ANIM LV_SPINNER_TYPE_SPINNING_ARC -#endif +#define LV_USE_TILEVIEW 0 -/*Roller (dependencies: lv_ddlist)*/ -#define LV_USE_ROLLER 1 -#if LV_USE_ROLLER != 0 -/*Focus animation time [ms] (0: no animation)*/ -#define LV_ROLLER_DEF_ANIM_TIME 200 +#define LV_USE_WIN 0 -/*Number of extra "pages" when the roller is infinite*/ -#define LV_ROLLER_INF_PAGES 7 +#define LV_USE_SPAN 0 +#if LV_USE_SPAN +/*A line text can contain maximum num of span descriptor */ +# define LV_SPAN_SNIPPET_STACK_SIZE 64 #endif -/*Slider (dependencies: lv_bar)*/ -#define LV_USE_SLIDER 1 +/*----------- + * Themes + *----------*/ +/*A simple, impressive and very complete theme*/ +#define LV_USE_THEME_DEFAULT 1 +#if LV_USE_THEME_DEFAULT -/*Spinbox (dependencies: lv_ta)*/ -#define LV_USE_SPINBOX 0 +/*0: Light mode; 1: Dark mode*/ +# define LV_THEME_DEFAULT_DARK 0 -/*Switch (dependencies: lv_slider)*/ -#define LV_USE_SWITCH 1 +/*1: Enable grow on press*/ +# define LV_THEME_DEFAULT_GROW 0 -/*Text area (dependencies: lv_label, lv_page)*/ -#define LV_USE_TEXTAREA 1 -#if LV_USE_TEXTAREA != 0 -#define LV_TEXTAREA_DEF_CURSOR_BLINK_TIME 400 /*ms*/ -#define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ -#endif +/*Default transition time in [ms]*/ +# define LV_THEME_DEFAULT_TRANSITON_TIME 80 +#endif /*LV_USE_THEME_DEFAULT*/ -/*Table (dependencies: lv_label)*/ -#define LV_USE_TABLE 1 -#if LV_USE_TABLE -#define LV_TABLE_COL_MAX 12 -#define LV_TABLE_CELL_STYLE_CNT 5 -#endif +/*An very simple them that is a good starting point for a custom theme*/ + #define LV_USE_THEME_BASIC 0 +/*A theme designed for monochrome displays*/ +#define LV_USE_THEME_MONO 0 -/*Tab (dependencies: lv_page, lv_btnm)*/ -#define LV_USE_TABVIEW 0 -# if LV_USE_TABVIEW != 0 -/*Time of slide animation [ms] (0: no animation)*/ -#define LV_TABVIEW_DEF_ANIM_TIME 300 -#endif +/*----------- + * Layouts + *----------*/ -/*Tileview (dependencies: lv_page) */ -#define LV_USE_TILEVIEW 0 -#if LV_USE_TILEVIEW -/*Time of slide animation [ms] (0: no animation)*/ -#define LV_TILEVIEW_DEF_ANIM_TIME 300 -#endif +/*A layout similar to Flexbox in CSS.*/ +#define LV_USE_FLEX 1 -/*Window (dependencies: lv_cont, lv_btn, lv_label, lv_img, lv_page)*/ -#define LV_USE_WIN 0 +/*A layout similar to Grid in CSS.*/ +#define LV_USE_GRID 0 /*================== - * Non-user section - *==================*/ +* EXAMPLES +*==================*/ -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) /* Disable warnings for Visual Studio*/ -#define _CRT_SECURE_NO_WARNINGS -#endif +/*Enable the examples to be built with the library*/ +#define LV_BUILD_EXAMPLES 0 /*--END OF LV_CONF_H--*/ diff --git a/src/rtoshook.c b/src/rtoshook.c new file mode 100644 index 0000000000..7860b9eb62 --- /dev/null +++ b/src/rtoshook.c @@ -0,0 +1,15 @@ +// +// Created by robert on 10/7/21. +// + +#include +#include "task.h" +#include "stack_macros.h" + +void vApplicationStackOverflowHook(xTaskHandle *pxTask, signed char *pcTaskName ) +{ + xTaskHandle *bad_task_handle = pxTask; // pointer to crashed task handle + signed char *bad_task_name = pcTaskName; // pointer to the name of the crashed task + + for( ;; ); +} From df7a417d39c5faddd5d0c7f91cc0ef31ffcf6260 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Fri, 8 Oct 2021 14:21:42 -0400 Subject: [PATCH 03/25] This variable goes out of scope after the init, but its reference is kept in an lv_indev object in the lv_indev_ll. Store it as a member variable to keep it alive. --- src/displayapp/LittleVgl.cpp | 2 -- src/displayapp/LittleVgl.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index 2bd5e57be7..b287bb61f7 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -54,8 +54,6 @@ void LittleVgl::InitDisplay() { } void LittleVgl::InitTouchpad() { - lv_indev_drv_t indev_drv; - lv_indev_drv_init(&indev_drv); indev_drv.type = LV_INDEV_TYPE_POINTER; indev_drv.read_cb = touchpad_read; diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index 1f8a3d79f0..83b721579c 100644 --- a/src/displayapp/LittleVgl.h +++ b/src/displayapp/LittleVgl.h @@ -38,6 +38,7 @@ namespace Pinetime { lv_color_t buf2_1[LV_HOR_RES_MAX * 4]; lv_color_t buf2_2[LV_HOR_RES_MAX * 4]; + lv_indev_drv_t indev_drv; lv_disp_drv_t disp_drv; lv_point_t previousClick; From 12d985a87e0db449a63cabd8d1a4dc198b893e23 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Fri, 8 Oct 2021 14:40:28 -0400 Subject: [PATCH 04/25] Found the same issue with fs_drv. --- src/components/fs/FS.cpp | 2 -- src/components/fs/FS.h | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/fs/FS.cpp b/src/components/fs/FS.cpp index 857e6bf93d..7118e4462d 100644 --- a/src/components/fs/FS.cpp +++ b/src/components/fs/FS.cpp @@ -179,8 +179,6 @@ namespace { } void FS::LVGLFileSystemInit() { - - lv_fs_drv_t fs_drv; lv_fs_drv_init(&fs_drv); fs_drv.file_size = sizeof(lfs_file_t); diff --git a/src/components/fs/FS.h b/src/components/fs/FS.h index 75ba16c813..bf298c7867 100644 --- a/src/components/fs/FS.h +++ b/src/components/fs/FS.h @@ -3,6 +3,7 @@ #include #include "drivers/SpiNorFlash.h" #include +#include namespace Pinetime { namespace Controllers { @@ -55,7 +56,9 @@ namespace Pinetime { static constexpr size_t startAddress = 0x0B4000; static constexpr size_t size = 0x34C000; static constexpr size_t blockSize = 4096; - + + lv_fs_drv_t fs_drv; + bool resourcesValid = false; const struct lfs_config lfsConfig; From 15bd632742ea460d5fd527fb0c05d694e269075e Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Fri, 8 Oct 2021 17:26:59 -0400 Subject: [PATCH 05/25] Fixes for List and Tile screen event handlers --- src/displayapp/screens/List.cpp | 2 +- src/displayapp/screens/Tile.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/displayapp/screens/List.cpp b/src/displayapp/screens/List.cpp index 7fad1eb860..c1e6b041a6 100644 --- a/src/displayapp/screens/List.cpp +++ b/src/displayapp/screens/List.cpp @@ -71,6 +71,7 @@ List::List(uint8_t screenID, if (applications[i].application != Apps::None) { itemApps[i] = lv_btn_create(container1); + itemApps[i]->user_data = this; lv_obj_set_style_bg_opa(itemApps[i], LV_OPA_20, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(itemApps[i], 57, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(itemApps[i], lv_color_hex(0x00FFFF), LV_PART_MAIN | LV_STATE_DEFAULT); @@ -81,7 +82,6 @@ List::List(uint8_t screenID, lv_obj_set_layout(itemApps[i], LV_LAYOUT_FLEX); lv_obj_set_flex_flow(itemApps[i], LV_FLEX_FLOW_ROW); lv_obj_set_flex_align(itemApps[i], LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START); - itemApps[i]->user_data = this; labelBtIco = lv_label_create(itemApps[i]); lv_obj_set_style_text_color(labelBtIco, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_MAIN | LV_STATE_DEFAULT); diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index 739354f0be..5e7987e1ea 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -14,8 +14,9 @@ namespace { if (lv_event_get_code(event) != LV_EVENT_VALUE_CHANGED) return; Tile* screen = static_cast(lv_event_get_user_data(event)); - uint32_t btnId= reinterpret_cast(lv_event_get_param(event)); - screen->OnValueChangedEvent(lv_event_get_target(event), btnId); + lv_obj_t *obj = lv_event_get_target(event); + uint32_t btnId= lv_btnmatrix_get_selected_btn(obj); + screen->OnValueChangedEvent(obj, btnId); } } From 23d8b2cc17b76ff69731d02aa535a47b4fc1a037 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Sat, 9 Oct 2021 14:07:12 -0400 Subject: [PATCH 06/25] Port pinetime theme --- src/CMakeLists.txt | 5 +- src/displayapp/LittleVgl.cpp | 17 +- src/displayapp/lv_pinetime_theme.c | 1379 ++++++----------- src/displayapp/lv_pinetime_theme.h | 3 +- .../screens/settings/SettingDisplay.cpp | 2 +- src/libs/lv_conf.h | 4 +- 6 files changed, 464 insertions(+), 946 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b90aec6983..ab7d016ddb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -338,8 +338,7 @@ set(LVGL_SRC libs/lvgl/src/misc/lv_utils.c libs/lvgl/src/core/lv_theme.c libs/lvgl/src/extra/lv_extra.c - libs/lvgl/src/extra/themes/lv_themes.h - libs/lvgl/src/extra/themes/basic/lv_theme_basic.h + libs/lvgl/src/extra/themes/basic/lv_theme_basic.c #libs/lvgl/src/lv_themes/lv_theme_mono.c #libs/lvgl/src/lv_themes/lv_theme_template.c libs/lvgl/src/widgets/lv_arc.c @@ -800,7 +799,7 @@ add_definitions(-DNIMBLE_CFG_CONTROLLER) add_definitions(-DOS_CPUTIME_FREQ) add_definitions(-DNRF52 -DNRF52832 -DNRF52832_XXAA -DNRF52_PAN_74 -DNRF52_PAN_64 -DNRF52_PAN_12 -DNRF52_PAN_58 -DNRF52_PAN_54 -DNRF52_PAN_31 -DNRF52_PAN_51 -DNRF52_PAN_36 -DNRF52_PAN_15 -DNRF52_PAN_20 -DNRF52_PAN_55 -DBOARD_PCA10040) add_definitions(-DFREERTOS) -add_definitions(-D__STACK_SIZE=1024) +add_definitions(-D__STACK_SIZE=2048) add_definitions(-D__HEAP_SIZE=4096) # NOTE : Add the following defines to enable debug mode of the NRF SDK: diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index 7fa80273fc..f337a16e35 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -29,8 +29,8 @@ LittleVgl::LittleVgl(Pinetime::Drivers::St7789& lcd, Pinetime::Drivers::Cst816S& void LittleVgl::Init() { lv_init(); - InitTheme(); InitDisplay(); + InitTheme(); InitTouchpad(); } @@ -185,15 +185,8 @@ bool LittleVgl::GetTouchPadInfo(lv_indev_data_t* ptr) { } void LittleVgl::InitTheme() { - -// lv_theme_t* th = lv_pinetime_theme_init( -// lv_color_white(), lv_color_hex(0xC0C0C0), 0, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20, &jetbrains_mono_bold_20); - - lv_theme_t* th = lv_pinetime_theme_init(lv_disp_get_default(), - lv_color_white(), - lv_color_hex(0xC0C0C0), - 0, - &jetbrains_mono_bold_20); - - lv_disp_set_theme(lv_disp_get_default(), th); + if (!lv_pinetime_theme_is_inited()) { + lv_theme_t* th = lv_pinetime_theme_init(lv_disp_get_default(), lv_color_white(), lv_color_hex(0xC0C0C0), &jetbrains_mono_bold_20); + lv_disp_set_theme(lv_disp_get_default(), th); + } } diff --git a/src/displayapp/lv_pinetime_theme.c b/src/displayapp/lv_pinetime_theme.c index 9a257594a9..e0c71dd81d 100644 --- a/src/displayapp/lv_pinetime_theme.c +++ b/src/displayapp/lv_pinetime_theme.c @@ -1,178 +1,87 @@ /** - * @file lv_theme_defau.c + * @file lv_pinetime_theme.c * */ /********************* * INCLUDES *********************/ -#include +#include /*To see all the widgets*/ -#if LV_USE_THEME_DEFAULT +#if LV_USE_THEME_PINETIME #include "lv_pinetime_theme.h" +//#include "../../../misc/lv_gc.h" #include /********************* * DEFINES *********************/ -#define MODE_DARK 1 -#define RADIUS_DEFAULT (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8)) - -/*SCREEN*/ -#define LIGHT_COLOR_SCR lv_palette_lighten(LV_PALETTE_GREY, 4) -#define LIGHT_COLOR_CARD lv_color_white() -#define LIGHT_COLOR_TEXT lv_palette_darken(LV_PALETTE_GREY, 4) -#define LIGHT_COLOR_GREY lv_palette_lighten(LV_PALETTE_GREY, 2) -#define DARK_COLOR_SCR lv_color_hex(0x15171A) -#define DARK_COLOR_CARD lv_color_hex(0x282b30) -#define DARK_COLOR_TEXT lv_palette_lighten(LV_PALETTE_GREY, 5) -#define DARK_COLOR_GREY lv_color_hex(0x2f3237) - -#define TRANSITION_TIME LV_THEME_DEFAULT_TRANSITON_TIME -#define BORDER_WIDTH lv_disp_dpx(theme.disp, 2) -#define OUTLINE_WIDTH lv_disp_dpx(theme.disp, 3) - -#define PAD_DEF (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 24) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 20) : lv_disp_dpx(theme.disp, 16)) -#define PAD_SMALL (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 14) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 10)) -#define PAD_TINY (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 8) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 6) : lv_disp_dpx(theme.disp, 2)) + +#define COLOR_WHITE lv_color_white() +#define COLOR_BLACK lv_color_black() +#define COLOR_LIGHT lv_palette_lighten(LV_PALETTE_GREY, 3) +#define COLOR_MID lv_palette_lighten(LV_PALETTE_GREY, 1) +#define COLOR_DARK COLOR_BLACK +//#define COLOR_DARK lv_palette_main(LV_PALETTE_GREY) +#define COLOR_DIM lv_palette_darken(LV_PALETTE_GREY, 2) +#define PAD_DEF LV_DPX(5) +#define RADIUS_ROUND 10 /********************** * TYPEDEFS **********************/ -typedef struct { - lv_style_t scr; - lv_style_t scrollbar; - lv_style_t scrollbar_scrolled; - lv_style_t card; - lv_style_t btn; - - /*Utility*/ - lv_style_t bg_color_primary; - lv_style_t bg_color_primary_muted; - lv_style_t bg_color_secondary; - lv_style_t bg_color_secondary_muted; - lv_style_t bg_color_grey; - lv_style_t bg_color_white; - lv_style_t pressed; - lv_style_t disabled; - lv_style_t pad_zero; - lv_style_t pad_tiny; - lv_style_t pad_small; - lv_style_t pad_normal; - lv_style_t pad_gap; - lv_style_t line_space_large; - lv_style_t text_align_center; - lv_style_t outline_primary; - lv_style_t outline_secondary; - lv_style_t circle; - lv_style_t no_radius; - lv_style_t clip_corner; -#if LV_THEME_DEFAULT_GROW - lv_style_t grow; -#endif - lv_style_t transition_delayed; - lv_style_t transition_normal; - lv_style_t anim; - - /*Parts*/ - lv_style_t knob; - lv_style_t indic; - -#if LV_USE_ARC - lv_style_t arc_indic; - lv_style_t arc_indic_primary; -#endif - -#if LV_USE_CHART - lv_style_t chart_series, chart_indic, chart_ticks, chart_bg; -#endif - -#if LV_USE_DROPDOWN - lv_style_t dropdown_list; -#endif - -#if LV_USE_CHECKBOX - lv_style_t cb_marker, cb_marker_checked; -#endif - -#if LV_USE_SWITCH - lv_style_t switch_knob; -#endif - -#if LV_USE_LINE - lv_style_t line; -#endif - -#if LV_USE_TABLE - lv_style_t table_cell; -#endif - -#if LV_USE_METER - lv_style_t meter_marker, meter_indic; -#endif - -#if LV_USE_TEXTAREA - lv_style_t ta_cursor, ta_placeholder; -#endif - -#if LV_USE_CALENDAR - lv_style_t calendar_bg, calendar_day; -#endif - -#if LV_USE_COLORWHEEL - lv_style_t colorwheel_main; -#endif - -#if LV_USE_MSGBOX - lv_style_t msgbox_bg, msgbox_btn_bg; -#endif - -#if LV_USE_KEYBOARD - lv_style_t keyboard_btn_bg; -#endif - -#if LV_USE_LIST - lv_style_t list_bg, list_btn, list_item_grow, list_label; -#endif - -#if LV_USE_TABVIEW - lv_style_t tab_bg_focus, tab_btn; -#endif -#if LV_USE_LED - lv_style_t led; -#endif -} my_theme_styles_t; - -typedef struct { - lv_theme_t base; - uint8_t light :1; -}my_theme_t; - -typedef enum { - DISP_SMALL = 3, - DISP_MEDIUM = 2, - DISP_LARGE = 1, -}disp_size_t; /********************** * STATIC PROTOTYPES **********************/ -static void theme_apply(lv_theme_t * th, lv_obj_t * obj); static void style_init_reset(lv_style_t * style); +static void theme_apply(lv_theme_t * th, lv_obj_t * obj); /********************** * STATIC VARIABLES **********************/ -static my_theme_styles_t * styles; static lv_theme_t theme; -static disp_size_t disp_size; -static bool inited; -static lv_color_t color_scr; -static lv_color_t color_text; -static lv_color_t color_card; -static lv_color_t color_grey; +static lv_style_t style_pad; +static lv_style_t style_circle; + +static lv_style_t style_bg; +static lv_style_t style_box; +static lv_style_t style_box_border; +static lv_style_t style_btn; +static lv_style_t style_btn_checked; +static lv_style_t style_btn_disabled; +static lv_style_t style_btn_disabled_checked; +static lv_style_t style_btn_border; +static lv_style_t style_label_white; +static lv_style_t style_icon; +static lv_style_t style_bar_indic; +static lv_style_t style_slider_knob; +static lv_style_t style_slider_knob_pressed; +static lv_style_t style_scrollbar; +static lv_style_t style_list_btn; +static lv_style_t style_list_btn_checked; +static lv_style_t style_list_btn_checked_pressed; +static lv_style_t style_ddlist_list; +static lv_style_t style_ddlist_selected; +static lv_style_t style_sw_bg; +static lv_style_t style_sw_indic; +static lv_style_t style_sw_knob; +static lv_style_t style_arc_bg; +static lv_style_t style_arc_knob; +static lv_style_t style_arc_indic; +static lv_style_t style_table_cell; +static lv_style_t style_pad_small; +static lv_style_t style_bg_grad; +static lv_style_t style_lmeter; +static lv_style_t style_chart_series; +static lv_style_t style_cb_bg; +static lv_style_t style_cb_bullet; +static lv_style_t style_cb_bullet_focused; +static lv_style_t style_cb_bullet_checked; + +static bool inited; /********************** * MACROS @@ -182,419 +91,279 @@ static lv_color_t color_grey; * STATIC FUNCTIONS **********************/ +//static lv_color_t dark_color_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t c, lv_opa_t opa) +//{ +// LV_UNUSED(f); +// return lv_color_darken(c, opa); +//} -static lv_color_t dark_color_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t c, lv_opa_t opa) -{ - LV_UNUSED(f); - return lv_color_darken(c, opa); -} -static lv_color_t grey_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t color, lv_opa_t opa) -{ - LV_UNUSED(f); - if(theme.flags & MODE_DARK) return lv_color_mix(lv_palette_darken(LV_PALETTE_GREY, 2), color, opa); - else return lv_color_mix(lv_palette_lighten(LV_PALETTE_GREY, 2), color, opa); -} +//static lv_color_t grey_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t color, lv_opa_t opa) +//{ +// LV_UNUSED(f); +// return lv_color_mix(lv_color_white(), color, opa); +//} -lv_theme_t * lv_pinetime_theme_init(lv_disp_t* disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t* font) +static void style_init(void) { - static const lv_style_prop_t trans_props[] = { - LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR, - LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT, - LV_STYLE_TRANSLATE_Y, LV_STYLE_TRANSLATE_X, - LV_STYLE_TRANSFORM_ZOOM, LV_STYLE_TRANSFORM_ANGLE, - LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_DSC, - 0 - }; - - color_scr = theme.flags & MODE_DARK ? DARK_COLOR_SCR : LIGHT_COLOR_SCR; - color_text = theme.flags & MODE_DARK ? DARK_COLOR_TEXT : LIGHT_COLOR_TEXT; - color_card = theme.flags & MODE_DARK ? DARK_COLOR_CARD : LIGHT_COLOR_CARD; - color_grey = theme.flags & MODE_DARK ? DARK_COLOR_GREY : LIGHT_COLOR_GREY; - - static lv_style_transition_dsc_t trans_delayed; - lv_style_transition_dsc_init(&trans_delayed, trans_props, lv_anim_path_linear, TRANSITION_TIME, 70, NULL); - - static lv_style_transition_dsc_t trans_normal; - lv_style_transition_dsc_init(&trans_normal, trans_props, lv_anim_path_linear, TRANSITION_TIME, 0, NULL); - - style_init_reset(&styles->transition_delayed); - lv_style_set_transition(&styles->transition_delayed, &trans_delayed); /*Go back to default state with delay*/ - - style_init_reset(&styles->transition_normal); - lv_style_set_transition(&styles->transition_normal, &trans_normal); /*Go back to default state with delay*/ - - style_init_reset(&styles->scrollbar); - lv_style_set_bg_color(&styles->scrollbar, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, 2) : lv_palette_main(LV_PALETTE_GREY)); - lv_style_set_radius(&styles->scrollbar, LV_RADIUS_CIRCLE); - lv_style_set_pad_right(&styles->scrollbar, lv_disp_dpx(theme.disp, 7)); - lv_style_set_pad_top(&styles->scrollbar, lv_disp_dpx(theme.disp, 7)); - lv_style_set_size(&styles->scrollbar, lv_disp_dpx(theme.disp, 5)); - lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_40); - lv_style_set_transition(&styles->scrollbar, &trans_normal); - - style_init_reset(&styles->scrollbar_scrolled); - lv_style_set_bg_opa(&styles->scrollbar_scrolled, LV_OPA_COVER); - - style_init_reset(&styles->scr); - lv_style_set_bg_opa(&styles->scr, LV_OPA_COVER); - lv_style_set_bg_color(&styles->scr, color_scr); - lv_style_set_text_color(&styles->scr, color_text); - lv_style_set_pad_row(&styles->scr, PAD_SMALL); - lv_style_set_pad_column(&styles->scr, PAD_SMALL); - - style_init_reset(&styles->card); - lv_style_set_radius(&styles->card, RADIUS_DEFAULT); - lv_style_set_bg_opa(&styles->card, LV_OPA_COVER); - lv_style_set_bg_color(&styles->card, color_card); - lv_style_set_border_color(&styles->card, color_grey); - lv_style_set_border_width(&styles->card, BORDER_WIDTH); - lv_style_set_border_post(&styles->card, true); - lv_style_set_text_color(&styles->card, color_text); - lv_style_set_pad_all(&styles->card, PAD_DEF); - lv_style_set_pad_row(&styles->card, PAD_SMALL); - lv_style_set_pad_column(&styles->card, PAD_SMALL); - lv_style_set_line_color(&styles->card, lv_palette_main(LV_PALETTE_GREY)); - lv_style_set_line_width(&styles->card, lv_disp_dpx(theme.disp, 1)); - - style_init_reset(&styles->outline_primary); - lv_style_set_outline_color(&styles->outline_primary, theme.color_primary); - lv_style_set_outline_width(&styles->outline_primary, OUTLINE_WIDTH); - lv_style_set_outline_pad(&styles->outline_primary, OUTLINE_WIDTH); - lv_style_set_outline_opa(&styles->outline_primary, LV_OPA_50); - - style_init_reset(&styles->outline_secondary); - lv_style_set_outline_color(&styles->outline_secondary, theme.color_secondary); - lv_style_set_outline_width(&styles->outline_secondary, OUTLINE_WIDTH); - lv_style_set_outline_opa(&styles->outline_secondary, LV_OPA_50); - - style_init_reset(&styles->btn); - lv_style_set_radius(&styles->btn, (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 16) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8))); - lv_style_set_bg_opa(&styles->btn, LV_OPA_COVER); - lv_style_set_bg_color(&styles->btn, color_grey); - if(!(theme.flags & MODE_DARK)) { - lv_style_set_shadow_color(&styles->btn, lv_palette_lighten(LV_PALETTE_GREY, 3)); - lv_style_set_shadow_width(&styles->btn, 1); - lv_style_set_shadow_ofs_y(&styles->btn, lv_disp_dpx(theme.disp, 4)); - } - lv_style_set_text_color(&styles->btn, color_text); - lv_style_set_pad_hor(&styles->btn, PAD_DEF); - lv_style_set_pad_ver(&styles->btn, PAD_SMALL); - lv_style_set_pad_column(&styles->btn, lv_disp_dpx(theme.disp, 5)); - lv_style_set_pad_row(&styles->btn, lv_disp_dpx(theme.disp, 5)); - - static lv_color_filter_dsc_t dark_filter; - lv_color_filter_dsc_init(&dark_filter, dark_color_filter_cb); - - static lv_color_filter_dsc_t grey_filter; - lv_color_filter_dsc_init(&grey_filter, grey_filter_cb); - - style_init_reset(&styles->pressed); - lv_style_set_color_filter_dsc(&styles->pressed, &dark_filter); - lv_style_set_color_filter_opa(&styles->pressed, 35); - - style_init_reset(&styles->disabled); - lv_style_set_color_filter_dsc(&styles->disabled, &grey_filter); - lv_style_set_color_filter_opa(&styles->disabled, LV_OPA_50); - - style_init_reset(&styles->clip_corner); - lv_style_set_clip_corner(&styles->clip_corner, true); - - style_init_reset(&styles->pad_normal); - lv_style_set_pad_all(&styles->pad_normal, PAD_DEF); - lv_style_set_pad_row(&styles->pad_normal, PAD_DEF); - lv_style_set_pad_column(&styles->pad_normal, PAD_DEF); - - style_init_reset(&styles->pad_small); - lv_style_set_pad_all(&styles->pad_small, PAD_SMALL); - lv_style_set_pad_gap(&styles->pad_small, PAD_SMALL); - - style_init_reset(&styles->pad_gap); - lv_style_set_pad_row(&styles->pad_gap, lv_disp_dpx(theme.disp, 10)); - lv_style_set_pad_column(&styles->pad_gap, lv_disp_dpx(theme.disp, 10)); - - style_init_reset(&styles->line_space_large); - lv_style_set_text_line_space(&styles->line_space_large, lv_disp_dpx(theme.disp, 20)); - - style_init_reset(&styles->text_align_center); - lv_style_set_text_align(&styles->text_align_center, LV_TEXT_ALIGN_CENTER); - - style_init_reset(&styles->pad_zero); - lv_style_set_pad_all(&styles->pad_zero, 0); - lv_style_set_pad_row(&styles->pad_zero, 0); - lv_style_set_pad_column(&styles->pad_zero, 0); - - style_init_reset(&styles->pad_tiny); - lv_style_set_pad_all(&styles->pad_tiny, PAD_TINY); - lv_style_set_pad_row(&styles->pad_tiny, PAD_TINY); - lv_style_set_pad_column(&styles->pad_tiny, PAD_TINY); - - style_init_reset(&styles->bg_color_primary); - lv_style_set_bg_color(&styles->bg_color_primary, theme.color_primary); - lv_style_set_text_color(&styles->bg_color_primary, lv_color_white()); - lv_style_set_bg_opa(&styles->bg_color_primary, LV_OPA_COVER); - - style_init_reset(&styles->bg_color_primary_muted); - lv_style_set_bg_color(&styles->bg_color_primary_muted, theme.color_primary); - lv_style_set_text_color(&styles->bg_color_primary_muted, theme.color_primary); - lv_style_set_bg_opa(&styles->bg_color_primary_muted, LV_OPA_20); - - style_init_reset(&styles->bg_color_secondary); - lv_style_set_bg_color(&styles->bg_color_secondary, theme.color_secondary); - lv_style_set_text_color(&styles->bg_color_secondary, lv_color_white()); - lv_style_set_bg_opa(&styles->bg_color_secondary, LV_OPA_COVER); - - style_init_reset(&styles->bg_color_secondary_muted); - lv_style_set_bg_color(&styles->bg_color_secondary_muted, theme.color_secondary); - lv_style_set_text_color(&styles->bg_color_secondary_muted, theme.color_secondary); - lv_style_set_bg_opa(&styles->bg_color_secondary_muted, LV_OPA_20); - - style_init_reset(&styles->bg_color_grey); - lv_style_set_bg_color(&styles->bg_color_grey, color_grey); - lv_style_set_bg_opa(&styles->bg_color_grey, LV_OPA_COVER); - lv_style_set_text_color(&styles->bg_color_grey, color_text); - - style_init_reset(&styles->bg_color_white); - lv_style_set_bg_color(&styles->bg_color_white, color_card); - lv_style_set_bg_opa(&styles->bg_color_white, LV_OPA_COVER); - lv_style_set_text_color(&styles->bg_color_white, color_text); - - style_init_reset(&styles->circle); - lv_style_set_radius(&styles->circle, LV_RADIUS_CIRCLE); - - style_init_reset(&styles->no_radius); - lv_style_set_radius(&styles->no_radius, 0); - -#if LV_THEME_DEFAULT_GROW - style_init_reset(&styles->grow); - lv_style_set_transform_width(&styles->grow, lv_disp_dpx(theme.disp, 3)); - lv_style_set_transform_height(&styles->grow, lv_disp_dpx(theme.disp, 3)); -#endif - - style_init_reset(&styles->knob); - lv_style_set_bg_color(&styles->knob, theme.color_primary); - lv_style_set_bg_opa(&styles->knob, LV_OPA_COVER); - lv_style_set_pad_all(&styles->knob, lv_disp_dpx(theme.disp, 6)); - lv_style_set_radius(&styles->knob, LV_RADIUS_CIRCLE); - - style_init_reset(&styles->anim); - lv_style_set_anim_time(&styles->anim, 200); - -#if LV_USE_ARC - style_init_reset(&styles->arc_indic); - lv_style_set_arc_color(&styles->arc_indic, color_grey); - lv_style_set_arc_width(&styles->arc_indic, lv_disp_dpx(theme.disp, 15)); - lv_style_set_arc_rounded(&styles->arc_indic, true); - - style_init_reset(&styles->arc_indic_primary); - lv_style_set_arc_color(&styles->arc_indic_primary, theme.color_primary); -#endif - -#if LV_USE_DROPDOWN - style_init_reset(&styles->dropdown_list); - lv_style_set_max_height(&styles->dropdown_list, LV_DPI_DEF * 2); -#endif -#if LV_USE_CHECKBOX - style_init_reset(&styles->cb_marker); - lv_style_set_pad_all(&styles->cb_marker, lv_disp_dpx(theme.disp, 3)); - lv_style_set_border_width(&styles->cb_marker, BORDER_WIDTH); - lv_style_set_border_color(&styles->cb_marker, theme.color_primary); - lv_style_set_bg_color(&styles->cb_marker, color_card); - lv_style_set_bg_opa(&styles->cb_marker, LV_OPA_COVER); - lv_style_set_radius(&styles->cb_marker, RADIUS_DEFAULT / 2); - - style_init_reset(&styles->cb_marker_checked); - lv_style_set_bg_img_src(&styles->cb_marker_checked, LV_SYMBOL_OK); - lv_style_set_text_color(&styles->cb_marker_checked, lv_color_white()); - lv_style_set_text_font(&styles->cb_marker_checked, theme.font_small); -#endif - -#if LV_USE_SWITCH - style_init_reset(&styles->switch_knob); - lv_style_set_pad_all(&styles->switch_knob, - lv_disp_dpx(theme.disp, 4)); - lv_style_set_bg_color(&styles->switch_knob, lv_color_white()); -#endif - -#if LV_USE_LINE - style_init_reset(&styles->line); - lv_style_set_line_width(&styles->line, 1); - lv_style_set_line_color(&styles->line, color_text); -#endif - -#if LV_USE_CHART - style_init_reset(&styles->chart_bg); - lv_style_set_border_post(&styles->chart_bg, false); - lv_style_set_pad_column(&styles->chart_bg, lv_disp_dpx(theme.disp, 10)); - lv_style_set_line_color(&styles->chart_bg, color_grey); - - style_init_reset(&styles->chart_series); - lv_style_set_line_width(&styles->chart_series, lv_disp_dpx(theme.disp, 3)); - lv_style_set_radius(&styles->chart_series, lv_disp_dpx(theme.disp, 3)); - lv_style_set_size(&styles->chart_series, lv_disp_dpx(theme.disp, 8)); - lv_style_set_pad_column(&styles->chart_series, lv_disp_dpx(theme.disp, 2)); - - style_init_reset(&styles->chart_indic); - lv_style_set_radius(&styles->chart_indic,LV_RADIUS_CIRCLE); - lv_style_set_size(&styles->chart_indic, lv_disp_dpx(theme.disp, 8)); - lv_style_set_bg_color(&styles->chart_indic, theme.color_primary); - lv_style_set_bg_opa(&styles->chart_indic, LV_OPA_COVER); - - style_init_reset(&styles->chart_ticks); - lv_style_set_line_width(&styles->chart_ticks, lv_disp_dpx(theme.disp, 1)); - lv_style_set_line_color(&styles->chart_ticks, color_text); - lv_style_set_pad_all(&styles->chart_ticks, lv_disp_dpx(theme.disp, 2)); - lv_style_set_text_color(&styles->chart_ticks, lv_palette_main(LV_PALETTE_GREY)); -#endif - -#if LV_USE_METER - style_init_reset(&styles->meter_marker); - lv_style_set_line_width(&styles->meter_marker, lv_disp_dpx(theme.disp, 5)); - lv_style_set_line_color(&styles->meter_marker, color_text); - lv_style_set_size(&styles->meter_marker, lv_disp_dpx(theme.disp, 20)); - lv_style_set_pad_left(&styles->meter_marker, lv_disp_dpx(theme.disp, 15)); - - style_init_reset(&styles->meter_indic); - lv_style_set_radius(&styles->meter_indic, LV_RADIUS_CIRCLE); - lv_style_set_bg_color(&styles->meter_indic, color_text); - lv_style_set_bg_opa(&styles->meter_indic, LV_OPA_COVER); - lv_style_set_size(&styles->meter_indic, lv_disp_dpx(theme.disp, 15)); -#endif - -#if LV_USE_TABLE - style_init_reset(&styles->table_cell); - lv_style_set_border_width(&styles->table_cell, lv_disp_dpx(theme.disp, 1)); - lv_style_set_border_color(&styles->table_cell, color_grey); - lv_style_set_border_side(&styles->table_cell, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM ); -#endif - -#if LV_USE_TEXTAREA - style_init_reset(&styles->ta_cursor); - lv_style_set_border_color(&styles->ta_cursor, color_text); - lv_style_set_border_width(&styles->ta_cursor, lv_disp_dpx(theme.disp, 2)); - lv_style_set_pad_left(&styles->ta_cursor, lv_disp_dpx(theme.disp, 1)); - lv_style_set_border_side(&styles->ta_cursor, LV_BORDER_SIDE_LEFT); - lv_style_set_anim_time(&styles->ta_cursor, 400); - - style_init_reset(&styles->ta_placeholder); - lv_style_set_text_color(&styles->ta_placeholder, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, 2) : lv_palette_lighten(LV_PALETTE_GREY, 1)); -#endif - -#if LV_USE_CALENDAR - style_init_reset(&styles->calendar_bg); - lv_style_set_pad_all(&styles->calendar_bg, PAD_SMALL); - lv_style_set_pad_gap(&styles->calendar_bg, PAD_SMALL / 2); - lv_style_set_radius(&styles->calendar_bg, 0); - - style_init_reset(&styles->calendar_day); - lv_style_set_border_width(&styles->calendar_day, lv_disp_dpx(theme.disp, 1)); - lv_style_set_border_color(&styles->calendar_day, color_grey); - lv_style_set_bg_color(&styles->calendar_day, color_card); - lv_style_set_bg_opa(&styles->calendar_day, LV_OPA_20); -#endif - -#if LV_USE_COLORWHEEL - style_init_reset(&styles->colorwheel_main); - lv_style_set_arc_width(&styles->colorwheel_main, lv_disp_dpx(theme.disp, 10)); -#endif - -#if LV_USE_MSGBOX - /*To add space for for the button shadow*/ - style_init_reset(&styles->msgbox_btn_bg); - lv_style_set_pad_all(&styles->msgbox_btn_bg, lv_disp_dpx(theme.disp, 4)); - - style_init_reset(&styles->msgbox_bg); - lv_style_set_max_width(&styles->msgbox_bg, lv_pct(100)); -#endif -#if LV_USE_KEYBOARD - style_init_reset(&styles->keyboard_btn_bg); - lv_style_set_shadow_width(&styles->keyboard_btn_bg, 0); - lv_style_set_radius(&styles->keyboard_btn_bg, disp_size == DISP_SMALL ? RADIUS_DEFAULT / 2 : RADIUS_DEFAULT); -#endif - -#if LV_USE_TABVIEW - style_init_reset(&styles->tab_btn); - lv_style_set_border_color(&styles->tab_btn, theme.color_primary); - lv_style_set_border_width(&styles->tab_btn, BORDER_WIDTH * 2); - lv_style_set_border_side(&styles->tab_btn, LV_BORDER_SIDE_BOTTOM); - - style_init_reset(&styles->tab_bg_focus); - lv_style_set_outline_pad(&styles->tab_bg_focus, -BORDER_WIDTH); -#endif - -#if LV_USE_LIST - style_init_reset(&styles->list_bg); - lv_style_set_pad_hor(&styles->list_bg, PAD_DEF); - lv_style_set_pad_ver(&styles->list_bg, 0); - lv_style_set_pad_gap(&styles->list_bg, 0); - lv_style_set_clip_corner(&styles->list_bg, true); - - style_init_reset(&styles->list_btn); - lv_style_set_border_width(&styles->list_btn, lv_disp_dpx(theme.disp, 1)); - lv_style_set_border_color(&styles->list_btn, color_grey); - lv_style_set_border_side(&styles->list_btn, LV_BORDER_SIDE_BOTTOM); - lv_style_set_pad_all(&styles->list_btn, PAD_SMALL); - lv_style_set_pad_column(&styles->list_btn, PAD_SMALL); - - style_init_reset(&styles->list_item_grow); - lv_style_set_transform_width(&styles->list_item_grow, PAD_DEF); -#endif - - -#if LV_USE_LED - style_init_reset(&styles->led); - lv_style_set_bg_opa(&styles->led, LV_OPA_COVER); - lv_style_set_bg_color(&styles->led, lv_color_white()); - lv_style_set_bg_grad_color(&styles->led, lv_palette_main(LV_PALETTE_GREY)); - lv_style_set_radius(&styles->led, LV_RADIUS_CIRCLE); - lv_style_set_shadow_width(&styles->led, lv_disp_dpx(theme.disp, 15)); - lv_style_set_shadow_color(&styles->led, lv_color_white()); - lv_style_set_shadow_spread(&styles->led, lv_disp_dpx(theme.disp, 5)); -#endif - - return &theme; + style_init_reset(&style_pad); + lv_style_set_pad_top(&style_pad, LV_VER_RES / 30); + lv_style_set_pad_bottom(&style_pad, LV_VER_RES / 30); + lv_style_set_pad_left(&style_pad, LV_VER_RES / 40); + lv_style_set_pad_right(&style_pad, LV_VER_RES / 40); + + style_init_reset(&style_circle); + lv_style_set_radius(&style_circle, LV_RADIUS_CIRCLE); + + style_init_reset(&style_bg); + lv_style_set_bg_opa(&style_bg, LV_OPA_COVER); + lv_style_set_bg_color(&style_bg, COLOR_BLACK); + lv_style_set_text_font(&style_bg, theme.font_normal); + + style_init_reset(&style_box); + lv_style_set_bg_opa(&style_box, LV_OPA_COVER); + lv_style_set_radius(&style_box, 10); +// lv_style_set_value_color(&style_box, LV_PINETIME_BLUE); +// lv_style_set_value_font(&style_box, theme.font_normal); + + style_init_reset(&style_box_border); + lv_style_set_bg_opa(&style_box_border, LV_OPA_TRANSP); + lv_style_set_border_width(&style_box_border, 2); + lv_style_set_border_color(&style_box_border, LV_PINETIME_GRAY); + lv_style_set_text_color(&style_box, LV_PINETIME_BLUE); + +// style_init_reset(&style_title); +// lv_style_set_text_color(&style_title, LV_PINETIME_WHITE); +// lv_style_set_text_font(&style_title, theme.font_subtitle); + + style_init_reset(&style_label_white); + lv_style_set_text_color(&style_label_white, LV_PINETIME_WHITE); + + style_init_reset(&style_btn); + lv_style_set_radius(&style_btn, 10); + lv_style_set_bg_opa(&style_btn, LV_OPA_COVER); + lv_style_set_bg_color(&style_btn, lv_color_hex(0x2F3540)); + lv_style_set_border_color(&style_btn, theme.color_primary); + lv_style_set_border_width(&style_btn, 0); + lv_style_set_text_color(&style_btn, COLOR_WHITE); + lv_style_set_pad_left(&style_btn, LV_DPX(20)); + lv_style_set_pad_right(&style_btn, LV_DPX(20)); + lv_style_set_pad_top(&style_btn, LV_DPX(20)); + lv_style_set_pad_bottom(&style_btn, LV_DPX(20)); + lv_style_set_pad_gap(&style_btn, LV_DPX(15)); + lv_style_set_outline_width(&style_btn, LV_DPX(2)); + lv_style_set_outline_opa(&style_btn, LV_OPA_0); + lv_style_set_outline_color(&style_btn, theme.color_primary); + + style_init_reset(&style_btn_checked); + lv_style_set_border_opa(&style_btn_checked, LV_OPA_TRANSP); + lv_style_set_bg_color(&style_btn_checked, lv_palette_main(LV_PALETTE_GREEN)); + lv_style_set_text_color(&style_btn_checked, lv_color_hex(0xffffff)); + + style_init_reset(&style_btn_disabled); + lv_style_set_bg_color(&style_btn_disabled, lv_color_hex(0x2F3540)); + lv_style_set_text_color(&style_btn_disabled, lv_color_hex(0x888888)); + + style_init_reset(&style_btn_disabled_checked); + lv_style_set_bg_color(&style_btn_disabled_checked, lv_color_hex3(0x888)); + + style_init_reset(&style_btn_border); + lv_style_set_radius(&style_btn_border, LV_RADIUS_CIRCLE); + lv_style_set_border_color(&style_btn_border, LV_PINETIME_WHITE); + lv_style_set_border_width(&style_btn_border, 2); + lv_style_set_bg_opa(&style_btn_border, LV_OPA_TRANSP); + lv_style_set_bg_color(&style_btn_border, LV_PINETIME_WHITE); + lv_style_set_text_color(&style_btn_border, LV_PINETIME_WHITE); + + style_init_reset(&style_icon); + lv_style_set_text_color(&style_icon, LV_PINETIME_WHITE); + + style_init_reset(&style_bar_indic); + lv_style_set_bg_opa(&style_bar_indic, LV_OPA_COVER); + lv_style_set_radius(&style_bar_indic, 10); + + style_init_reset(&style_scrollbar); + lv_style_set_bg_opa(&style_scrollbar, LV_OPA_COVER); + lv_style_set_radius(&style_scrollbar, LV_RADIUS_CIRCLE); + lv_style_set_bg_color(&style_scrollbar, LV_PINETIME_LIGHT_GRAY); + lv_style_set_size(&style_scrollbar, LV_HOR_RES / 80); + lv_style_set_pad_right(&style_scrollbar, LV_HOR_RES / 60); + + style_init_reset(&style_list_btn); + lv_style_set_bg_opa(&style_list_btn, LV_OPA_COVER); + lv_style_set_bg_color(&style_list_btn, LV_PINETIME_WHITE); + lv_style_set_text_color(&style_list_btn, LV_PINETIME_BLUE); + lv_style_set_img_recolor(&style_list_btn, LV_PINETIME_BLUE); + lv_style_set_pad_left(&style_list_btn, LV_HOR_RES / 25); + lv_style_set_pad_right(&style_list_btn, LV_HOR_RES / 25); + lv_style_set_pad_top(&style_list_btn, LV_HOR_RES / 100); + lv_style_set_pad_bottom(&style_list_btn, LV_HOR_RES / 100); + lv_style_set_pad_gap(&style_list_btn, LV_HOR_RES / 50); + + style_init_reset(&style_list_btn_checked); + lv_style_set_bg_color(&style_list_btn_checked, LV_PINETIME_GRAY); + lv_style_set_text_color(&style_list_btn_checked, LV_PINETIME_WHITE); + lv_style_set_img_recolor(&style_list_btn_checked, LV_PINETIME_WHITE); + + style_init_reset(&style_list_btn_checked_pressed); + lv_style_set_bg_color(&style_list_btn_checked_pressed, lv_color_darken(LV_PINETIME_GRAY, LV_OPA_20)); + lv_style_set_text_color(&style_list_btn_checked_pressed, LV_PINETIME_WHITE); + lv_style_set_img_recolor(&style_list_btn_checked_pressed, LV_PINETIME_WHITE); + + style_init_reset(&style_ddlist_list); + lv_style_set_text_line_space(&style_ddlist_list, LV_VER_RES / 25); + lv_style_set_shadow_width(&style_ddlist_list, LV_VER_RES / 20); + lv_style_set_shadow_color(&style_ddlist_list, LV_PINETIME_GRAY); + lv_style_set_bg_color(&style_ddlist_list, LV_PINETIME_GRAY); + + style_init_reset(&style_ddlist_selected); + lv_style_set_bg_opa(&style_ddlist_selected, LV_OPA_COVER); + lv_style_set_bg_color(&style_ddlist_selected, LV_PINETIME_BLUE); + + style_init_reset(&style_sw_bg); + lv_style_set_bg_opa(&style_sw_bg, LV_OPA_COVER); + lv_style_set_bg_color(&style_sw_bg, LV_PINETIME_LIGHT_GRAY); + lv_style_set_radius(&style_sw_bg, LV_RADIUS_CIRCLE); + + style_init_reset(&style_sw_indic); + lv_style_set_bg_opa(&style_sw_indic, LV_OPA_COVER); + lv_style_set_bg_color(&style_sw_indic, LV_PINETIME_GREEN); + + style_init_reset(&style_sw_knob); + lv_style_set_bg_opa(&style_sw_knob, LV_OPA_COVER); + lv_style_set_bg_color(&style_sw_knob, LV_PINETIME_WHITE); + lv_style_set_radius(&style_sw_knob, LV_RADIUS_CIRCLE); + lv_style_set_pad_top(&style_sw_knob, -4); + lv_style_set_pad_bottom(&style_sw_knob, -4); + lv_style_set_pad_left(&style_sw_knob, -4); + lv_style_set_pad_right(&style_sw_knob, -4); + + style_init_reset(&style_slider_knob); + lv_style_set_bg_opa(&style_slider_knob, LV_OPA_COVER); + lv_style_set_bg_color(&style_slider_knob, lv_palette_main(LV_PALETTE_RED)); + lv_style_set_border_color(&style_slider_knob, COLOR_WHITE); + lv_style_set_border_width(&style_slider_knob, 6); + lv_style_set_radius(&style_slider_knob, LV_RADIUS_CIRCLE); + lv_style_set_pad_top(&style_slider_knob, 10); + lv_style_set_pad_bottom(&style_slider_knob, 10); + lv_style_set_pad_left(&style_slider_knob, 10); + lv_style_set_pad_right(&style_slider_knob, 10); + + style_init_reset(&style_slider_knob_pressed); + lv_style_set_pad_top(&style_slider_knob_pressed, 14); + lv_style_set_pad_bottom(&style_slider_knob_pressed, 14); + lv_style_set_pad_left(&style_slider_knob_pressed, 14); + lv_style_set_pad_right(&style_slider_knob_pressed, 14); + + style_init_reset(&style_arc_indic); + lv_style_set_line_color(&style_arc_indic, LV_PINETIME_BLUE); + lv_style_set_line_width(&style_arc_indic, LV_DPX(25)); + lv_style_set_line_rounded(&style_arc_indic, true); + + style_init_reset(&style_arc_bg); + lv_style_set_line_color(&style_arc_bg, LV_PINETIME_GRAY); + lv_style_set_line_width(&style_arc_bg, LV_DPX(25)); + lv_style_set_line_rounded(&style_arc_bg, true); + lv_style_set_pad_all(&style_arc_bg, LV_DPX(5)); + + lv_style_reset(&style_arc_knob); + lv_style_set_radius(&style_arc_knob, LV_RADIUS_CIRCLE); + lv_style_set_bg_opa(&style_arc_knob, LV_OPA_COVER); + lv_style_set_bg_color(&style_arc_knob, LV_PINETIME_LIGHT_GRAY); + lv_style_set_pad_all(&style_arc_knob, LV_DPX(5)); + + style_init_reset(&style_table_cell); + lv_style_set_border_color(&style_table_cell, LV_PINETIME_GRAY); + lv_style_set_border_width(&style_table_cell, 1); + lv_style_set_border_side(&style_table_cell, LV_BORDER_SIDE_FULL); + lv_style_set_pad_left(&style_table_cell, 5); + lv_style_set_pad_right(&style_table_cell, 5); + lv_style_set_pad_top(&style_table_cell, 2); + lv_style_set_pad_bottom(&style_table_cell, 2); + + style_init_reset(&style_pad_small); + int32_t pad_small_value = 10; + lv_style_set_pad_left(&style_pad_small, pad_small_value); + lv_style_set_pad_right(&style_pad_small, pad_small_value); + lv_style_set_pad_top(&style_pad_small, pad_small_value); + lv_style_set_pad_bottom(&style_pad_small, pad_small_value); + lv_style_set_pad_gap(&style_pad_small, pad_small_value); + + style_init_reset(&style_bg_grad); + lv_style_set_bg_color(&style_bg_grad, lv_color_hsv_to_rgb(10, 10, 40)); + lv_style_set_bg_grad_color(&style_bg_grad, lv_color_hsv_to_rgb(10, 10, 20)); + lv_style_set_bg_grad_dir(&style_bg_grad, LV_GRAD_DIR_VER); + + style_init_reset(&style_lmeter); + lv_style_set_radius(&style_lmeter, LV_RADIUS_CIRCLE); + lv_style_set_pad_left(&style_lmeter, LV_DPX(20)); + lv_style_set_pad_right(&style_lmeter, LV_DPX(20)); + lv_style_set_pad_top(&style_lmeter, LV_DPX(20)); + lv_style_set_pad_gap(&style_lmeter, LV_DPX(30)); +// lv_style_set_scale_width(&style_lmeter, LV_DPX(25)); + + lv_style_set_line_color(&style_lmeter, theme.color_primary); +// lv_style_set_scale_grad_color(&style_lmeter, theme.color_primary); +// lv_style_set_scale_end_color(&style_lmeter, lv_color_hex3(0x888)); + lv_style_set_line_width(&style_lmeter, LV_DPX(10)); +// lv_style_set_scale_end_line_width(&style_lmeter, LV_DPX(7)); + + style_init_reset(&style_chart_series); + lv_style_set_line_color(&style_chart_series, LV_PINETIME_WHITE); + lv_style_set_line_width(&style_chart_series, 4); + lv_style_set_size(&style_chart_series, 4); + lv_style_set_bg_opa(&style_chart_series, 0); + + lv_style_reset(&style_cb_bg); + lv_style_set_radius(&style_cb_bg, LV_DPX(4)); + lv_style_set_pad_gap(&style_cb_bg, LV_DPX(10)); + lv_style_set_outline_color(&style_cb_bg, theme.color_primary); + lv_style_set_outline_width(&style_cb_bg, LV_DPX(2)); + lv_style_set_outline_pad(&style_cb_bg, LV_DPX(20)); + + lv_style_reset(&style_cb_bullet); + lv_style_set_radius(&style_cb_bullet, LV_DPX(4)); + lv_style_set_pad_left(&style_cb_bullet, LV_DPX(8)); + lv_style_set_pad_right(&style_cb_bullet, LV_DPX(8)); + lv_style_set_pad_top(&style_cb_bullet, LV_DPX(8)); + lv_style_set_pad_bottom(&style_cb_bullet, LV_DPX(8)); + + lv_style_reset(&style_cb_bullet_focused); + lv_style_set_outline_opa(&style_cb_bullet_focused, LV_OPA_TRANSP); + + lv_style_reset(&style_cb_bullet_checked); + lv_style_set_bg_img_recolor(&style_cb_bullet_checked, lv_color_white()); } + /********************** * GLOBAL FUNCTIONS **********************/ -lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font) +lv_theme_t * lv_pinetime_theme_init(lv_disp_t * disp, + lv_color_t color_primary, + lv_color_t color_secondary, + const lv_font_t* font) { - - /*This trick is required only to avoid the garbage collection of - *styles' data if LVGL is used in a binding (e.g. Micropython) - *In a general case styles could be in simple `static lv_style_t my_style...` variables*/ - if(!inited) { - LV_GC_ROOT(_lv_theme_default_styles) = lv_mem_alloc(sizeof(my_theme_styles_t)); - styles = (my_theme_styles_t *)LV_GC_ROOT(_lv_theme_default_styles); - } - - if(LV_HOR_RES <= 320) disp_size = DISP_SMALL; - else if(LV_HOR_RES < 720) disp_size = DISP_MEDIUM; - else disp_size = DISP_LARGE; - - theme.disp = disp; theme.color_primary = color_primary; theme.color_secondary = color_secondary; + theme.disp = disp; theme.font_small = font; theme.font_normal = font; theme.font_large = font; + theme.apply_cb = theme_apply; - theme.flags = dark ? MODE_DARK : 0; - lv_pinetime_theme_init(lv_disp_get_default(), - lv_color_white(), - lv_color_hex(0xC0C0C0), - 0, - &jetbrains_mono_bold_20); + style_init(); + inited = true; if(disp == NULL || lv_disp_get_theme(disp) == &theme) lv_obj_report_style_change(NULL); - return (lv_theme_t *)&theme; + return &theme; } -bool lv_theme_default_is_inited(void) +bool lv_pinetime_theme_is_inited(void) { return inited; } @@ -602,396 +371,149 @@ bool lv_theme_default_is_inited(void) static void theme_apply(lv_theme_t * th, lv_obj_t * obj) { - LV_UNUSED(th); - - if(lv_obj_get_parent(obj) == NULL) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - return; - } - - if(lv_obj_check_type(obj, &lv_obj_class)) { -#if LV_USE_TABVIEW - lv_obj_t * parent = lv_obj_get_parent(obj); - /*Tabview content area*/ - if(lv_obj_check_type(parent, &lv_tabview_class)) { - return; - } - /*Tabview pages*/ - else if(lv_obj_check_type(lv_obj_get_parent(parent), &lv_tabview_class)) { - lv_obj_add_style(obj, &styles->pad_normal, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - return; - } -#endif - -#if LV_USE_WIN - /*Header*/ - if(lv_obj_get_child_id(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) { - lv_obj_add_style(obj, &styles->bg_color_grey, 0); - lv_obj_add_style(obj, &styles->pad_tiny, 0); - return; - } - /*Content*/ - else if(lv_obj_get_child_id(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->pad_normal, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - return; - } -#endif - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - } - #if LV_USE_BTN - else if(lv_obj_check_type(obj, &lv_btn_class)) { - lv_obj_add_style(obj, &styles->btn, 0); - lv_obj_add_style(obj, &styles->bg_color_primary, 0); - lv_obj_add_style(obj, &styles->transition_delayed, 0); - lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->transition_normal, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); -#if LV_THEME_DEFAULT_GROW - lv_obj_add_style(obj, &styles->grow, LV_STATE_PRESSED); -#endif - lv_obj_add_style(obj, &styles->bg_color_secondary, LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED); - } -#endif - -#if LV_USE_LINE - else if(lv_obj_check_type(obj, &lv_line_class)) { - lv_obj_add_style(obj, &styles->line, 0); - } -#endif - -#if LV_USE_BTNMATRIX - else if(lv_obj_check_type(obj, &lv_btnmatrix_class)) { -#if LV_USE_MSGBOX - if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_msgbox_class)) { - lv_obj_add_style(obj, &styles->msgbox_btn_bg, 0); - lv_obj_add_style(obj, &styles->pad_gap, 0); - lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED); - return; - } -#endif -#if LV_USE_TABVIEW - if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_tabview_class)) { - lv_obj_add_style(obj, &styles->bg_color_white, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->tab_bg_focus, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->tab_btn, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->tab_bg_focus, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - return; - } -#endif - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); - } -#endif - -#if LV_USE_BAR - else if(lv_obj_check_type(obj, &lv_bar_class)) { - lv_obj_add_style(obj, &styles->bg_color_primary_muted, 0); - lv_obj_add_style(obj, &styles->circle, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR); - } -#endif - -#if LV_USE_SLIDER - else if(lv_obj_check_type(obj, &lv_slider_class)) { - lv_obj_add_style(obj, &styles->bg_color_primary_muted, 0); - lv_obj_add_style(obj, &styles->circle, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB); -#if LV_THEME_DEFAULT_GROW - lv_obj_add_style(obj, &styles->grow, LV_PART_KNOB | LV_STATE_PRESSED); -#endif - lv_obj_add_style(obj, &styles->transition_delayed, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->transition_normal, LV_PART_KNOB | LV_STATE_PRESSED); - } -#endif - -#if LV_USE_TABLE - else if(lv_obj_check_type(obj, &lv_table_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_zero, 0); - lv_obj_add_style(obj, &styles->no_radius, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->table_cell, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pad_normal, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->bg_color_secondary, LV_PART_ITEMS | LV_STATE_EDITED); - } -#endif - -#if LV_USE_CHECKBOX - else if(lv_obj_check_type(obj, &lv_checkbox_class)) { - lv_obj_add_style(obj, &styles->pad_gap, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->cb_marker, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->cb_marker_checked, LV_PART_INDICATOR | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->pressed, LV_PART_INDICATOR | LV_STATE_PRESSED); -#if LV_THEME_DEFAULT_GROW - lv_obj_add_style(obj, &styles->grow, LV_PART_INDICATOR | LV_STATE_PRESSED); -#endif - lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->transition_delayed, LV_PART_INDICATOR); - } -#endif - -#if LV_USE_SWITCH - else if(lv_obj_check_type(obj, &lv_switch_class)) { - lv_obj_add_style(obj, &styles->bg_color_grey, 0); - lv_obj_add_style(obj, &styles->circle, 0); - lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->circle, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->switch_knob, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->disabled, LV_PART_KNOB | LV_STATE_DISABLED); - } -#endif - -#if LV_USE_CHART - else if(lv_obj_check_type(obj, &lv_chart_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_small, 0); - lv_obj_add_style(obj, &styles->chart_bg, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - lv_obj_add_style(obj, &styles->chart_series, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->chart_indic, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->chart_ticks, LV_PART_TICKS); - lv_obj_add_style(obj, &styles->chart_series, LV_PART_CURSOR); - } -#endif - -#if LV_USE_ROLLER - else if(lv_obj_check_type(obj, &lv_roller_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->anim, 0); - lv_obj_add_style(obj, &styles->line_space_large, 0); - lv_obj_add_style(obj, &styles->text_align_center, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_SELECTED); - } -#endif - -#if LV_USE_DROPDOWN - else if(lv_obj_check_type(obj, &lv_dropdown_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_small, 0); - lv_obj_add_style(obj, &styles->transition_delayed, 0); - lv_obj_add_style(obj, &styles->transition_normal, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR); - } - else if(lv_obj_check_type(obj, &lv_dropdownlist_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->clip_corner, 0); - lv_obj_add_style(obj, &styles->line_space_large, 0); - lv_obj_add_style(obj, &styles->dropdown_list, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_SELECTED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_SELECTED | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->pressed, LV_PART_SELECTED | LV_STATE_PRESSED); - } -#endif - -#if LV_USE_ARC - else if(lv_obj_check_type(obj, &lv_arc_class)) { - lv_obj_add_style(obj, &styles->arc_indic, 0); - lv_obj_add_style(obj, &styles->arc_indic, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->arc_indic_primary, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->knob, LV_PART_KNOB); - } -#endif - - -#if LV_USE_SPINNER - else if(lv_obj_check_type(obj, &lv_spinner_class)) { - lv_obj_add_style(obj, &styles->arc_indic, 0); - lv_obj_add_style(obj, &styles->arc_indic, LV_PART_INDICATOR); - lv_obj_add_style(obj, &styles->arc_indic_primary, LV_PART_INDICATOR); - } -#endif - -#if LV_USE_METER - else if(lv_obj_check_type(obj, &lv_meter_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->circle, 0); - lv_obj_add_style(obj, &styles->meter_indic, LV_PART_INDICATOR); - } -#endif - -#if LV_USE_TEXTAREA - else if(lv_obj_check_type(obj, &lv_textarea_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_small, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - lv_obj_add_style(obj, &styles->ta_cursor, LV_PART_CURSOR | LV_STATE_FOCUSED); - lv_obj_add_style(obj, &styles->ta_placeholder, LV_PART_TEXTAREA_PLACEHOLDER); - } -#endif - -#if LV_USE_CALENDAR - else if(lv_obj_check_type(obj, &lv_calendar_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->calendar_bg, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->calendar_day, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED); - } -#endif - -#if LV_USE_CALENDAR_HEADER_ARROW - else if(lv_obj_check_type(obj, &lv_calendar_header_arrow_class)) { - lv_obj_add_style(obj, &styles->card, 0); - } -#endif - -#if LV_USE_CALENDAR_HEADER_DROPDOWN - else if(lv_obj_check_type(obj, &lv_calendar_header_dropdown_class)) { - lv_obj_add_style(obj, &styles->card, 0); - } -#endif - -#if LV_USE_KEYBOARD - else if(lv_obj_check_type(obj, &lv_keyboard_class)) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, disp_size == DISP_LARGE ? &styles->pad_small : &styles->pad_tiny, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->btn, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); - lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->keyboard_btn_bg, LV_PART_ITEMS); - lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->bg_color_grey, LV_PART_ITEMS | LV_STATE_CHECKED); - lv_obj_add_style(obj, &styles->bg_color_primary_muted, LV_PART_ITEMS | LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->bg_color_secondary_muted, LV_PART_ITEMS | LV_STATE_EDITED); - } -#endif -#if LV_USE_LIST - else if(lv_obj_check_type(obj, &lv_list_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->list_bg, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - return; - } - else if(lv_obj_check_type(obj, &lv_list_text_class)) { - lv_obj_add_style(obj, &styles->bg_color_grey, 0); - lv_obj_add_style(obj, &styles->list_item_grow, 0); - } - else if(lv_obj_check_type(obj, &lv_list_btn_class)) { - lv_obj_add_style(obj, &styles->bg_color_white, 0); - lv_obj_add_style(obj, &styles->list_btn, 0); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->list_item_grow, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->list_item_grow, LV_STATE_PRESSED); - lv_obj_add_style(obj, &styles->pressed, LV_STATE_PRESSED); - - } -#endif -#if LV_USE_MSGBOX - else if(lv_obj_check_type(obj, &lv_msgbox_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->msgbox_bg, 0); - return; - } -#endif -#if LV_USE_SPINBOX - else if(lv_obj_check_type(obj, &lv_spinbox_class)) { - lv_obj_add_style(obj, &styles->card, 0); - lv_obj_add_style(obj, &styles->pad_small, 0); - lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY); - lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED); - lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_CURSOR); - } -#endif -#if LV_USE_TILEVIEW - else if(lv_obj_check_type(obj, &lv_tileview_class)) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - } - else if(lv_obj_check_type(obj, &lv_tileview_tile_class)) { - lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR); - lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED); - } -#endif - -#if LV_USE_TABVIEW - if(lv_obj_check_type(obj, &lv_tabview_class)) { - lv_obj_add_style(obj, &styles->scr, 0); - lv_obj_add_style(obj, &styles->pad_zero, 0); - return; - } -#endif - -#if LV_USE_COLORWHEEL - else if(lv_obj_check_type(obj, &lv_colorwheel_class)) { - lv_obj_add_style(obj, &styles->colorwheel_main, 0); - lv_obj_add_style(obj, &styles->pad_normal, 0); - lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_KNOB); - lv_obj_add_style(obj, &styles->pad_normal, LV_PART_KNOB); - } -#endif - -#if LV_USE_LED - else if(lv_obj_check_type(obj, &lv_led_class)) { - lv_obj_add_style(obj, &styles->led, 0); - } -#endif + LV_UNUSED(th); + + if (obj == NULL) { + return; + } + + if (lv_obj_get_parent(obj) == NULL) { + lv_obj_add_style(obj, &style_bg, 0); + lv_obj_add_style(obj, &style_label_white, 0); + return; + } + + if (lv_obj_check_type(obj, &lv_obj_class)) { + lv_obj_add_style(obj, &style_box, 0); + } + #if LV_USE_BTN + else if (lv_obj_check_type(obj, &lv_btn_class)) { + lv_obj_add_style(obj, &style_btn, 0); + lv_obj_add_style(obj, &style_btn_checked, LV_STATE_CHECKED); + lv_obj_add_style(obj, &style_btn_disabled, LV_STATE_DISABLED); + lv_obj_add_style(obj, &style_btn_disabled_checked, LV_STATE_DISABLED | LV_STATE_CHECKED); + } + #endif + + #if LV_USE_BTNMATRIX + else if (lv_obj_check_type(obj, &lv_btnmatrix_class)) { + lv_obj_add_style(obj, &style_bg, 0); + lv_obj_add_style(obj, &style_pad_small, 0); + lv_obj_add_style(obj, &style_btn, LV_PART_ITEMS); + lv_obj_add_style(obj, &style_btn_checked, LV_PART_ITEMS | LV_STATE_CHECKED); + lv_obj_add_style(obj, &style_btn_disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + lv_obj_add_style(obj, &style_btn_disabled_checked, LV_PART_ITEMS | LV_STATE_DISABLED | LV_STATE_CHECKED); + } + #endif + + #if LV_USE_BAR + else if (lv_obj_check_type(obj, &lv_bar_class)) { + lv_obj_add_style(obj, &style_bar_indic, LV_PART_INDICATOR); + } + #endif + + #if LV_USE_SLIDER + else if (lv_obj_check_type(obj, &lv_slider_class)) { + lv_obj_add_style(obj, &style_sw_bg, 0); + lv_obj_add_style(obj, &style_sw_knob, LV_PART_KNOB); + } + #endif + + #if LV_USE_TABLE + else if (lv_obj_check_type(obj, &lv_table_class)) { + lv_obj_add_style(obj, &style_bg, 0); + lv_obj_add_style(obj, &style_table_cell, LV_PART_ITEMS); + lv_obj_add_style(obj, &style_label_white, LV_PART_ITEMS); + } + #endif + + #if LV_USE_CHECKBOX + else if (lv_obj_check_type(obj, &lv_checkbox_class)) { + lv_obj_add_style(obj, &style_cb_bg, 0); + + lv_obj_add_style(obj, &style_btn, LV_PART_INDICATOR); + lv_obj_add_style(obj, &style_btn_checked, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &style_btn_disabled, LV_PART_INDICATOR | LV_STATE_DISABLED); + lv_obj_add_style(obj, &style_btn_disabled_checked, LV_PART_INDICATOR | LV_STATE_DISABLED | LV_STATE_CHECKED); + + lv_obj_add_style(obj, &style_cb_bullet, LV_PART_INDICATOR); + lv_obj_add_style(obj, &style_cb_bullet_checked, LV_PART_INDICATOR | LV_STATE_CHECKED); + lv_obj_add_style(obj, &style_cb_bullet_focused, LV_PART_INDICATOR | LV_STATE_FOCUSED); + } + #endif + + #if LV_USE_SWITCH + else if (lv_obj_check_type(obj, &lv_switch_class)) { + lv_obj_add_style(obj, &style_sw_bg, 0); + lv_obj_add_style(obj, &style_sw_indic, LV_PART_INDICATOR); + lv_obj_add_style(obj, &style_sw_knob, LV_PART_KNOB); + } + #endif + + #if LV_USE_CHART + else if (lv_obj_check_type(obj, &lv_chart_class)) { + lv_obj_add_style(obj, &style_btn, 0); + lv_obj_add_style(obj, &style_btn_checked, LV_STATE_CHECKED); + lv_obj_add_style(obj, &style_btn_disabled, LV_STATE_DISABLED); + lv_obj_add_style(obj, &style_btn_disabled_checked, LV_STATE_DISABLED | LV_STATE_CHECKED); + lv_obj_add_style(obj, &style_chart_series, 0); + } + #endif + + #if LV_USE_DROPDOWN + else if (lv_obj_check_type(obj, &lv_dropdown_class)) { + lv_obj_add_style(obj, &style_btn, 0); + lv_obj_add_style(obj, &style_pad, 0); + lv_obj_add_style(obj, &style_btn_checked, LV_STATE_CHECKED); + lv_obj_add_style(obj, &style_btn_disabled, LV_STATE_DISABLED); + lv_obj_add_style(obj, &style_btn_disabled_checked, LV_STATE_DISABLED | LV_STATE_CHECKED); + } else if (lv_obj_check_type(obj, &lv_dropdownlist_class)) { + lv_obj_add_style(obj, &style_box, 0); + lv_obj_add_style(obj, &style_ddlist_list, 0); + lv_obj_add_style(obj, &style_pad, 0); + lv_obj_add_style(obj, &style_ddlist_selected, LV_PART_SELECTED); + lv_obj_add_style(obj, &style_scrollbar, LV_PART_SCROLLBAR); + } + #endif + + #if LV_USE_ARC + else if (lv_obj_check_type(obj, &lv_arc_class)) { + lv_obj_add_style(obj, &style_arc_bg, 0); + lv_obj_add_style(obj, &style_arc_indic, LV_PART_INDICATOR); + lv_obj_add_style(obj, &style_arc_knob, LV_PART_KNOB); + } + #endif + + #if LV_USE_METER + else if (lv_obj_check_type(obj, &lv_meter_class)) { + lv_obj_add_style(obj, &style_bg, 0); + lv_obj_add_style(obj, &style_lmeter, 0); + } + #endif + + #if LV_USE_CALENDAR + else if (lv_obj_check_type(obj, &lv_calendar_class)) { +// lv_obj_add_style(obj, &styles->light, 0); +// lv_obj_add_style(obj, &styles->light, LV_PART_ITEMS | LV_STATE_PRESSED); +// lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED); +// lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED); + } + #endif + + #if LV_USE_LIST + else if (lv_obj_check_type(obj, &lv_list_class)) { + lv_obj_add_style(obj, &style_box, 0); + lv_obj_add_style(obj, &style_scrollbar, LV_PART_SCROLLBAR); + } else if (lv_obj_check_type(obj, &lv_list_text_class)) { + + } else if (lv_obj_check_type(obj, &lv_list_btn_class)) { + lv_obj_add_style(obj, &style_list_btn, 0); + lv_obj_add_style(obj, &style_list_btn_checked, LV_STATE_CHECKED); + lv_obj_add_style(obj, &style_list_btn_checked_pressed, LV_STATE_CHECKED | LV_STATE_PRESSED); + } + #endif + + lv_obj_refresh_style(obj, LV_PART_ANY, LV_STYLE_PROP_ANY); } /********************** @@ -1000,8 +522,11 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) static void style_init_reset(lv_style_t * style) { - if(inited) lv_style_reset(style); - else lv_style_init(style); + if(inited) { + lv_style_reset(style); + } else{ + lv_style_init(style); + } } -#endif \ No newline at end of file +#endif diff --git a/src/displayapp/lv_pinetime_theme.h b/src/displayapp/lv_pinetime_theme.h index f286fe4696..b2c022674f 100644 --- a/src/displayapp/lv_pinetime_theme.h +++ b/src/displayapp/lv_pinetime_theme.h @@ -45,10 +45,9 @@ extern "C" { lv_theme_t* lv_pinetime_theme_init(lv_disp_t* disp, lv_color_t color_primary, lv_color_t color_secondary, - bool dark, const lv_font_t* font); -bool lv_theme_default_is_inited(void); +bool lv_pinetime_theme_is_inited(void); /********************** * MACROS diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp index f996da7508..c42fe9eabd 100644 --- a/src/displayapp/screens/settings/SettingDisplay.cpp +++ b/src/displayapp/screens/settings/SettingDisplay.cpp @@ -22,7 +22,7 @@ SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); -lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT);; + lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 10, 60); diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index 3a47b8e5bb..0bc2fa61b5 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -480,7 +480,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ * Themes *----------*/ /*A simple, impressive and very complete theme*/ -#define LV_USE_THEME_DEFAULT 1 +#define LV_USE_THEME_DEFAULT 0 #if LV_USE_THEME_DEFAULT /*0: Light mode; 1: Dark mode*/ @@ -493,6 +493,8 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ # define LV_THEME_DEFAULT_TRANSITON_TIME 80 #endif /*LV_USE_THEME_DEFAULT*/ +#define LV_USE_THEME_PINETIME 1 + /*An very simple them that is a good starting point for a custom theme*/ #define LV_USE_THEME_BASIC 0 From 16910e6e03c9d938fd41ee0c8de970b3437131fc Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Sun, 10 Oct 2021 18:51:25 -0400 Subject: [PATCH 07/25] Implementation of LeftAnim, RightAnim, ScrollDown using public lvgl8 API. --- src/displayapp/LittleVgl.cpp | 197 ++++++++++++++++++++++++++++------- src/displayapp/LittleVgl.h | 5 + 2 files changed, 164 insertions(+), 38 deletions(-) diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index f337a16e35..dabcb88ec6 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -67,17 +67,153 @@ void LittleVgl::InitTouchpad() { void LittleVgl::SetFullRefresh(FullRefreshDirections direction) { if (scrollDirection == FullRefreshDirections::None) { scrollDirection = direction; - if (scrollDirection == FullRefreshDirections::Down) { - lv_disp_set_rotation(lv_disp_get_default(), static_cast(1)); - } else if (scrollDirection == FullRefreshDirections::Right) { - lv_disp_set_rotation(lv_disp_get_default(), static_cast(2)); - } else if (scrollDirection == FullRefreshDirections::Left) { - lv_disp_set_rotation(lv_disp_get_default(), static_cast(3)); - } else if (scrollDirection == FullRefreshDirections::RightAnim) { - lv_disp_set_rotation(lv_disp_get_default(), static_cast(5)); - } else if (scrollDirection == FullRefreshDirections::LeftAnim) { - lv_disp_set_rotation(lv_disp_get_default(), static_cast(4)); +// if (scrollDirection == FullRefreshDirections::Down) { +// lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); +// } else if (scrollDirection == FullRefreshDirections::Right) { +// lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); +// } else if (scrollDirection == FullRefreshDirections::Left) { +// lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); +// } else if (scrollDirection == FullRefreshDirections::RightAnim) { +// lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); +// } else if (scrollDirection == FullRefreshDirections::LeftAnim) { +// lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); +// } + } +} + + +void LittleVgl::DisplayDownScroll(){ + // We are controlling the drawing process, disable lvgl timers + lv_timer_enable(false); + + // For each segment, draw the full width, 4 lines at a time starting from the bottom + // TODO: Should probably calculate this from the size of the draw buffer + int16_t height = 4; + int16_t width = 240; + int16_t y2 = 240; + int16_t y1 = 240 - height; + + lv_area_t area; + area.x1 = 0; + area.x2 = width; + + // Start from the bottom and create a 4 line high box + for (y1 = 240 - height; y1 >= 0; y1 -= height) { + y2 = y1 + height - 1; + + // If the previous box has reached the end of the visible line on the lcd controller... + if (area.y2 == visibleNbLines - 1) { + // move past the non visible lines + writeOffset += (totalNbLines - visibleNbLines); + // and wrap around to the start of address space + writeOffset %= totalNbLines; } + // Set new box + area.y1 = y1; + area.y2 = y2; + + // Scroll as we draw + uint16_t toScroll = height; + if (scrollOffset >= toScroll) + scrollOffset -= toScroll; + else { // now we need to wrap the scroll address + toScroll -= scrollOffset; + scrollOffset = totalNbLines - toScroll; + } + lcd.VerticalScrollStartAddress(scrollOffset); + + lv_disp_t* disp = lv_disp_get_default(); + // Clear invalid area list / tells lvgl that nothing on the screen needs to be updated + _lv_inv_area(disp, nullptr); + // invalidate only the segment we want to update in this portion of the animation + _lv_inv_area(disp, &area); + // cancel any current flushes in the display driver + // Since we've stopped timers, it will be waiting forever if there is currently a flush + lv_disp_flush_ready(disp->driver); + lv_refr_now(disp); + } + // Done! clear flags and enable timers + scrollDirection = FullRefreshDirections::None; + animating = false; + lv_timer_enable(true); +} + +void LittleVgl::DisplayHorizAnim() { + lv_timer_enable(false); + + int16_t height, width, x1, x2; + lv_area_t area; + + height = 240; + width = 4; + int16_t (*NextStep)(int16_t, int16_t){}; + bool (*CheckEnd)(int16_t){}; + + area.y1=0; + area.y2=height; + + if (scrollDirection == FullRefreshDirections::RightAnim) { + x1 = 0; + + CheckEnd = [](int16_t x) -> bool { + return (x < LV_HOR_RES_MAX); + }; + NextStep = [](int16_t x, int16_t width) -> int16_t { + auto newx = x + width * 2; + if (newx < 240) {return newx;}; + return (newx < 240 + width) ? (newx - 240 + width) : newx; + }; + + } else if (scrollDirection == FullRefreshDirections::LeftAnim) { + x1 = 240 - width; + + CheckEnd = [](int16_t x) -> bool { + return (x >= 0); + }; + NextStep = [](int16_t x, int16_t width) -> int16_t { + auto newx = x - width * 2; + if (newx >= 0) {return newx;} + return (newx >= 0 - width) ? (newx + 240 - width) : newx; + }; + + } else { + // Not set for a horizontal animation! + lv_timer_enable(true); + return; + } + + for (; CheckEnd(x1); x1 = NextStep(x1, width)) { + x2 = x1 + width-1; + + if (area.y2 == visibleNbLines - 1) { + writeOffset += (totalNbLines - visibleNbLines); + writeOffset %= totalNbLines; + } + area.x1 = x1; + area.x2 = x2; + + lv_disp_t* disp = lv_disp_get_default(); + _lv_inv_area(disp, nullptr); + _lv_inv_area(disp, &area); + lv_disp_flush_ready(disp->driver); + lv_refr_now(disp); + } + scrollDirection = FullRefreshDirections::None; + animating = false; + lv_timer_enable(true); +} + +void LittleVgl::FlushDisplayManually() { + switch(scrollDirection){ + case FullRefreshDirections::Down: + DisplayDownScroll(); + break; + case FullRefreshDirections::RightAnim: + case FullRefreshDirections::LeftAnim: + DisplayHorizAnim(); + break; + default: + break; } } @@ -87,10 +223,16 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { ulTaskNotifyTake(pdTRUE, 200); // NOtification is still needed (even if there is a mutex on SPI) because of the DataCommand pin // which cannot be set/clear during a transfert. + + if (!animating && (scrollDirection == FullRefreshDirections::Down || + scrollDirection == FullRefreshDirections::RightAnim || + scrollDirection == FullRefreshDirections::LeftAnim)){ + animating = true; + FlushDisplayManually(); + return; + } - if ((scrollDirection == LittleVgl::FullRefreshDirections::Down) && (area->y2 == visibleNbLines - 1)) { - writeOffset = ((writeOffset + totalNbLines) - visibleNbLines) % totalNbLines; - } else if ((scrollDirection == FullRefreshDirections::Up) && (area->y1 == 0)) { + if ((scrollDirection == FullRefreshDirections::Up) && (area->y1 == 0)) { writeOffset = (writeOffset + visibleNbLines) % totalNbLines; } @@ -100,34 +242,13 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { width = (area->x2 - area->x1) + 1; height = (area->y2 - area->y1) + 1; - if (scrollDirection == LittleVgl::FullRefreshDirections::Down) { - - if (area->y2 < visibleNbLines - 1) { - uint16_t toScroll = 0; - if (area->y1 == 0) { - toScroll = height * 2; - scrollDirection = FullRefreshDirections::None; - lv_disp_set_rotation(lv_disp_get_default(), static_cast(0)); - } else { - toScroll = height; - } - - if (scrollOffset >= toScroll) - scrollOffset -= toScroll; - else { - toScroll -= scrollOffset; - scrollOffset = (totalNbLines) -toScroll; - } - lcd.VerticalScrollStartAddress(scrollOffset); - } - - } else if (scrollDirection == FullRefreshDirections::Up) { + if (scrollDirection == FullRefreshDirections::Up) { if (area->y1 > 0) { if (area->y2 == visibleNbLines - 1) { scrollOffset += (height * 2); scrollDirection = FullRefreshDirections::None; - lv_disp_set_rotation(lv_disp_get_default(), static_cast(0)); +// lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); } else { scrollOffset += height; } @@ -137,12 +258,12 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { } else if (scrollDirection == FullRefreshDirections::Left or scrollDirection == FullRefreshDirections::LeftAnim) { if (area->x2 == visibleNbLines - 1) { scrollDirection = FullRefreshDirections::None; - lv_disp_set_rotation(lv_disp_get_default(), static_cast(0)); +// lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); } } else if (scrollDirection == FullRefreshDirections::Right or scrollDirection == FullRefreshDirections::RightAnim) { if (area->x1 == 0) { scrollDirection = FullRefreshDirections::None; - lv_disp_set_rotation(lv_disp_get_default(), static_cast(0)); +// lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); } } diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index d71ed7060b..893a879291 100644 --- a/src/displayapp/LittleVgl.h +++ b/src/displayapp/LittleVgl.h @@ -30,6 +30,10 @@ namespace Pinetime { void InitDisplay(); void InitTouchpad(); void InitTheme(); + + void FlushDisplayManually(); + void DisplayDownScroll(); + void DisplayHorizAnim(); Pinetime::Drivers::St7789& lcd; Pinetime::Drivers::Cst816S& touchPanel; @@ -42,6 +46,7 @@ namespace Pinetime { lv_point_t previousClick; bool firstTouch = true; + bool animating = false; static constexpr uint8_t nbWriteLines = 4; static constexpr uint16_t totalNbLines = 320; static constexpr uint16_t visibleNbLines = 240; From fb632d47932a2bcf6d25617e117659fcc671e8b9 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Sun, 10 Oct 2021 23:01:04 -0400 Subject: [PATCH 08/25] stop digital watch face from constantly refreshing --- src/displayapp/screens/WatchFaceDigital.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 2ba5ff5ccc..b68c14ce6c 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -105,6 +105,10 @@ void WatchFaceDigital::Refresh() { powerPresent = batteryController.IsPowerPresent(); if (powerPresent.IsUpdated()) { lv_label_set_text(batteryPlug, BatteryIcon::GetPlugIcon(powerPresent.Get())); + + // These alignments cause lvgl to refresh the screen even if nothing has technically changed. Only align if needed. + lv_obj_align(batteryIcon, LV_ALIGN_TOP_RIGHT, 0, 0); + lv_obj_align(batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0); } batteryPercentRemaining = batteryController.PercentRemaining(); @@ -116,15 +120,19 @@ void WatchFaceDigital::Refresh() { lv_obj_set_style_text_color(batteryIcon, lv_color_white(), LV_PART_MAIN | LV_STATE_DEFAULT); } lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryPercent)); + + // These alignments cause lvgl to refresh the screen even if nothing has technically changed. Only align if needed. + lv_obj_align(batteryIcon, LV_ALIGN_TOP_RIGHT, 0, 0); + lv_obj_align(batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0); } bleState = bleController.IsConnected(); if (bleState.IsUpdated()) { lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get())); + + // These alignments cause lvgl to refresh the screen even if nothing has technically changed. Only align if needed. + lv_obj_align(bleIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); } - lv_obj_align(batteryIcon, LV_ALIGN_TOP_RIGHT, 0, 0); - lv_obj_align(batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0); - lv_obj_align(bleIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); notificationState = notificatioManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { From edc88e99290e0ab6bc4ed872051154987ebb42db Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Sun, 10 Oct 2021 23:02:16 -0400 Subject: [PATCH 09/25] center icons on quicksettings --- .../screens/settings/QuickSettings.cpp | 112 +++++++++--------- .../screens/settings/QuickSettings.h | 12 +- 2 files changed, 64 insertions(+), 60 deletions(-) diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index 82d1504351..7499255f8c 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -53,58 +53,62 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, lv_style_set_radius(&btn_style, buttonHeight / 4); lv_style_set_bg_color(&btn_style, lv_color_hex(0x111111)); - btn1 = lv_btn_create(lv_scr_act()); - btn1->user_data = this; - lv_obj_add_event_cb(btn1, ButtonEventHandler, LV_EVENT_ALL, btn1->user_data); - lv_obj_add_style(btn1, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_size(btn1, buttonWidth, buttonHeight); - lv_obj_align(btn1, LV_ALIGN_TOP_LEFT, buttonXOffset, barHeight); - - btn1_lvl = lv_label_create(btn1); - lv_obj_set_style_text_font(btn1_lvl, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_label_set_text_static(btn1_lvl, brightness.GetIcon()); - - btn2 = lv_btn_create(lv_scr_act()); - btn2->user_data = this; - lv_obj_add_event_cb(btn2, ButtonEventHandler, LV_EVENT_ALL, btn2->user_data); - lv_obj_add_style(btn2, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_size(btn2, buttonWidth, buttonHeight); - lv_obj_align(btn2, LV_ALIGN_TOP_RIGHT, - buttonXOffset, barHeight); - - lv_obj_t* lbl_btn; - lbl_btn = lv_label_create(btn2); - lv_obj_set_style_text_font(lbl_btn, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_label_set_text_static(lbl_btn, Symbols::highlight); - - btn3 = lv_btn_create(lv_scr_act()); - btn3->user_data = this; - lv_obj_add_event_cb(btn3, ButtonEventHandler, LV_EVENT_ALL, btn3->user_data); - lv_obj_add_flag(btn3, LV_OBJ_FLAG_CHECKABLE); - lv_obj_add_style(btn3, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_bg_color(btn3, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_CHECKED); - lv_obj_set_size(btn3, buttonWidth, buttonHeight); - lv_obj_align(btn3, LV_ALIGN_BOTTOM_LEFT, buttonXOffset, 0); - - btn3_lvl = lv_label_create(btn3); - lv_obj_set_style_text_font(btn3_lvl, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); + brightnessButton = lv_btn_create(lv_scr_act()); + brightnessButton->user_data = this; + lv_obj_add_event_cb(brightnessButton, ButtonEventHandler, LV_EVENT_ALL, brightnessButton->user_data); + lv_obj_add_style(brightnessButton, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_size(brightnessButton, buttonWidth, buttonHeight); + lv_obj_align(brightnessButton, LV_ALIGN_TOP_LEFT, buttonXOffset, barHeight); + + brightnessLabel = lv_label_create(brightnessButton); + lv_obj_set_style_text_font(brightnessLabel, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_label_set_text_static(brightnessLabel, brightness.GetIcon()); + lv_obj_center(brightnessLabel); + + flashlightButton = lv_btn_create(lv_scr_act()); + flashlightButton->user_data = this; + lv_obj_add_event_cb(flashlightButton, ButtonEventHandler, LV_EVENT_ALL, flashlightButton->user_data); + lv_obj_add_style(flashlightButton, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_size(flashlightButton, buttonWidth, buttonHeight); + lv_obj_align(flashlightButton, LV_ALIGN_TOP_RIGHT, - buttonXOffset, barHeight); + + lv_obj_t* flashlightLabel; + flashlightLabel = lv_label_create(flashlightButton); + lv_obj_set_style_text_font(flashlightLabel, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_label_set_text_static(flashlightLabel, Symbols::highlight); + lv_obj_center(flashlightLabel); + + notificationButton = lv_btn_create(lv_scr_act()); + notificationButton->user_data = this; + lv_obj_add_event_cb(notificationButton, ButtonEventHandler, LV_EVENT_ALL, notificationButton->user_data); + lv_obj_add_flag(notificationButton, LV_OBJ_FLAG_CHECKABLE); + lv_obj_add_style(notificationButton, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(notificationButton, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_CHECKED); + lv_obj_set_size(notificationButton, buttonWidth, buttonHeight); + lv_obj_align(notificationButton, LV_ALIGN_BOTTOM_LEFT, buttonXOffset, 0); + + notificationLabel = lv_label_create(notificationButton); + lv_obj_set_style_text_font(notificationLabel, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_center(notificationLabel); if (settingsController.GetNotificationStatus() == Controllers::Settings::Notification::ON) { - lv_obj_add_state(btn3, LV_STATE_CHECKED); - lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn); + lv_obj_add_state(notificationButton, LV_STATE_CHECKED); + lv_label_set_text_static(notificationLabel, Symbols::notificationsOn); } else { - lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff); + lv_label_set_text_static(notificationLabel, Symbols::notificationsOff); } - btn4 = lv_btn_create(lv_scr_act()); - btn4->user_data = this; - lv_obj_add_event_cb(btn4, ButtonEventHandler, LV_EVENT_ALL, btn4->user_data); - lv_obj_add_style(btn4, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_size(btn4, buttonWidth, buttonHeight); - lv_obj_align(btn4, LV_ALIGN_BOTTOM_RIGHT, - buttonXOffset, 0); + settingsButton = lv_btn_create(lv_scr_act()); + settingsButton->user_data = this; + lv_obj_add_event_cb(settingsButton, ButtonEventHandler, LV_EVENT_ALL, settingsButton->user_data); + lv_obj_add_style(settingsButton, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_size(settingsButton, buttonWidth, buttonHeight); + lv_obj_align(settingsButton, LV_ALIGN_BOTTOM_RIGHT, - buttonXOffset, 0); - lbl_btn = lv_label_create(btn4); - lv_obj_set_style_text_font(lbl_btn, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_label_set_text_static(lbl_btn, Symbols::settings); + lv_obj_t *settingsLabel= lv_label_create(settingsButton); + lv_obj_set_style_text_font(settingsLabel, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_label_set_text_static(settingsLabel, Symbols::settings); + lv_obj_center(settingsLabel); lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act()); lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); @@ -128,29 +132,29 @@ void QuickSettings::UpdateScreen() { } void QuickSettings::OnButtonEvent(lv_obj_t* object, lv_event_t* event) { - if (object == btn2 && lv_event_get_code(event) == LV_EVENT_CLICKED) { + if (object == flashlightButton && lv_event_get_code(event) == LV_EVENT_CLICKED) { running = false; app->StartApp(Apps::FlashLight, DisplayApp::FullRefreshDirections::None); - } else if (object == btn1 && lv_event_get_code(event) == LV_EVENT_CLICKED) { + } else if (object == brightnessButton && lv_event_get_code(event) == LV_EVENT_CLICKED) { brightness.Step(); - lv_label_set_text_static(btn1_lvl, brightness.GetIcon()); + lv_label_set_text_static(brightnessLabel, brightness.GetIcon()); settingsController.SetBrightness(brightness.Level()); - } else if (object == btn3 && lv_event_get_code(event) == LV_EVENT_VALUE_CHANGED) { + } else if (object == notificationButton && lv_event_get_code(event) == LV_EVENT_VALUE_CHANGED) { - if (lv_obj_get_state(btn3) & LV_STATE_CHECKED) { + if (lv_obj_get_state(notificationButton) & LV_STATE_CHECKED) { settingsController.SetNotificationStatus(Controllers::Settings::Notification::ON); motorController.RunForDuration(35); - lv_label_set_text_static(btn3_lvl, Symbols::notificationsOn); + lv_label_set_text_static(notificationLabel, Symbols::notificationsOn); } else { settingsController.SetNotificationStatus(Controllers::Settings::Notification::OFF); - lv_label_set_text_static(btn3_lvl, Symbols::notificationsOff); + lv_label_set_text_static(notificationLabel, Symbols::notificationsOff); } - } else if (object == btn4 && lv_event_get_code(event) == LV_EVENT_CLICKED) { + } else if (object == settingsButton && lv_event_get_code(event) == LV_EVENT_CLICKED) { running = false; settingsController.SetSettingsMenu(0); app->StartApp(Apps::Settings, DisplayApp::FullRefreshDirections::Up); diff --git a/src/displayapp/screens/settings/QuickSettings.h b/src/displayapp/screens/settings/QuickSettings.h index 7c38cce1fc..ff123860d9 100644 --- a/src/displayapp/screens/settings/QuickSettings.h +++ b/src/displayapp/screens/settings/QuickSettings.h @@ -44,12 +44,12 @@ namespace Pinetime { lv_style_t btn_style; - lv_obj_t* btn1; - lv_obj_t* btn1_lvl; - lv_obj_t* btn2; - lv_obj_t* btn3; - lv_obj_t* btn3_lvl; - lv_obj_t* btn4; + lv_obj_t* brightnessButton; + lv_obj_t* brightnessLabel; + lv_obj_t* flashlightButton; + lv_obj_t* notificationButton; + lv_obj_t* notificationLabel; + lv_obj_t* settingsButton; }; } } From 33a6be5733d70405ad9e7381645f88d71a4118b6 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Mon, 11 Oct 2021 00:15:50 -0400 Subject: [PATCH 10/25] Fix many alignment issues --- src/displayapp/lv_pinetime_theme.c | 1 + src/displayapp/screens/Music.cpp | 5 ++++ src/displayapp/screens/WatchFaceDigital.cpp | 24 +++++++++---------- .../screens/settings/SettingDisplay.cpp | 4 ++-- .../screens/settings/SettingSteps.cpp | 6 +++-- .../screens/settings/SettingTimeFormat.cpp | 4 ++-- .../screens/settings/SettingWakeUp.cpp | 4 ++-- .../screens/settings/SettingWatchFace.cpp | 4 ++-- 8 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/displayapp/lv_pinetime_theme.c b/src/displayapp/lv_pinetime_theme.c index e0c71dd81d..abec609688 100644 --- a/src/displayapp/lv_pinetime_theme.c +++ b/src/displayapp/lv_pinetime_theme.c @@ -320,6 +320,7 @@ static void style_init(void) lv_style_set_outline_color(&style_cb_bg, theme.color_primary); lv_style_set_outline_width(&style_cb_bg, LV_DPX(2)); lv_style_set_outline_pad(&style_cb_bg, LV_DPX(20)); + lv_style_set_outline_opa(&style_cb_bg, LV_OPA_0); lv_style_reset(&style_cb_bullet); lv_style_set_radius(&style_cb_bullet, LV_DPX(4)); diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp index 582313e6de..823631ac3e 100644 --- a/src/displayapp/screens/Music.cpp +++ b/src/displayapp/screens/Music.cpp @@ -62,6 +62,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus lv_obj_align(btnVolDown, LV_ALIGN_BOTTOM_LEFT, 0, 0); lv_obj_add_style(btnVolDown, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); label = lv_label_create(btnVolDown); + lv_obj_center(label); lv_label_set_text(label, Symbols::volumDown); lv_obj_add_flag(btnVolDown, LV_OBJ_FLAG_HIDDEN); @@ -72,6 +73,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus lv_obj_align(btnVolUp, LV_ALIGN_BOTTOM_RIGHT, 0, 0); lv_obj_add_style(btnVolUp, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); label = lv_label_create(btnVolUp); + lv_obj_center(label); lv_label_set_text(label, Symbols::volumUp); lv_obj_add_flag(btnVolUp, LV_OBJ_FLAG_HIDDEN); @@ -82,6 +84,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus lv_obj_align(btnPrev, LV_ALIGN_BOTTOM_LEFT, 0, 0); lv_obj_add_style(btnPrev, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); label = lv_label_create(btnPrev); + lv_obj_center(label); lv_label_set_text(label, Symbols::stepBackward); btnNext = lv_btn_create(lv_scr_act()); @@ -91,6 +94,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus lv_obj_align(btnNext, LV_ALIGN_BOTTOM_RIGHT, 0, 0); lv_obj_add_style(btnNext, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); label = lv_label_create(btnNext); + lv_obj_center(label); lv_label_set_text(label, Symbols::stepForward); btnPlayPause = lv_btn_create(lv_scr_act()); @@ -100,6 +104,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus lv_obj_align(btnPlayPause, LV_ALIGN_BOTTOM_MID, 0, 0); lv_obj_add_style(btnPlayPause, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); txtPlayPause = lv_label_create(btnPlayPause); + lv_obj_center(txtPlayPause); lv_label_set_text(txtPlayPause, Symbols::play); txtTrackDuration = lv_label_create(lv_scr_act()); diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index b68c14ce6c..7e5269daf6 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -37,15 +37,15 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, lv_label_set_text(batteryIcon, Symbols::batteryFull); lv_obj_align(batteryIcon, LV_ALIGN_TOP_RIGHT, 0, 0); - batteryPlug = lv_label_create(batteryIcon); + batteryPlug = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(batteryPlug, lv_color_hex(0xFF0000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(batteryPlug, Symbols::plug); - lv_obj_align(batteryPlug,LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align_to(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); - bleIcon = lv_label_create(batteryPlug); + bleIcon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(bleIcon, lv_color_hex(0x0000FF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(bleIcon, Symbols::bluetooth); - lv_obj_align(bleIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align_to(bleIcon, batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0); notificationIcon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(notificationIcon, lv_color_hex(0x00FF00), LV_PART_MAIN | LV_STATE_DEFAULT); @@ -77,20 +77,20 @@ WatchFaceDigital::WatchFaceDigital(DisplayApp* app, lv_obj_set_style_text_color(heartbeatIcon, lv_color_hex(0xCE1B1B), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_align(heartbeatIcon, LV_ALIGN_BOTTOM_LEFT, 0, 0); - heartbeatValue = lv_label_create(heartbeatIcon); + heartbeatValue = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(heartbeatValue, lv_color_hex(0xCE1B1B), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(heartbeatValue, ""); - lv_obj_align(heartbeatValue, LV_ALIGN_OUT_RIGHT_MID, 5, 0); + lv_obj_align_to(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0); stepValue = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(stepValue, lv_color_hex(0x00FFE7), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(stepValue, "0"); lv_obj_align(stepValue, LV_ALIGN_BOTTOM_RIGHT, 0, 0); - stepIcon = lv_label_create(stepValue); + stepIcon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(stepIcon, lv_color_hex(0x00FFE7), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(stepIcon, Symbols::shoe); - lv_obj_align(stepIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align_to(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); Refresh(); @@ -108,7 +108,7 @@ void WatchFaceDigital::Refresh() { // These alignments cause lvgl to refresh the screen even if nothing has technically changed. Only align if needed. lv_obj_align(batteryIcon, LV_ALIGN_TOP_RIGHT, 0, 0); - lv_obj_align(batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align_to(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); } batteryPercentRemaining = batteryController.PercentRemaining(); @@ -123,7 +123,7 @@ void WatchFaceDigital::Refresh() { // These alignments cause lvgl to refresh the screen even if nothing has technically changed. Only align if needed. lv_obj_align(batteryIcon, LV_ALIGN_TOP_RIGHT, 0, 0); - lv_obj_align(batteryPlug, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align_to(batteryPlug, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); } bleState = bleController.IsConnected(); @@ -131,7 +131,7 @@ void WatchFaceDigital::Refresh() { lv_label_set_text(bleIcon, BleIcon::GetIcon(bleState.Get())); // These alignments cause lvgl to refresh the screen even if nothing has technically changed. Only align if needed. - lv_obj_align(bleIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align_to(bleIcon, batteryIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); } notificationState = notificatioManager.AreNewNotificationsAvailable(); @@ -237,6 +237,6 @@ void WatchFaceDigital::Refresh() { if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); lv_obj_align(stepValue, LV_ALIGN_BOTTOM_RIGHT, 0, 0); - lv_obj_align(stepIcon, LV_ALIGN_OUT_LEFT_MID, -5, 0); + lv_obj_align_to(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); } } diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp index c42fe9eabd..e6969341f5 100644 --- a/src/displayapp/screens/settings/SettingDisplay.cpp +++ b/src/displayapp/screens/settings/SettingDisplay.cpp @@ -38,11 +38,11 @@ SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime lv_obj_set_style_text_align(title, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_align(title, LV_ALIGN_TOP_MID, 10, 15); - lv_obj_t* icon = lv_label_create(title); + lv_obj_t* icon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(icon, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(icon, Symbols::sun); lv_obj_set_style_text_align(icon, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align(icon, LV_ALIGN_OUT_LEFT_MID, -10, 0); + lv_obj_align_to(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); optionsTotal = 0; cbOption[optionsTotal] = lv_checkbox_create(container1); diff --git a/src/displayapp/screens/settings/SettingSteps.cpp b/src/displayapp/screens/settings/SettingSteps.cpp index 64cefd43ff..993f2dc57e 100644 --- a/src/displayapp/screens/settings/SettingSteps.cpp +++ b/src/displayapp/screens/settings/SettingSteps.cpp @@ -37,12 +37,12 @@ SettingSteps::SettingSteps( lv_obj_set_style_text_align(title, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_align(title, LV_ALIGN_TOP_MID, 15, 15); - lv_obj_t * icon = lv_label_create(title); + lv_obj_t * icon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(icon, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(icon, Symbols::shoe); lv_obj_set_style_text_align(icon, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align(icon, LV_ALIGN_OUT_LEFT_MID, -10, 0); + lv_obj_align_to(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); stepValue = lv_label_create(lv_scr_act()); @@ -57,6 +57,7 @@ SettingSteps::SettingSteps( lv_obj_align(btnPlus, LV_ALIGN_CENTER, 55, 80); txtBtnPlus = lv_label_create(btnPlus); lv_label_set_text(txtBtnPlus, "+"); + lv_obj_center(txtBtnPlus); lv_obj_add_event_cb(btnPlus, event_handler, LV_EVENT_ALL, btnPlus->user_data); btnMinus = lv_btn_create(lv_scr_act()); @@ -65,6 +66,7 @@ SettingSteps::SettingSteps( lv_obj_align(btnMinus, LV_ALIGN_CENTER, -55, 80); txtBtnMinus = lv_label_create(btnMinus); lv_label_set_text(txtBtnMinus, "-"); + lv_obj_center(txtBtnMinus); lv_obj_add_event_cb(btnMinus, event_handler, LV_EVENT_ALL, btnMinus->user_data); } diff --git a/src/displayapp/screens/settings/SettingTimeFormat.cpp b/src/displayapp/screens/settings/SettingTimeFormat.cpp index babee69c03..eacbe40c8c 100644 --- a/src/displayapp/screens/settings/SettingTimeFormat.cpp +++ b/src/displayapp/screens/settings/SettingTimeFormat.cpp @@ -36,11 +36,11 @@ SettingTimeFormat::SettingTimeFormat(Pinetime::Applications::DisplayApp* app, Pi lv_obj_set_style_text_align(title, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_align(title, LV_ALIGN_TOP_MID, 15, 15); - lv_obj_t* icon = lv_label_create(title); + lv_obj_t* icon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(icon, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(icon, Symbols::clock); lv_obj_set_style_text_align(icon, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align(icon, LV_ALIGN_OUT_LEFT_MID, -10, 0); + lv_obj_align_to(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); optionsTotal = 0; cbOption[optionsTotal] = lv_checkbox_create(container1); diff --git a/src/displayapp/screens/settings/SettingWakeUp.cpp b/src/displayapp/screens/settings/SettingWakeUp.cpp index e41da09462..b5bb664c75 100644 --- a/src/displayapp/screens/settings/SettingWakeUp.cpp +++ b/src/displayapp/screens/settings/SettingWakeUp.cpp @@ -38,11 +38,11 @@ SettingWakeUp::SettingWakeUp(Pinetime::Applications::DisplayApp* app, Pinetime:: lv_obj_set_style_text_align(title, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_align(title, LV_ALIGN_TOP_MID, 15, 15); - lv_obj_t* icon = lv_label_create(title); + lv_obj_t* icon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(icon, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(icon, Symbols::eye); lv_obj_set_style_text_align(icon, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align(icon, LV_ALIGN_OUT_LEFT_MID, -10, 0); + lv_obj_align_to(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); optionsTotal = 0; cbOption[optionsTotal] = lv_checkbox_create(container1); diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp index 2ea3da0d1f..16e76286d9 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.cpp +++ b/src/displayapp/screens/settings/SettingWatchFace.cpp @@ -36,11 +36,11 @@ SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pine lv_obj_set_style_text_align(title, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_align(title, LV_ALIGN_TOP_MID, 10, 15); - lv_obj_t* icon = lv_label_create(title); + lv_obj_t* icon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(icon, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(icon, Symbols::home); lv_obj_set_style_text_align(icon, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align(icon, LV_ALIGN_OUT_LEFT_MID, -10, 0); + lv_obj_align_to(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); optionsTotal = 0; cbOption[optionsTotal] = lv_checkbox_create(container1); From f99b15fcf7b7c5fe0d09e0f1f4bf3a678d380cf2 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Mon, 11 Oct 2021 08:44:56 -0400 Subject: [PATCH 11/25] Fix small glitch with the first frame of scrolldown animation. --- src/displayapp/LittleVgl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index 0b0fa6e6c1..6495379219 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -99,8 +99,8 @@ void LittleVgl::DisplayDownScroll(){ for (y1 = 240 - height; y1 >= 0; y1 -= height) { y2 = y1 + height - 1; - // If the previous box has reached the end of the visible line on the lcd controller... - if (area.y2 == visibleNbLines - 1) { + // If the box has reached the end of the visible line on the lcd controller... + if (y2 == visibleNbLines - 1) { // move past the non visible lines writeOffset += (totalNbLines - visibleNbLines); // and wrap around to the start of address space From 4602efc2060582299b12b434e1bd81a121a57a37 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Mon, 11 Oct 2021 10:11:43 -0400 Subject: [PATCH 12/25] Port latest PRs --- src/displayapp/screens/Error.cpp | 34 ++--- src/displayapp/screens/Error.h | 2 +- .../screens/settings/SettingSetDate.cpp | 132 ++++++++++-------- .../screens/settings/SettingSetDate.h | 9 +- .../screens/settings/SettingSetTime.cpp | 126 +++++++++-------- .../screens/settings/SettingSetTime.h | 7 +- 6 files changed, 172 insertions(+), 138 deletions(-) diff --git a/src/displayapp/screens/Error.cpp b/src/displayapp/screens/Error.cpp index 75946abae5..13d698aa30 100644 --- a/src/displayapp/screens/Error.cpp +++ b/src/displayapp/screens/Error.cpp @@ -3,8 +3,8 @@ using namespace Pinetime::Applications::Screens; namespace { - void ButtonEventCallback(lv_obj_t* obj, lv_event_t /*event*/) { - auto* errorScreen = static_cast(obj->user_data); + void ButtonEventCallback(lv_event_t* event) { + auto* errorScreen = static_cast(lv_event_get_user_data(event)); errorScreen->ButtonEventHandler(); } } @@ -12,33 +12,35 @@ namespace { Error::Error(Pinetime::Applications::DisplayApp* app, System::BootErrors error) : Screen(app) { - lv_obj_t* warningLabel = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(warningLabel, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_obj_t* warningLabel = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_color(warningLabel, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(warningLabel, "Warning"); - lv_obj_align(warningLabel, nullptr, LV_ALIGN_IN_TOP_MID, 0, 0); + lv_obj_align(warningLabel, LV_ALIGN_TOP_MID, 0, 0); - lv_obj_t* causeLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(causeLabel, LV_LABEL_LONG_BREAK); + lv_obj_t* causeLabel = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(causeLabel, LV_LABEL_LONG_WRAP); lv_obj_set_width(causeLabel, LV_HOR_RES); - lv_obj_align(causeLabel, warningLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); + lv_obj_align_to(causeLabel, warningLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); if (error == System::BootErrors::TouchController) { lv_label_set_text_static(causeLabel, "Touch controller error detected."); } - lv_obj_t* tipLabel = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_long_mode(tipLabel, LV_LABEL_LONG_BREAK); + lv_obj_t* tipLabel = lv_label_create(lv_scr_act()); + lv_label_set_long_mode(tipLabel, LV_LABEL_LONG_WRAP); lv_obj_set_width(tipLabel, LV_HOR_RES); lv_label_set_text_static(tipLabel, "If you encounter problems and your device is under warranty, contact the devices seller."); - lv_obj_align(tipLabel, causeLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); + lv_obj_align_to(tipLabel, causeLabel, LV_ALIGN_OUT_BOTTOM_MID, 0, 0); - btnOk = lv_btn_create(lv_scr_act(), nullptr); + btnOk = lv_btn_create(lv_scr_act()); btnOk->user_data = this; - lv_obj_set_event_cb(btnOk, ButtonEventCallback); + lv_obj_add_event_cb(btnOk, ButtonEventCallback, LV_EVENT_ALL, btnOk->user_data); lv_obj_set_size(btnOk, LV_HOR_RES, 50); - lv_obj_align(btnOk, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0); - lv_obj_set_style_local_value_str(btnOk, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Proceed"); - lv_obj_set_style_local_bg_color(btnOk, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_obj_align(btnOk, LV_ALIGN_BOTTOM_MID, 0, 0); + lv_obj_set_style_bg_color(btnOk, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); + lblOk = lv_label_create(btnOk); + lv_obj_center(lblOk); + lv_label_set_text(btnOk, "Proceed"); } void Error::ButtonEventHandler() { diff --git a/src/displayapp/screens/Error.h b/src/displayapp/screens/Error.h index 20dde7eeb1..850da9333d 100644 --- a/src/displayapp/screens/Error.h +++ b/src/displayapp/screens/Error.h @@ -14,7 +14,7 @@ namespace Pinetime { void ButtonEventHandler(); private: - lv_obj_t* btnOk; + lv_obj_t *btnOk, *lblOk; }; } } diff --git a/src/displayapp/screens/settings/SettingSetDate.cpp b/src/displayapp/screens/settings/SettingSetDate.cpp index ba3413ef66..d13fb4bec4 100644 --- a/src/displayapp/screens/settings/SettingSetDate.cpp +++ b/src/displayapp/screens/settings/SettingSetDate.cpp @@ -15,106 +15,118 @@ namespace { constexpr int16_t POS_Y_TEXT = -6; constexpr int16_t POS_Y_MINUS = 40; - void event_handler(lv_obj_t * obj, lv_event_t event) { - auto* screen = static_cast(obj->user_data); - screen->HandleButtonPress(obj, event); + void event_handler(lv_event_t *event) { + auto* screen = static_cast(lv_event_get_user_data(event)); + screen->HandleButtonPress(lv_event_get_target(event), event); } } SettingSetDate::SettingSetDate(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::DateTime &dateTimeController) : Screen(app), dateTimeController {dateTimeController} { - lv_obj_t * title = lv_label_create(lv_scr_act(), nullptr); + lv_obj_t * title = lv_label_create(lv_scr_act()); lv_label_set_text_static(title, "Set current date"); - lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); - lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15); + lv_obj_set_style_text_align(title, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(title, LV_ALIGN_TOP_MID, 15, 15); - lv_obj_t * icon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_obj_t * icon = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_color(icon, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(icon, Symbols::clock); - lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); - lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); + lv_obj_set_style_text_align(icon, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align_to(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); dayValue = static_cast(dateTimeController.Day()); - lblDay = lv_label_create(lv_scr_act(), nullptr); + lblDay = lv_label_create(lv_scr_act()); lv_label_set_text_fmt(lblDay, "%d", dayValue); - lv_label_set_align(lblDay, LV_LABEL_ALIGN_CENTER); - lv_obj_align(lblDay, lv_scr_act(), LV_ALIGN_CENTER, POS_X_DAY, POS_Y_TEXT); - lv_obj_set_auto_realign(lblDay, true); + lv_obj_set_style_text_align(lblDay, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(lblDay, LV_ALIGN_CENTER, POS_X_DAY, POS_Y_TEXT); monthValue = static_cast(dateTimeController.Month()); - lblMonth = lv_label_create(lv_scr_act(), nullptr); + lblMonth = lv_label_create(lv_scr_act()); UpdateMonthLabel(); - lv_label_set_align(lblMonth, LV_LABEL_ALIGN_CENTER); - lv_obj_align(lblMonth, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MONTH, POS_Y_TEXT); - lv_obj_set_auto_realign(lblMonth, true); + lv_obj_set_style_text_align(lblMonth, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(lblMonth, LV_ALIGN_CENTER, POS_X_MONTH, POS_Y_TEXT); + yearValue = static_cast(dateTimeController.Year()); if (yearValue < 2021) yearValue = 2021; - lblYear = lv_label_create(lv_scr_act(), nullptr); + lblYear = lv_label_create(lv_scr_act()); lv_label_set_text_fmt(lblYear, "%d", yearValue); - lv_label_set_align(lblYear, LV_LABEL_ALIGN_CENTER); - lv_obj_align(lblYear, lv_scr_act(), LV_ALIGN_CENTER, POS_X_YEAR, POS_Y_TEXT); - lv_obj_set_auto_realign(lblYear, true); + lv_obj_set_style_text_align(lblYear, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(lblYear, LV_ALIGN_CENTER, POS_X_YEAR, POS_Y_TEXT); - btnDayPlus = lv_btn_create(lv_scr_act(), nullptr); + btnDayPlus = lv_btn_create(lv_scr_act()); btnDayPlus->user_data = this; lv_obj_set_size(btnDayPlus, 50, 40); - lv_obj_align(btnDayPlus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_DAY, POS_Y_PLUS); - lv_obj_set_style_local_value_str(btnDayPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+"); - lv_obj_set_event_cb(btnDayPlus, event_handler); + lv_obj_align(btnDayPlus, LV_ALIGN_CENTER, POS_X_DAY, POS_Y_PLUS); + lblDayPlus = lv_label_create(btnDayPlus); + lv_label_set_text(lblDayPlus, "+"); + lv_obj_center(lblDayPlus); + lv_obj_add_event_cb(btnDayPlus, event_handler, LV_EVENT_ALL, btnDayPlus->user_data); - btnDayMinus = lv_btn_create(lv_scr_act(), nullptr); + btnDayMinus = lv_btn_create(lv_scr_act()); btnDayMinus->user_data = this; lv_obj_set_size(btnDayMinus, 50, 40); - lv_obj_align(btnDayMinus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_DAY, POS_Y_MINUS); - lv_obj_set_style_local_value_str(btnDayMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-"); - lv_obj_set_event_cb(btnDayMinus, event_handler); + lv_obj_align(btnDayMinus, LV_ALIGN_CENTER, POS_X_DAY, POS_Y_MINUS); + lblDayMinus = lv_label_create(btnDayMinus); + lv_label_set_text(lblDayMinus, "-"); + lv_obj_center(lblDayMinus); + lv_obj_add_event_cb(btnDayMinus, event_handler, LV_EVENT_ALL, btnDayMinus->user_data); - btnMonthPlus = lv_btn_create(lv_scr_act(), nullptr); + btnMonthPlus = lv_btn_create(lv_scr_act()); btnMonthPlus->user_data = this; lv_obj_set_size(btnMonthPlus, 50, 40); - lv_obj_align(btnMonthPlus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MONTH, POS_Y_PLUS); - lv_obj_set_style_local_value_str(btnMonthPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+"); - lv_obj_set_event_cb(btnMonthPlus, event_handler); + lv_obj_align(btnMonthPlus, LV_ALIGN_CENTER, POS_X_MONTH, POS_Y_PLUS); + lblMonthPlus = lv_label_create(btnMonthPlus); + lv_label_set_text(lblMonthPlus, "+"); + lv_obj_center(lblMonthPlus); + lv_obj_add_event_cb(btnMonthPlus, event_handler, LV_EVENT_ALL, btnMonthPlus->user_data); - btnMonthMinus = lv_btn_create(lv_scr_act(), nullptr); + btnMonthMinus = lv_btn_create(lv_scr_act()); btnMonthMinus->user_data = this; lv_obj_set_size(btnMonthMinus, 50, 40); - lv_obj_align(btnMonthMinus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MONTH, POS_Y_MINUS); - lv_obj_set_style_local_value_str(btnMonthMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-"); - lv_obj_set_event_cb(btnMonthMinus, event_handler); + lv_obj_align(btnMonthMinus, LV_ALIGN_CENTER, POS_X_MONTH, POS_Y_MINUS); + lblMonthMinus = lv_label_create(btnMonthMinus); + lv_label_set_text(lblMonthMinus, "-"); + lv_obj_center(lblMonthMinus); + lv_obj_add_event_cb(btnMonthMinus, event_handler, LV_EVENT_ALL, btnMonthMinus->user_data); - btnYearPlus = lv_btn_create(lv_scr_act(), nullptr); + btnYearPlus = lv_btn_create(lv_scr_act()); btnYearPlus->user_data = this; lv_obj_set_size(btnYearPlus, 50, 40); - lv_obj_align(btnYearPlus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_YEAR, POS_Y_PLUS); - lv_obj_set_style_local_value_str(btnYearPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+"); - lv_obj_set_event_cb(btnYearPlus, event_handler); + lv_obj_align(btnYearPlus, LV_ALIGN_CENTER, POS_X_YEAR, POS_Y_PLUS); + lblYearPlus = lv_label_create(btnYearPlus); + lv_label_set_text(lblYearPlus, "+"); + lv_obj_center(lblYearPlus); + lv_obj_add_event_cb(btnYearPlus, event_handler, LV_EVENT_ALL, btnYearPlus->user_data); - btnYearMinus = lv_btn_create(lv_scr_act(), nullptr); + btnYearMinus = lv_btn_create(lv_scr_act()); btnYearMinus->user_data = this; lv_obj_set_size(btnYearMinus, 50, 40); - lv_obj_align(btnYearMinus, lv_scr_act(), LV_ALIGN_CENTER, POS_X_YEAR, POS_Y_MINUS); - lv_obj_set_style_local_value_str(btnYearMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-"); - lv_obj_set_event_cb(btnYearMinus, event_handler); + lv_obj_align(btnYearMinus, LV_ALIGN_CENTER, POS_X_YEAR, POS_Y_MINUS); + lblYearMinus = lv_label_create(btnYearMinus); + lv_label_set_text(lblYearMinus, "-"); + lv_obj_center(lblYearMinus); + lv_obj_add_event_cb(btnYearMinus, event_handler, LV_EVENT_ALL, btnYearMinus->user_data); - btnSetTime = lv_btn_create(lv_scr_act(), nullptr); + btnSetTime = lv_btn_create(lv_scr_act()); btnSetTime->user_data = this; lv_obj_set_size(btnSetTime, 120, 48); - lv_obj_align(btnSetTime, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0); - lv_obj_set_style_local_value_str(btnSetTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Set"); - lv_obj_set_event_cb(btnSetTime, event_handler); + lv_obj_align(btnSetTime, LV_ALIGN_BOTTOM_MID, 0, 0); + lblSetTime = lv_label_create(btnSetTime); + lv_label_set_text(lblSetTime, "Set"); + lv_obj_center(lblSetTime); + lv_obj_add_event_cb(btnSetTime, event_handler, LV_EVENT_ALL, btnSetTime->user_data); } SettingSetDate::~SettingSetDate() { lv_obj_clean(lv_scr_act()); } -void SettingSetDate::HandleButtonPress(lv_obj_t *object, lv_event_t event) { - if (event != LV_EVENT_CLICKED) +void SettingSetDate::HandleButtonPress(lv_obj_t *object, lv_event_t* event) { + if (lv_event_get_code(event) != LV_EVENT_CLICKED) return; if (object == btnDayPlus) { @@ -122,36 +134,36 @@ void SettingSetDate::HandleButtonPress(lv_obj_t *object, lv_event_t event) { if (dayValue > MaximumDayOfMonth()) dayValue = 1; lv_label_set_text_fmt(lblDay, "%d", dayValue); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED); + lv_obj_clear_state(btnSetTime, LV_STATE_DISABLED); } else if (object == btnDayMinus) { dayValue--; if (dayValue < 1) dayValue = MaximumDayOfMonth(); lv_label_set_text_fmt(lblDay, "%d", dayValue); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED); + lv_obj_clear_state(btnSetTime, LV_STATE_DISABLED); } else if (object == btnMonthPlus) { monthValue++; if (monthValue > 12) monthValue = 1; UpdateMonthLabel(); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED); + lv_obj_clear_state(btnSetTime, LV_STATE_DISABLED); CheckDay(); } else if (object == btnMonthMinus) { monthValue--; if (monthValue < 1) monthValue = 12; UpdateMonthLabel(); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED); + lv_obj_clear_state(btnSetTime, LV_STATE_DISABLED); CheckDay(); } else if (object == btnYearPlus) { yearValue++; lv_label_set_text_fmt(lblYear, "%d", yearValue); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED); + lv_obj_clear_state(btnSetTime, LV_STATE_DISABLED); CheckDay(); } else if (object == btnYearMinus) { yearValue--; lv_label_set_text_fmt(lblYear, "%d", yearValue); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED); + lv_obj_clear_state(btnSetTime, LV_STATE_DISABLED); CheckDay(); } else if (object == btnSetTime) { NRF_LOG_INFO("Setting date (manually) to %04d-%02d-%02d", yearValue, monthValue, dayValue); @@ -163,7 +175,7 @@ void SettingSetDate::HandleButtonPress(lv_obj_t *object, lv_event_t event) { dateTimeController.Minutes(), dateTimeController.Seconds(), nrf_rtc_counter_get(portNRF_RTC_REG)); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_DISABLED); + lv_obj_add_state(btnSetTime, LV_STATE_DISABLED); } } @@ -188,7 +200,7 @@ void SettingSetDate::CheckDay() { if (dayValue > maxDay) { dayValue = maxDay; lv_label_set_text_fmt(lblDay, "%d", dayValue); - lv_obj_align(lblDay, lv_scr_act(), LV_ALIGN_CENTER, POS_X_DAY, POS_Y_TEXT); + lv_obj_align(lblDay, LV_ALIGN_CENTER, POS_X_DAY, POS_Y_TEXT); } } diff --git a/src/displayapp/screens/settings/SettingSetDate.h b/src/displayapp/screens/settings/SettingSetDate.h index 477337fff2..bc76f16ec0 100644 --- a/src/displayapp/screens/settings/SettingSetDate.h +++ b/src/displayapp/screens/settings/SettingSetDate.h @@ -13,7 +13,7 @@ namespace Pinetime { SettingSetDate(DisplayApp* app, Pinetime::Controllers::DateTime &dateTimeController); ~SettingSetDate() override; - void HandleButtonPress(lv_obj_t *object, lv_event_t event); + void HandleButtonPress(lv_obj_t *object, lv_event_t* event); private: Controllers::DateTime& dateTimeController; @@ -31,6 +31,13 @@ namespace Pinetime { lv_obj_t * btnYearPlus; lv_obj_t * btnYearMinus; lv_obj_t * btnSetTime; + lv_obj_t * lblDayPlus; + lv_obj_t * lblDayMinus; + lv_obj_t * lblMonthPlus; + lv_obj_t * lblMonthMinus; + lv_obj_t * lblYearPlus; + lv_obj_t * lblYearMinus; + lv_obj_t * lblSetTime; int MaximumDayOfMonth() const; void CheckDay(); diff --git a/src/displayapp/screens/settings/SettingSetTime.cpp b/src/displayapp/screens/settings/SettingSetTime.cpp index 194bf5eb47..2d2a926031 100644 --- a/src/displayapp/screens/settings/SettingSetTime.cpp +++ b/src/displayapp/screens/settings/SettingSetTime.cpp @@ -16,103 +16,111 @@ namespace { constexpr int16_t POS_Y_MINUS = 40; constexpr int16_t OFS_Y_COLON = -2; - void event_handler(lv_obj_t * obj, lv_event_t event) { - auto* screen = static_cast(obj->user_data); - screen->HandleButtonPress(obj, event); + void event_handler(lv_event_t* event) { + auto* screen = static_cast(lv_event_get_user_data(event)); + screen->HandleButtonPress(lv_event_get_target(event), event); } } SettingSetTime::SettingSetTime(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::DateTime &dateTimeController) : Screen(app), dateTimeController {dateTimeController} { - lv_obj_t * title = lv_label_create(lv_scr_act(), nullptr); + lv_obj_t * title = lv_label_create(lv_scr_act()); lv_label_set_text_static(title, "Set current time"); - lv_label_set_align(title, LV_LABEL_ALIGN_CENTER); - lv_obj_align(title, lv_scr_act(), LV_ALIGN_IN_TOP_MID, 15, 15); + lv_obj_center(title); + lv_obj_align(title, LV_ALIGN_TOP_MID, 15, 15); - lv_obj_t * icon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_color(icon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_obj_t * icon = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_color(icon, lv_palette_main(LV_PALETTE_ORANGE), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(icon, Symbols::clock); - lv_label_set_align(icon, LV_LABEL_ALIGN_CENTER); - lv_obj_align(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); + lv_obj_center(icon); + lv_obj_align_to(icon, title, LV_ALIGN_OUT_LEFT_MID, -10, 0); hoursValue = static_cast(dateTimeController.Hours()); - lblHours = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(lblHours, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lblHours = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(lblHours, &jetbrains_mono_42, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_fmt(lblHours, "%02d", hoursValue); - lv_label_set_align(lblHours, LV_LABEL_ALIGN_CENTER); - lv_obj_align(lblHours, lv_scr_act(), LV_ALIGN_CENTER, POS_X_HOURS, POS_Y_TEXT); - lv_obj_set_auto_realign(lblHours, true); + lv_obj_set_style_text_align(lblHours, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(lblHours, LV_ALIGN_CENTER, POS_X_HOURS, POS_Y_TEXT); - lv_obj_t * lblColon1 = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(lblColon1, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_t * lblColon1 = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(lblColon1, &jetbrains_mono_42, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(lblColon1, ":"); - lv_label_set_align(lblColon1, LV_LABEL_ALIGN_CENTER); - lv_obj_align(lblColon1, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_HOURS + POS_X_MINUTES) / 2, POS_Y_TEXT + OFS_Y_COLON); + lv_obj_set_style_text_align(lblColon1, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(lblColon1, LV_ALIGN_CENTER, (POS_X_HOURS + POS_X_MINUTES) / 2, POS_Y_TEXT + OFS_Y_COLON); minutesValue = static_cast(dateTimeController.Minutes()); - lblMinutes = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(lblMinutes, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lblMinutes = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(lblMinutes, &jetbrains_mono_42, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue); - lv_label_set_align(lblMinutes, LV_LABEL_ALIGN_CENTER); - lv_obj_align(lblMinutes, lv_scr_act(), LV_ALIGN_CENTER, POS_X_MINUTES, POS_Y_TEXT); - lv_obj_set_auto_realign(lblMinutes, true); + lv_obj_set_style_text_align(lblMinutes, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(lblMinutes, LV_ALIGN_CENTER, POS_X_MINUTES, POS_Y_TEXT); - lv_obj_t * lblColon2 = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(lblColon2, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_t * lblColon2 = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(lblColon2, &jetbrains_mono_42, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(lblColon2, ":"); - lv_label_set_align(lblColon2, LV_LABEL_ALIGN_CENTER); - lv_obj_align(lblColon2, lv_scr_act(), LV_ALIGN_CENTER, (POS_X_MINUTES + POS_X_SECONDS) / 2, POS_Y_TEXT + OFS_Y_COLON); + lv_obj_set_style_text_align(lblColon2, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(lblColon2, LV_ALIGN_CENTER, (POS_X_MINUTES + POS_X_SECONDS) / 2, POS_Y_TEXT + OFS_Y_COLON); - lv_obj_t * lblSeconds = lv_label_create(lv_scr_act(), nullptr); - lv_obj_set_style_local_text_font(lblSeconds, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_t * lblSeconds = lv_label_create(lv_scr_act()); + lv_obj_set_style_text_font(lblSeconds, &jetbrains_mono_42, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(lblSeconds, "00"); - lv_label_set_align(lblSeconds, LV_LABEL_ALIGN_CENTER); - lv_obj_align(lblSeconds, lv_scr_act(), LV_ALIGN_CENTER, POS_X_SECONDS, POS_Y_TEXT); + lv_obj_set_style_text_align(lblSeconds, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(lblSeconds, LV_ALIGN_CENTER, POS_X_SECONDS, POS_Y_TEXT); - btnHoursPlus = lv_btn_create(lv_scr_act(), nullptr); + btnHoursPlus = lv_btn_create(lv_scr_act()); btnHoursPlus->user_data = this; lv_obj_set_size(btnHoursPlus, 50, 40); - lv_obj_align(btnHoursPlus, lv_scr_act(), LV_ALIGN_CENTER, -72, -50); - lv_obj_set_style_local_value_str(btnHoursPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+"); - lv_obj_set_event_cb(btnHoursPlus, event_handler); + lv_obj_align(btnHoursPlus, LV_ALIGN_CENTER, -72, -50); + lblHoursPlus = lv_label_create(btnHoursPlus); + lv_label_set_text(lblHoursPlus, "+"); + lv_obj_center(lblHoursPlus); + lv_obj_add_event_cb(btnHoursPlus, event_handler, LV_EVENT_ALL, btnHoursPlus->user_data); - btnHoursMinus = lv_btn_create(lv_scr_act(), nullptr); + btnHoursMinus = lv_btn_create(lv_scr_act()); btnHoursMinus->user_data = this; lv_obj_set_size(btnHoursMinus, 50, 40); - lv_obj_align(btnHoursMinus, lv_scr_act(), LV_ALIGN_CENTER, -72, 40); - lv_obj_set_style_local_value_str(btnHoursMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-"); - lv_obj_set_event_cb(btnHoursMinus, event_handler); + lv_obj_align(btnHoursMinus, LV_ALIGN_CENTER, -72, 40); + lblHoursMinus = lv_label_create(btnHoursMinus); + lv_label_set_text(lblHoursMinus, "-"); + lv_obj_center(lblHoursMinus); + lv_obj_add_event_cb(btnHoursMinus, event_handler, LV_EVENT_ALL, btnHoursMinus->user_data); - btnMinutesPlus = lv_btn_create(lv_scr_act(), nullptr); + btnMinutesPlus = lv_btn_create(lv_scr_act()); btnMinutesPlus->user_data = this; lv_obj_set_size(btnMinutesPlus, 50, 40); - lv_obj_align(btnMinutesPlus, lv_scr_act(), LV_ALIGN_CENTER, 0, -50); - lv_obj_set_style_local_value_str(btnMinutesPlus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "+"); - lv_obj_set_event_cb(btnMinutesPlus, event_handler); + lv_obj_align(btnMinutesPlus, LV_ALIGN_CENTER, 0, -50); + lblMinutesPlus = lv_label_create(btnMinutesPlus); + lv_label_set_text(lblMinutesPlus, "+"); + lv_obj_center(lblMinutesPlus); + lv_obj_add_event_cb(btnMinutesPlus, event_handler, LV_EVENT_ALL, btnMinutesPlus->user_data); - btnMinutesMinus = lv_btn_create(lv_scr_act(), nullptr); + btnMinutesMinus = lv_btn_create(lv_scr_act()); btnMinutesMinus->user_data = this; lv_obj_set_size(btnMinutesMinus, 50, 40); - lv_obj_align(btnMinutesMinus, lv_scr_act(), LV_ALIGN_CENTER, 0, 40); - lv_obj_set_style_local_value_str(btnMinutesMinus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "-"); - lv_obj_set_event_cb(btnMinutesMinus, event_handler); + lv_obj_align(btnMinutesMinus, LV_ALIGN_CENTER, 0, 40); + lblMinutesMinus = lv_label_create(btnMinutesMinus); + lv_label_set_text(lblMinutesMinus, "-"); + lv_obj_center(lblMinutesMinus); + lv_obj_add_event_cb(btnMinutesMinus, event_handler, LV_EVENT_ALL, btnMinutesMinus->user_data); - btnSetTime = lv_btn_create(lv_scr_act(), nullptr); + btnSetTime = lv_btn_create(lv_scr_act()); btnSetTime->user_data = this; lv_obj_set_size(btnSetTime, 120, 48); - lv_obj_align(btnSetTime, lv_scr_act(), LV_ALIGN_IN_BOTTOM_MID, 0, 0); - lv_obj_set_style_local_value_str(btnSetTime, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, "Set"); - lv_obj_set_event_cb(btnSetTime, event_handler); + lv_obj_align(btnSetTime, LV_ALIGN_BOTTOM_MID, 0, 0); + lblSetTime = lv_label_create(btnSetTime); + lv_label_set_text(lblSetTime, "Set"); + lv_obj_center(lblSetTime); + lv_obj_add_event_cb(btnSetTime, event_handler, LV_EVENT_ALL, btnSetTime->user_data); } SettingSetTime::~SettingSetTime() { lv_obj_clean(lv_scr_act()); } -void SettingSetTime::HandleButtonPress(lv_obj_t *object, lv_event_t event) { - if (event != LV_EVENT_CLICKED) +void SettingSetTime::HandleButtonPress(lv_obj_t *object, lv_event_t* event) { + if (lv_event_get_code(event) != LV_EVENT_CLICKED) return; if (object == btnHoursPlus) { @@ -120,25 +128,25 @@ void SettingSetTime::HandleButtonPress(lv_obj_t *object, lv_event_t event) { if (hoursValue > 23) hoursValue = 0; lv_label_set_text_fmt(lblHours, "%02d", hoursValue); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED); + lv_obj_clear_state(btnSetTime, LV_STATE_DISABLED); } else if (object == btnHoursMinus) { hoursValue--; if (hoursValue < 0) hoursValue = 23; lv_label_set_text_fmt(lblHours, "%02d", hoursValue); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED); + lv_obj_clear_state(btnSetTime, LV_STATE_DISABLED); } else if (object == btnMinutesPlus) { minutesValue++; if (minutesValue > 59) minutesValue = 0; lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED); + lv_obj_clear_state(btnSetTime, LV_STATE_DISABLED); } else if (object == btnMinutesMinus) { minutesValue--; if (minutesValue < 0) minutesValue = 59; lv_label_set_text_fmt(lblMinutes, "%02d", minutesValue); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_RELEASED); + lv_obj_clear_state(btnSetTime, LV_STATE_DISABLED); } else if (object == btnSetTime) { NRF_LOG_INFO("Setting time (manually) to %02d:%02d:00", hoursValue, minutesValue); dateTimeController.SetTime(dateTimeController.Year(), @@ -149,6 +157,6 @@ void SettingSetTime::HandleButtonPress(lv_obj_t *object, lv_event_t event) { static_cast(minutesValue), 0, nrf_rtc_counter_get(portNRF_RTC_REG)); - lv_btn_set_state(btnSetTime, LV_BTN_STATE_DISABLED); + lv_obj_add_state(btnSetTime, LV_STATE_DISABLED); } } diff --git a/src/displayapp/screens/settings/SettingSetTime.h b/src/displayapp/screens/settings/SettingSetTime.h index 8ba41eae45..672cf1a22e 100644 --- a/src/displayapp/screens/settings/SettingSetTime.h +++ b/src/displayapp/screens/settings/SettingSetTime.h @@ -13,7 +13,7 @@ namespace Pinetime { SettingSetTime(DisplayApp* app, Pinetime::Controllers::DateTime &dateTimeController); ~SettingSetTime() override; - void HandleButtonPress(lv_obj_t *object, lv_event_t event); + void HandleButtonPress(lv_obj_t *object, lv_event_t* event); private: Controllers::DateTime& dateTimeController; @@ -27,6 +27,11 @@ namespace Pinetime { lv_obj_t * btnMinutesPlus; lv_obj_t * btnMinutesMinus; lv_obj_t * btnSetTime; + lv_obj_t * lblHoursPlus; + lv_obj_t * lblHoursMinus; + lv_obj_t * lblMinutesPlus; + lv_obj_t * lblMinutesMinus; + lv_obj_t * lblSetTime; }; } } From 4a8049a64ada7f754bfe8b72fc93840e7f344e9e Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Mon, 11 Oct 2021 16:55:12 -0400 Subject: [PATCH 13/25] VERY IMPORTANT! fix twos for lvgl8 - used basic objects instead of table - only updates squares that are changed - add indicator that shows which square is new --- src/displayapp/screens/Twos.cpp | 182 ++++++++++++++++++-------------- src/displayapp/screens/Twos.h | 7 +- 2 files changed, 111 insertions(+), 78 deletions(-) diff --git a/src/displayapp/screens/Twos.cpp b/src/displayapp/screens/Twos.cpp index cee332e9b4..a68126aac3 100644 --- a/src/displayapp/screens/Twos.cpp +++ b/src/displayapp/screens/Twos.cpp @@ -10,75 +10,61 @@ using namespace Pinetime::Applications::Screens; namespace { - - static lv_color_t TWOS_COLOR_0 = lv_color_hex(0xcdc0b4); - static lv_color_t TWOS_COLOR_2 = lv_color_hex(0xefdfc6); - static lv_color_t TWOS_COLOR_8 = lv_color_hex(0xef9263); - static lv_color_t TWOS_COLOR_32 = lv_color_hex(0xf76142); - static lv_color_t TWOS_COLOR_128 = lv_color_hex(0x007dc5); - - static void draw_part_event_cb(lv_event_t* event){ - - lv_obj_draw_part_dsc_t *dsc = static_cast(lv_event_get_param(event)); - if(dsc->part == LV_PART_ITEMS) { - switch (dsc->value) { - case 0: - dsc->rect_dsc->bg_color = TWOS_COLOR_0; - break; - case 2: - case 4: - dsc->rect_dsc->bg_color = TWOS_COLOR_2; - break; - case 8: - case 16: - dsc->rect_dsc->bg_color = TWOS_COLOR_8; - break; - case 32: - case 64: - dsc->rect_dsc->bg_color = TWOS_COLOR_32; - break; - default: - dsc->rect_dsc->bg_color = TWOS_COLOR_128; - break; - - } - } - } + const lv_color_t TWOS_COLOR_0 = lv_color_hex(0xcdc0b4); + const lv_color_t TWOS_COLOR_2_4 = lv_color_hex(0xefdfc6); + const lv_color_t TWOS_COLOR_8_16 = lv_color_hex(0xef9263); + const lv_color_t TWOS_COLOR_32_64 = lv_color_hex(0xf76142); + const lv_color_t TWOS_COLOR_128_PLUS = lv_color_hex(0x007dc5); + const lv_color_t TWOS_BORDER_DEFAULT = lv_color_hex(0xbbada0); + const lv_color_t TWOS_BORDER_NEW = lv_color_darken(lv_color_hex(0xbbada0), LV_OPA_50); } Twos::Twos(Pinetime::Applications::DisplayApp* app) : Screen(app) { // create styles to apply to different valued tiles lv_style_init(&style_cell_default); - lv_style_init(&style_cell1); - lv_style_init(&style_cell2); - lv_style_init(&style_cell3); - lv_style_init(&style_cell4); - lv_style_init(&style_cell5); - lv_style_set_border_color(&style_cell_default, lv_color_hex(0xbbada0)); + lv_style_set_border_color(&style_cell_default, TWOS_BORDER_DEFAULT); lv_style_set_border_width(&style_cell_default, 3); lv_style_set_bg_opa(&style_cell_default, LV_OPA_COVER); + lv_style_set_bg_color(&style_cell_default, TWOS_COLOR_0); lv_style_set_pad_top(&style_cell_default, 25); lv_style_set_text_color(&style_cell_default, lv_color_black()); - + lv_style_set_radius(&style_cell_default, 0); + lv_style_set_pad_all(&style_cell_default, 0); // format grid display - gridDisplay = lv_table_create(lv_scr_act()); - lv_obj_add_style(gridDisplay, &style_cell_default, LV_PART_ITEMS | LV_STATE_DEFAULT); - lv_table_set_col_cnt(gridDisplay, 4); - lv_table_set_row_cnt(gridDisplay, 4); - lv_table_set_col_width(gridDisplay, 0, LV_HOR_RES / 4); - lv_table_set_col_width(gridDisplay, 1, LV_HOR_RES / 4); - lv_table_set_col_width(gridDisplay, 2, LV_HOR_RES / 4); - lv_table_set_col_width(gridDisplay, 3, LV_HOR_RES / 4); - lv_obj_align(gridDisplay, LV_ALIGN_BOTTOM_MID, 0, 0); - - // initialize grid + twosContainer = lv_obj_create(lv_scr_act()); + lv_obj_set_size(twosContainer, LV_HOR_RES, LV_VER_RES-40); + lv_obj_align(twosContainer, LV_ALIGN_BOTTOM_MID, 0, 0); + int cell_w = LV_HOR_RES/4; + int cell_h = (LV_VER_RES-40)/4; + lv_obj_t *align_to = twosContainer; + lv_align_t align_by = LV_ALIGN_TOP_LEFT; for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { - grid[row][col].value = 0; + Tile *curTile = &grid[row][col]; + + curTile->box = lv_obj_create(twosContainer); + lv_obj_add_style(curTile->box, &style_cell_default, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_size(curTile->box, cell_w, cell_h); + + curTile->lbl = lv_label_create(curTile->box); + lv_obj_clear_flag(curTile->lbl, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_center(curTile->lbl); + lv_label_set_text(curTile->lbl, ""); + lv_label_set_long_mode(curTile->lbl, LV_LABEL_LONG_CLIP); + + lv_obj_align_to(curTile->box, align_to, align_by, 0, 0); + if(col != 3){ + align_to = curTile->box; + align_by = LV_ALIGN_OUT_RIGHT_MID; + } else{ + align_to = grid[row][0].box; + align_by = LV_ALIGN_OUT_BOTTOM_MID; + } + } } placeNewTile(); @@ -88,7 +74,7 @@ Twos::Twos(Pinetime::Applications::DisplayApp* app) : Screen(app) { scoreText = lv_label_create(lv_scr_act()); lv_obj_set_width(scoreText, LV_HOR_RES); lv_obj_set_style_text_align(scoreText, LV_ALIGN_LEFT_MID, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align(scoreText, LV_ALIGN_TOP_LEFT, 0, 10); + lv_obj_align(scoreText, LV_ALIGN_TOP_LEFT, -10, 10); lv_label_set_recolor(scoreText, true); lv_label_set_text_fmt(scoreText, "Score #FFFF00 %i#", score); @@ -97,17 +83,10 @@ Twos::Twos(Pinetime::Applications::DisplayApp* app) : Screen(app) { lv_obj_set_size(backgroundLabel, 240, 240); lv_obj_set_pos(backgroundLabel, 0, 0); lv_label_set_text(backgroundLabel, ""); - - // Need a draw callback to color the cells - lv_obj_add_event_cb(gridDisplay, draw_part_event_cb, LV_EVENT_DRAW_PART_BEGIN, gridDisplay->user_data); } Twos::~Twos() { - lv_style_reset(&style_cell1); - lv_style_reset(&style_cell2); - lv_style_reset(&style_cell3); - lv_style_reset(&style_cell4); - lv_style_reset(&style_cell5); + lv_style_reset(&style_cell_default); lv_obj_clean(lv_scr_act()); } @@ -115,6 +94,10 @@ bool Twos::placeNewTile() { std::vector> availableCells; for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { + if(grid[row][col].isNew){ + grid[row][col].isNew = false; + grid[row][col].changed = true; + } if (!grid[row][col].value) { availableCells.push_back(std::make_pair(row, col)); } @@ -129,17 +112,49 @@ bool Twos::placeNewTile() { int random = rand() % availableCells.size(); std::advance(it, random); std::pair newCell = *it; + Tile *curTile = &grid[newCell.first][newCell.second]; - if ((rand() % 100) < 90) - grid[newCell.first][newCell.second].value = 2; - else - grid[newCell.first][newCell.second].value = 4; + if ((rand() % 100) < 90) { + curTile->value = 2; + } else { + curTile->value = 4; + } + curTile->changed = true; + curTile->isNew = true; updateGridDisplay(grid); return true; } +void Twos::updateTileColor(Tile *tile){ + lv_color_t color; + switch (tile->value) { + case 0: + color = TWOS_COLOR_0; + break; + case 2: + case 4: + color = TWOS_COLOR_2_4; + break; + case 8: + case 16: + color = TWOS_COLOR_8_16; + break; + case 32: + case 64: + color = TWOS_COLOR_32_64; + break; + default: + color = TWOS_COLOR_128_PLUS; + break; + } + lv_obj_set_style_bg_color(tile->box, color, LV_PART_MAIN | LV_STATE_DEFAULT); + + lv_color_t borderColor = tile->isNew ? TWOS_BORDER_NEW : TWOS_BORDER_DEFAULT; + lv_obj_set_style_border_color(tile->box, borderColor, LV_PART_MAIN | LV_STATE_DEFAULT); +} + bool Twos::tryMerge(Tile grid[][4], int& newRow, int& newCol, int oldRow, int oldCol) { - if ((grid[newRow][newCol].value == grid[oldRow][oldCol].value)) { + if (grid[newRow][newCol].value == grid[oldRow][oldCol].value) { if ((newCol != oldCol) || (newRow != oldRow)) { if (!grid[newRow][newCol].merged) { unsigned int newVal = grid[oldRow][oldCol].value *= 2; @@ -148,6 +163,10 @@ bool Twos::tryMerge(Tile grid[][4], int& newRow, int& newCol, int oldRow, int ol lv_label_set_text_fmt(scoreText, "Score #FFFF00 %i#", score); grid[oldRow][oldCol].value = 0; grid[newRow][newCol].merged = true; + + grid[oldRow][oldCol].changed = true; + grid[newRow][newCol].changed = true; + return true; } } @@ -159,6 +178,10 @@ bool Twos::tryMove(Tile grid[][4], int newRow, int newCol, int oldRow, int oldCo if (((newCol >= 0) && (newCol != oldCol)) || ((newRow >= 0) && (newRow != oldRow))) { grid[newRow][newCol].value = grid[oldRow][oldCol].value; grid[oldRow][oldCol].value = 0; + + grid[oldRow][oldCol].changed = true; + grid[newRow][newCol].changed = true; + return true; } return false; @@ -194,7 +217,7 @@ bool Twos::OnTouchEvent(Pinetime::Applications::TouchEvents event) { if (validMove) { placeNewTile(); } - return true; + break; case TouchEvents::SwipeRight: for (int col = 2; col >= 0; col--) { // ignore tiles already on far right for (int row = 0; row < 4; row++) { @@ -217,7 +240,7 @@ bool Twos::OnTouchEvent(Pinetime::Applications::TouchEvents event) { if (validMove) { placeNewTile(); } - return true; + break; case TouchEvents::SwipeUp: for (int row = 1; row < 4; row++) { // ignore tiles already on top for (int col = 0; col < 4; col++) { @@ -240,7 +263,7 @@ bool Twos::OnTouchEvent(Pinetime::Applications::TouchEvents event) { if (validMove) { placeNewTile(); } - return true; + break; case TouchEvents::SwipeDown: for (int row = 2; row >= 0; row--) { // ignore tiles already on bottom for (int col = 0; col < 4; col++) { @@ -263,20 +286,25 @@ bool Twos::OnTouchEvent(Pinetime::Applications::TouchEvents event) { if (validMove) { placeNewTile(); } - return true; + break; default: - return false; + validMove = false; + break; } - return false; + return validMove; } void Twos::updateGridDisplay(Tile grid[][4]) { for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { - if (grid[row][col].value) { - lv_table_set_cell_value(gridDisplay, row, col, (std::to_string(grid[row][col].value)).c_str()); - } else { - lv_table_set_cell_value(gridDisplay, row, col, ""); + Tile *curTile = &grid[row][col]; + if (curTile->changed){ + if (curTile->value) { + lv_label_set_text(curTile->lbl, std::to_string(curTile->value).c_str()); + } else { + lv_label_set_text(curTile->lbl, ""); + } + updateTileColor(curTile); } } } diff --git a/src/displayapp/screens/Twos.h b/src/displayapp/screens/Twos.h index 89fa63d8b6..80763cdd56 100644 --- a/src/displayapp/screens/Twos.h +++ b/src/displayapp/screens/Twos.h @@ -7,7 +7,11 @@ namespace Pinetime { namespace Applications { struct Tile { bool merged = false; + bool changed = true; + bool isNew = false; unsigned int value = 0; + lv_obj_t *box = nullptr; + lv_obj_t *lbl = nullptr; }; namespace Screens { class Twos : public Screen { @@ -26,13 +30,14 @@ namespace Pinetime { lv_style_t style_cell5; lv_obj_t* scoreText; - lv_obj_t* gridDisplay; + lv_obj_t* twosContainer; Tile grid[4][4]; unsigned int score = 0; void updateGridDisplay(Tile grid[][4]); bool tryMerge(Tile grid[][4], int& newRow, int& newCol, int oldRow, int oldCol); bool tryMove(Tile grid[][4], int newRow, int newCol, int oldRow, int oldCol); bool placeNewTile(); + void updateTileColor(Tile* tile); }; } } From 7c7cae99d5056f8a320c7bbafe700035246d9bc8 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Mon, 11 Oct 2021 17:12:36 -0400 Subject: [PATCH 14/25] fix building of Recovery image. --- src/displayapp/DisplayAppRecovery.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/displayapp/DisplayAppRecovery.h b/src/displayapp/DisplayAppRecovery.h index 425e0acad4..9f5fb130b6 100644 --- a/src/displayapp/DisplayAppRecovery.h +++ b/src/displayapp/DisplayAppRecovery.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "TouchEvents.h" #include "Apps.h" #include "Messages.h" @@ -58,6 +59,7 @@ namespace Pinetime { Pinetime::Controllers::AlarmController& alarmController, Pinetime::Controllers::TouchHandler& touchHandler); void Start(); + void Start(Pinetime::System::BootErrors){ Start(); }; void PushMessage(Pinetime::Applications::Display::Messages msg); void Register(Pinetime::System::SystemTask* systemTask); From 289df3f22fc1973d34b088c27a4c3758f2a03c8b Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Mon, 11 Oct 2021 18:03:36 -0400 Subject: [PATCH 15/25] Possible fix for reset on animation on actual pinetime --- src/displayapp/LittleVgl.cpp | 15 ++++++++++----- src/displayapp/LittleVgl.h | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index 6495379219..bdf84c5f77 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -63,7 +63,7 @@ void LittleVgl::InitTouchpad() { } void LittleVgl::SetFullRefresh(FullRefreshDirections direction) { - if (scrollDirection == FullRefreshDirections::None) { +// if (scrollDirection == FullRefreshDirections::None) { scrollDirection = direction; // if (scrollDirection == FullRefreshDirections::Down) { // lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); @@ -76,13 +76,14 @@ void LittleVgl::SetFullRefresh(FullRefreshDirections direction) { // } else if (scrollDirection == FullRefreshDirections::LeftAnim) { // lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); // } - } +// } } void LittleVgl::DisplayDownScroll(){ // We are controlling the drawing process, disable lvgl timers lv_timer_enable(false); + vTaskSuspendAll(); // For each segment, draw the full width, 4 lines at a time starting from the bottom // TODO: Should probably calculate this from the size of the draw buffer @@ -133,11 +134,13 @@ void LittleVgl::DisplayDownScroll(){ // Done! clear flags and enable timers scrollDirection = FullRefreshDirections::None; animating = false; + xTaskResumeAll(); lv_timer_enable(true); } void LittleVgl::DisplayHorizAnim() { lv_timer_enable(false); + vTaskSuspendAll(); int16_t height, width, x1, x2; lv_area_t area; @@ -198,16 +201,19 @@ void LittleVgl::DisplayHorizAnim() { } scrollDirection = FullRefreshDirections::None; animating = false; + xTaskResumeAll(); lv_timer_enable(true); } -void LittleVgl::FlushDisplayManually() { +void LittleVgl::StartTransitionAnimation() { switch(scrollDirection){ case FullRefreshDirections::Down: + animating = true; DisplayDownScroll(); break; case FullRefreshDirections::RightAnim: case FullRefreshDirections::LeftAnim: + animating = true; DisplayHorizAnim(); break; default: @@ -225,8 +231,7 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { if (!animating && (scrollDirection == FullRefreshDirections::Down || scrollDirection == FullRefreshDirections::RightAnim || scrollDirection == FullRefreshDirections::LeftAnim)){ - animating = true; - FlushDisplayManually(); + StartTransitionAnimation(); return; } diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index aba708bb3c..57e7b048bf 100644 --- a/src/displayapp/LittleVgl.h +++ b/src/displayapp/LittleVgl.h @@ -31,7 +31,7 @@ namespace Pinetime { void InitTouchpad(); void InitTheme(); - void FlushDisplayManually(); + void StartTransitionAnimation(); void DisplayDownScroll(); void DisplayHorizAnim(); From a6dbb1b2e9a417f5b268e2790092e46f02c45ab5 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Mon, 11 Oct 2021 18:20:40 -0400 Subject: [PATCH 16/25] clean pad_row/column to pad_gap --- src/displayapp/screens/List.cpp | 3 +-- src/displayapp/screens/Notifications.cpp | 3 +-- src/displayapp/screens/PineTimeStyle.cpp | 3 +-- src/displayapp/screens/Tile.cpp | 3 +-- src/displayapp/screens/settings/SettingDisplay.cpp | 3 +-- src/displayapp/screens/settings/SettingPineTimeStyle.cpp | 3 +-- src/displayapp/screens/settings/SettingSteps.cpp | 3 +-- src/displayapp/screens/settings/SettingTimeFormat.cpp | 3 +-- src/displayapp/screens/settings/SettingWakeUp.cpp | 3 +-- src/displayapp/screens/settings/SettingWatchFace.cpp | 3 +-- 10 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/displayapp/screens/List.cpp b/src/displayapp/screens/List.cpp index c1e6b041a6..b0b09d039d 100644 --- a/src/displayapp/screens/List.cpp +++ b/src/displayapp/screens/List.cpp @@ -52,8 +52,7 @@ List::List(uint8_t screenID, lv_obj_t* container1 = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_row(container1, 4, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(container1, 4, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_gap(container1, 4, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 0, 0); diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 63ca096568..4fbe91fe5d 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -153,8 +153,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_obj_set_style_bg_color(container1, lv_color_hex(0x222222), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_gap(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 0, 50); diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index 43489a5b87..dbd824edda 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -180,8 +180,7 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_obj_set_style_line_width(stepMeter, 4, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_line_color(stepMeter, lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_line_opa(stepMeter, LV_OPA_COVER, LV_PART_INDICATOR | LV_STATE_DEFAULT); - lv_obj_set_style_pad_row(stepMeter, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(stepMeter, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT);; + lv_obj_set_style_pad_gap(stepMeter, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT);; backgroundLabel = lv_label_create(lv_scr_act()); lv_obj_add_flag(backgroundLabel, LV_OBJ_FLAG_CLICKABLE); diff --git a/src/displayapp/screens/Tile.cpp b/src/displayapp/screens/Tile.cpp index 5e7987e1ea..471a85e2cf 100644 --- a/src/displayapp/screens/Tile.cpp +++ b/src/displayapp/screens/Tile.cpp @@ -92,8 +92,7 @@ Tile::Tile(uint8_t screenID, lv_obj_set_style_bg_opa(btnm1, LV_OPA_20, LV_PART_ITEMS | LV_STATE_DISABLED); lv_obj_set_style_bg_color(btnm1, lv_color_hex(0x111111), LV_PART_ITEMS | LV_STATE_DISABLED); lv_obj_set_style_pad_all(btnm1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_row(btnm1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(btnm1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_gap(btnm1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); for (uint8_t i = 0; i < 6; i++) { lv_btnmatrix_set_btn_ctrl(btnm1, i, LV_BTNMATRIX_CTRL_CLICK_TRIG); diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp index e6969341f5..ace3c4e083 100644 --- a/src/displayapp/screens/settings/SettingDisplay.cpp +++ b/src/displayapp/screens/settings/SettingDisplay.cpp @@ -21,8 +21,7 @@ SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_gap(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 10, 60); diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index a3a183622c..029d9fcba7 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -134,8 +134,7 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a lv_obj_set_style_line_width(stepMeter, 4, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_line_color(stepMeter, lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_line_opa(stepMeter, LV_OPA_COVER, LV_PART_INDICATOR | LV_STATE_DEFAULT); - lv_obj_set_style_pad_row(stepMeter, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(stepMeter, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT);; + lv_obj_set_style_pad_gap(stepMeter, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT);; backgroundLabel = lv_label_create(lv_scr_act()); lv_obj_add_flag(backgroundLabel, LV_OBJ_FLAG_CLICKABLE); diff --git a/src/displayapp/screens/settings/SettingSteps.cpp b/src/displayapp/screens/settings/SettingSteps.cpp index 993f2dc57e..14879ab27d 100644 --- a/src/displayapp/screens/settings/SettingSteps.cpp +++ b/src/displayapp/screens/settings/SettingSteps.cpp @@ -22,8 +22,7 @@ SettingSteps::SettingSteps( lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_gap(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 30, 60); lv_obj_set_width(container1, LV_HOR_RES - 50); diff --git a/src/displayapp/screens/settings/SettingTimeFormat.cpp b/src/displayapp/screens/settings/SettingTimeFormat.cpp index eacbe40c8c..d3d4b0c1f0 100644 --- a/src/displayapp/screens/settings/SettingTimeFormat.cpp +++ b/src/displayapp/screens/settings/SettingTimeFormat.cpp @@ -20,8 +20,7 @@ SettingTimeFormat::SettingTimeFormat(Pinetime::Applications::DisplayApp* app, Pi lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_gap(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 10, 60); diff --git a/src/displayapp/screens/settings/SettingWakeUp.cpp b/src/displayapp/screens/settings/SettingWakeUp.cpp index b5bb664c75..4d05997f7b 100644 --- a/src/displayapp/screens/settings/SettingWakeUp.cpp +++ b/src/displayapp/screens/settings/SettingWakeUp.cpp @@ -21,8 +21,7 @@ SettingWakeUp::SettingWakeUp(Pinetime::Applications::DisplayApp* app, Pinetime:: lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT);; + lv_obj_set_style_pad_gap(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT);; lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 10, 60); diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp index 16e76286d9..78cbd36558 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.cpp +++ b/src/displayapp/screens/settings/SettingWatchFace.cpp @@ -20,8 +20,7 @@ SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pine lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_all(container1, 10, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_row(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_column(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_gap(container1, 5, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 10, 60); From c6b59fa3c776e9878bcec5bb101cec7c11a3f663 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Mon, 11 Oct 2021 20:23:28 -0400 Subject: [PATCH 17/25] More alignment fixes Improve timer to not refresh screen constantly while running. --- src/displayapp/screens/Alarm.cpp | 14 ++-- src/displayapp/screens/Brightness.cpp | 4 +- src/displayapp/screens/FirmwareValidation.cpp | 6 +- src/displayapp/screens/Metronome.cpp | 6 +- src/displayapp/screens/Motion.cpp | 4 +- src/displayapp/screens/Navigation.cpp | 10 +-- src/displayapp/screens/PineTimeStyle.cpp | 64 ++++++++--------- src/displayapp/screens/Steps.cpp | 12 ++-- src/displayapp/screens/StopWatch.cpp | 8 +-- src/displayapp/screens/Timer.cpp | 35 ++++++---- src/displayapp/screens/Timer.h | 2 + .../screens/settings/SettingPineTimeStyle.cpp | 68 +++++++++---------- 12 files changed, 121 insertions(+), 112 deletions(-) diff --git a/src/displayapp/screens/Alarm.cpp b/src/displayapp/screens/Alarm.cpp index be33471498..ba3491714c 100644 --- a/src/displayapp/screens/Alarm.cpp +++ b/src/displayapp/screens/Alarm.cpp @@ -36,7 +36,7 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController) alarmHours = alarmController.Hours(); alarmMinutes = alarmController.Minutes(); - lv_label_set_text_fmt(time, "%02lu:%02lu", alarmHours, alarmMinutes); + lv_label_set_text_fmt(time, "%02u:%02u", alarmHours, alarmMinutes); lv_obj_align(time, LV_ALIGN_CENTER, 0, -25); @@ -47,6 +47,7 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController) lv_obj_align(btnHoursUp, LV_ALIGN_LEFT_MID, 20, -85); txtHrUp = lv_label_create(btnHoursUp); lv_label_set_text_static(txtHrUp, "+"); + lv_obj_center(txtHrUp); btnHoursDown = lv_btn_create(lv_scr_act()); btnHoursDown->user_data = this; @@ -55,6 +56,7 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController) lv_obj_align(btnHoursDown, LV_ALIGN_LEFT_MID, 20, 35); txtHrDown = lv_label_create(btnHoursDown); lv_label_set_text_static(txtHrDown, "-"); + lv_obj_center(txtHrDown); btnMinutesUp = lv_btn_create(lv_scr_act()); btnMinutesUp->user_data = this; @@ -63,6 +65,7 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController) lv_obj_align(btnMinutesUp, LV_ALIGN_RIGHT_MID, -20, -85); txtMinUp = lv_label_create(btnMinutesUp); lv_label_set_text_static(txtMinUp, "+"); + lv_obj_center(txtMinUp); btnMinutesDown = lv_btn_create(lv_scr_act()); btnMinutesDown->user_data = this; @@ -71,6 +74,7 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController) lv_obj_align(btnMinutesDown, LV_ALIGN_RIGHT_MID, -20, 35); txtMinDown = lv_label_create(btnMinutesDown); lv_label_set_text_static(txtMinDown, "-"); + lv_obj_center(txtMinDown); btnEnable = lv_btn_create(lv_scr_act()); btnEnable->user_data = this; @@ -78,6 +82,7 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController) lv_obj_set_size(btnEnable, 115, 50); lv_obj_align(btnEnable, LV_ALIGN_BOTTOM_LEFT, 0, 0); txtEnable = lv_label_create(btnEnable); + lv_obj_center(txtEnable); SetEnableButtonState(); btnRecur = lv_btn_create(lv_scr_act()); @@ -86,6 +91,7 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController) lv_obj_set_size(btnRecur, 115, 50); lv_obj_align(btnRecur, LV_ALIGN_BOTTOM_RIGHT, 0, 0); txtRecur = lv_label_create(btnRecur); + lv_obj_center(txtRecur); SetRecurButtonState(); btnInfo = lv_btn_create(lv_scr_act()); @@ -94,6 +100,7 @@ Alarm::Alarm(DisplayApp* app, Controllers::AlarmController& alarmController) lv_obj_set_size(btnInfo, 50, 40); lv_obj_align(btnInfo, LV_ALIGN_CENTER, 0, -85); txtInfo = lv_label_create(btnInfo); + lv_obj_center(txtInfo); lv_label_set_text_static(txtInfo, "i"); } @@ -208,8 +215,7 @@ void Alarm::ShowInfo() { btnMessage = lv_btn_create(lv_scr_act()); btnMessage->user_data = this; lv_obj_add_event_cb(btnMessage, btnEventHandler, LV_EVENT_ALL, btnMessage->user_data); - lv_obj_set_height(btnMessage, 200); - lv_obj_set_width(btnMessage, 150); + lv_obj_set_size(btnMessage, 150, 200); lv_obj_align(btnMessage, LV_ALIGN_CENTER, 0, 0); txtMessage = lv_label_create(btnMessage); lv_obj_set_style_bg_color(btnMessage, lv_color_hex(0x000080), LV_PART_MAIN | LV_STATE_DEFAULT); @@ -223,7 +229,7 @@ void Alarm::ShowInfo() { auto secToAlarm = timeToAlarm % 60; lv_label_set_text_fmt( - txtMessage, "Time to\nalarm:\n%2d Days\n%2d Hours\n%2d Minutes\n%2d Seconds", daysToAlarm, hrsToAlarm, minToAlarm, secToAlarm); + txtMessage, "Time to\nalarm:\n%2ld Days\n%2ld Hours\n%2ld Minutes\n%2ld Seconds", daysToAlarm, hrsToAlarm, minToAlarm, secToAlarm); } else { lv_label_set_text(txtMessage, "Alarm\nis not\nset."); } diff --git a/src/displayapp/screens/Brightness.cpp b/src/displayapp/screens/Brightness.cpp index 9352ff2610..7e4e2c88ad 100644 --- a/src/displayapp/screens/Brightness.cpp +++ b/src/displayapp/screens/Brightness.cpp @@ -20,9 +20,9 @@ Brightness::Brightness(Pinetime::Applications::DisplayApp* app, Controllers::Bri lv_slider_set_range(slider, 0, 2); lv_slider_set_value(slider, LevelToInt(brightness.Level()), LV_ANIM_OFF); - slider_label = lv_label_create(slider); + slider_label = lv_label_create(lv_scr_act()); lv_label_set_text(slider_label, LevelToString(brightness.Level())); - lv_obj_align(slider_label, LV_ALIGN_OUT_BOTTOM_MID, 0, 30); + lv_obj_align_to(slider_label, slider, LV_ALIGN_OUT_BOTTOM_MID, 0, 30); } Brightness::~Brightness() { diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp index 89aa0f6d59..3f30e647bb 100644 --- a/src/displayapp/screens/FirmwareValidation.cpp +++ b/src/displayapp/screens/FirmwareValidation.cpp @@ -18,7 +18,7 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app, : Screen {app}, validator {validator} { labelVersion = lv_label_create(lv_scr_act()); lv_label_set_text_fmt(labelVersion, - "Version : %u.%u.%u\n" + "Version : %lu.%lu.%lu\n" "ShortRef : %s", Version::Major(), Version::Minor(), @@ -26,8 +26,8 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app, Version::GitCommitHash()); lv_obj_align(labelVersion, LV_ALIGN_TOP_LEFT, 0, 0); - labelIsValidated = lv_label_create(labelVersion); - lv_obj_align(labelIsValidated, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); + labelIsValidated = lv_label_create(lv_scr_act()); + lv_obj_align_to(labelIsValidated, labelVersion, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); lv_label_set_recolor(labelIsValidated, true); lv_label_set_long_mode(labelIsValidated, LV_LABEL_LONG_WRAP); lv_obj_set_width(labelIsValidated, 240); diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp index 3221b3902f..aaf4579f7c 100644 --- a/src/displayapp/screens/Metronome.cpp +++ b/src/displayapp/screens/Metronome.cpp @@ -9,12 +9,12 @@ namespace { screen->OnEvent(lv_event_get_target(event), event); } - lv_obj_t* createLabel(const char* name, lv_obj_t* parent, lv_align_t align, const lv_font_t* font, uint8_t x, uint8_t y) { - lv_obj_t* label = lv_label_create(parent); + lv_obj_t* createLabel(const char* name, lv_obj_t* reference, lv_align_t align, const lv_font_t* font, uint8_t x, uint8_t y) { + lv_obj_t* label = lv_label_create(lv_scr_act()); lv_obj_set_style_text_font(label, font, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_text_color(label, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(label, name); - lv_obj_align(label, align, x, y); + lv_obj_align_to(label, reference, align, x, y); return label; } diff --git a/src/displayapp/screens/Motion.cpp b/src/displayapp/screens/Motion.cpp index 4299c58e05..47b1f10a34 100644 --- a/src/displayapp/screens/Motion.cpp +++ b/src/displayapp/screens/Motion.cpp @@ -33,8 +33,8 @@ Motion::Motion(Pinetime::Applications::DisplayApp* app, Controllers::MotionContr lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 10); lv_label_set_recolor(label, true); - labelStep = lv_label_create(chart); - lv_obj_align(labelStep, LV_ALIGN_BOTTOM_LEFT, 0, 0); + labelStep = lv_label_create(lv_scr_act()); + lv_obj_align_to(labelStep, chart, LV_ALIGN_BOTTOM_LEFT, 0, 0); lv_label_set_text(labelStep, "Steps ---"); taskRefresh = lv_timer_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, this); diff --git a/src/displayapp/screens/Navigation.cpp b/src/displayapp/screens/Navigation.cpp index ef41454771..65061aca32 100644 --- a/src/displayapp/screens/Navigation.cpp +++ b/src/displayapp/screens/Navigation.cpp @@ -135,22 +135,22 @@ Navigation::Navigation(Pinetime::Applications::DisplayApp* app, Pinetime::Contro lv_obj_set_style_text_font(imgFlag, &lv_font_navi_80, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_text_color(imgFlag, lv_color_hex(0x00FFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(imgFlag, iconForName("flag")); - lv_obj_align(imgFlag, LV_ALIGN_CENTER, 0, -60); + lv_obj_align(imgFlag, LV_ALIGN_CENTER, 0, -60); txtNarrative = lv_label_create(lv_scr_act()); lv_label_set_long_mode(txtNarrative, LV_LABEL_LONG_WRAP); lv_obj_set_width(txtNarrative, LV_HOR_RES); lv_label_set_text(txtNarrative, "Navigation"); - lv_obj_center(txtNarrative); - lv_obj_align(txtNarrative, LV_ALIGN_CENTER, 0, 10); + lv_obj_set_style_text_align(txtNarrative, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(txtNarrative, LV_ALIGN_CENTER, 0, 10); txtManDist = lv_label_create(lv_scr_act()); lv_label_set_long_mode(txtManDist, LV_LABEL_LONG_WRAP); lv_obj_set_style_text_color(txtManDist, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_width(txtManDist, LV_HOR_RES); lv_label_set_text(txtManDist, "--M"); - lv_obj_center(txtManDist); - lv_obj_align(txtManDist, LV_ALIGN_CENTER, 0, 60); + lv_obj_set_style_text_align(txtManDist, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_align(txtManDist, LV_ALIGN_CENTER, 0, 60); // Route Progress barProgress = lv_bar_create(lv_scr_act()); diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index dbd824edda..c6ac0250a0 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -70,23 +70,23 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_obj_align(timebar, LV_ALIGN_TOP_LEFT, 5, 0); // Display the time - timeDD1 = lv_label_create(timebar); + timeDD1 = lv_label_create(lv_scr_act()); lv_obj_set_style_text_font(timeDD1, &open_sans_light, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_text_color(timeDD1, Convert(settingsController.GetPTSColorTime()), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(timeDD1, "12"); - lv_obj_align(timeDD1, LV_ALIGN_TOP_MID, 5, 5); + lv_obj_align_to(timeDD1, timebar, LV_ALIGN_TOP_MID, 5, 5); - timeDD2 = lv_label_create(timebar); + timeDD2 = lv_label_create(lv_scr_act()); lv_obj_set_style_text_font(timeDD2, &open_sans_light, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_text_color(timeDD2, Convert(settingsController.GetPTSColorTime()), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(timeDD2, "34"); - lv_obj_align(timeDD2, LV_ALIGN_BOTTOM_MID, 5, -5); + lv_obj_align_to(timeDD2, timebar, LV_ALIGN_BOTTOM_MID, 5, -5); - timeAMPM = lv_label_create(timebar); + timeAMPM = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(timeAMPM, Convert(settingsController.GetPTSColorTime()), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_text_line_space(timeAMPM, -3, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(timeAMPM, ""); - lv_obj_align(timeAMPM, LV_ALIGN_BOTTOM_LEFT, 2, -20); + lv_obj_align_to(timeAMPM, timebar, LV_ALIGN_BOTTOM_LEFT, 2, -20); // Create a 40px wide bar down the right side of the screen sidebar = lv_obj_create(lv_scr_act()); @@ -96,81 +96,81 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_obj_align(sidebar, LV_ALIGN_TOP_RIGHT, 0, 0); // Display icons - batteryIcon = lv_label_create(sidebar); + batteryIcon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(batteryIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(batteryIcon, Symbols::batteryFull); - lv_obj_align(batteryIcon, LV_ALIGN_TOP_MID, 0, 2); + lv_obj_align_to(batteryIcon, sidebar, LV_ALIGN_TOP_MID, 0, 2); - bleIcon = lv_label_create(sidebar); + bleIcon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(bleIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align(bleIcon, LV_ALIGN_TOP_MID, 0, 25); + lv_obj_align_to(bleIcon, sidebar, LV_ALIGN_TOP_MID, 0, 25); - notificationIcon = lv_label_create(sidebar); + notificationIcon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(notificationIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align(notificationIcon, LV_ALIGN_TOP_MID, 0, 40); + lv_obj_align_to(notificationIcon, sidebar, LV_ALIGN_TOP_MID, 0, 40); // Calendar icon - calendarOuter = lv_obj_create(sidebar); + calendarOuter = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(calendarOuter, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(calendarOuter, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarOuter, 34, 34); - lv_obj_align(calendarOuter, LV_ALIGN_CENTER, 0, 0); + lv_obj_align_to(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0); - calendarInner = lv_obj_create(calendarOuter); + calendarInner = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(calendarInner, lv_color_hex(0xffffff), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(calendarInner, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarInner, 27, 27); - lv_obj_align(calendarInner, LV_ALIGN_CENTER, 0, 0); + lv_obj_align_to(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0); - calendarBar1 = lv_obj_create(calendarOuter); + calendarBar1 = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(calendarBar1, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(calendarBar1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarBar1, 3, 12); - lv_obj_align(calendarBar1, LV_ALIGN_TOP_MID, -6, -3); + lv_obj_align_to(calendarBar1, calendarOuter, LV_ALIGN_TOP_MID, -6, -3); - calendarBar2 = lv_obj_create(calendarOuter); + calendarBar2 = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(calendarBar2, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(calendarBar2, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarBar2, 3, 12); - lv_obj_align(calendarBar2, LV_ALIGN_TOP_MID, 6, -3); + lv_obj_align_to(calendarBar2, calendarOuter, LV_ALIGN_TOP_MID, 6, -3); - calendarCrossBar1 = lv_obj_create(calendarBar1); + calendarCrossBar1 = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(calendarCrossBar1, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(calendarCrossBar1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarCrossBar1, 8, 3); - lv_obj_align(calendarCrossBar1, LV_ALIGN_BOTTOM_MID, 0, 0); + lv_obj_align_to(calendarCrossBar1, calendarBar1, LV_ALIGN_BOTTOM_MID, 0, 0); - calendarCrossBar2 = lv_obj_create(calendarBar2); + calendarCrossBar2 = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(calendarCrossBar2, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(calendarCrossBar2, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarCrossBar2, 8, 3); - lv_obj_align(calendarCrossBar2, LV_ALIGN_BOTTOM_MID, 0, 0); + lv_obj_align_to(calendarCrossBar2, calendarBar2, LV_ALIGN_BOTTOM_MID, 0, 0); // Display date - dateDayOfWeek = lv_label_create(sidebar); + dateDayOfWeek = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(dateDayOfWeek, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateDayOfWeek, "THU"); - lv_obj_align(dateDayOfWeek, LV_ALIGN_CENTER, 0, -34); + lv_obj_align_to(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34); - dateDay = lv_label_create(sidebar); + dateDay = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(dateDay, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateDay, "25"); - lv_obj_align(dateDay, LV_ALIGN_CENTER, 0, 3); + lv_obj_align_to(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3); - dateMonth = lv_label_create(sidebar); + dateMonth = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(dateMonth, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateMonth, "MAR"); - lv_obj_align(dateMonth, LV_ALIGN_CENTER, 0, 32); + lv_obj_align_to(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32); // Step count gauge needle_color = lv_color_white(); - stepMeter = lv_meter_create(sidebar); + stepMeter = lv_meter_create(lv_scr_act()); stepScale = lv_meter_add_scale(stepMeter); stepIndicator = lv_meter_add_needle_line(stepMeter, stepScale, 3, needle_color, 0); lv_meter_set_scale_range(stepMeter, stepScale, 0, 100, 360, 180); lv_meter_set_scale_ticks(stepMeter, stepScale, 11, 4, 4, lv_color_black()); lv_obj_set_size(stepMeter, 40, 40); - lv_obj_align(stepMeter, LV_ALIGN_BOTTOM_MID, 0, 0); + lv_obj_align_to(stepMeter, sidebar, LV_ALIGN_BOTTOM_MID, 0, 0); lv_meter_set_indicator_value(stepMeter, stepIndicator, 0); lv_obj_set_style_pad_right(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp index f71e13adc8..2b6ead16f7 100644 --- a/src/displayapp/screens/Steps.cpp +++ b/src/displayapp/screens/Steps.cpp @@ -29,18 +29,18 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app, lv_obj_set_style_text_color(lSteps, lv_color_hex(0x00FF00), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_text_font(lSteps, &jetbrains_mono_42, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_fmt(lSteps, "%li", stepsCount); - lv_obj_align(lSteps, LV_ALIGN_CENTER, 0, -20); + lv_obj_align(lSteps, LV_ALIGN_CENTER, 0, -20); - lv_obj_t* lstepsL = lv_label_create(lSteps); + lv_obj_t* lstepsL = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(lstepsL, lv_color_hex(0x111111), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(lstepsL, "Steps"); - lv_obj_align(lstepsL, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); + lv_obj_align_to(lstepsL, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); - lv_obj_t* lstepsGoal = lv_label_create(lSteps); + lv_obj_t* lstepsGoal = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(lstepsGoal, lv_color_hex(0x00FFFF), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_fmt(lstepsGoal, "Goal\n%lu", settingsController.GetStepsGoal()); lv_obj_set_style_text_align(lstepsGoal, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align(lstepsGoal, LV_ALIGN_OUT_BOTTOM_MID, 0, 60); + lv_obj_align_to(lstepsGoal, lSteps, LV_ALIGN_OUT_BOTTOM_MID, 0, 60); lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act()); lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); @@ -60,7 +60,7 @@ void Steps::Refresh() { stepsCount = motionController.NbSteps(); lv_label_set_text_fmt(lSteps, "%li", stepsCount); - lv_obj_align(lSteps, LV_ALIGN_CENTER, 0, -20); + lv_obj_align(lSteps, LV_ALIGN_CENTER, 0, -20); lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal())); } diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index 49aa5dd75f..24f12e2ba3 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -70,20 +70,20 @@ StopWatch::StopWatch(DisplayApp* app, System::SystemTask& systemTask) btnPlayPause = lv_btn_create(lv_scr_act()); btnPlayPause->user_data = this; lv_obj_add_event_cb(btnPlayPause, play_pause_event_handler, LV_EVENT_ALL, btnPlayPause->user_data); - lv_obj_set_height(btnPlayPause, 50); - lv_obj_set_width(btnPlayPause, 115); + lv_obj_set_size(btnPlayPause, 115, 50); lv_obj_align(btnPlayPause, LV_ALIGN_BOTTOM_RIGHT, 0, 0); txtPlayPause = lv_label_create(btnPlayPause); + lv_obj_center(txtPlayPause); lv_label_set_text(txtPlayPause, Symbols::play); btnStopLap = lv_btn_create(lv_scr_act()); btnStopLap->user_data = this; lv_obj_add_event_cb(btnStopLap, stop_lap_event_handler, LV_EVENT_ALL, btnStopLap->user_data); - lv_obj_set_height(btnStopLap, 50); - lv_obj_set_width(btnStopLap, 115); + lv_obj_set_size(btnStopLap, 115, 50); lv_obj_align(btnStopLap, LV_ALIGN_BOTTOM_LEFT, 0, 0); lv_obj_set_style_bg_color(btnStopLap, lv_color_hex(0x080808), LV_PART_MAIN | LV_STATE_DISABLED); txtStopLap = lv_label_create(btnStopLap); + lv_obj_center(txtStopLap); lv_obj_set_style_text_color(txtStopLap, lv_color_hex(0x888888), LV_PART_MAIN | LV_STATE_DISABLED); lv_label_set_text(txtStopLap, Symbols::stop); lv_obj_clear_state(btnStopLap, LV_STATE_ANY); diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp index c86e1d5f7e..9b3a5dc3d7 100644 --- a/src/displayapp/screens/Timer.cpp +++ b/src/displayapp/screens/Timer.cpp @@ -15,38 +15,38 @@ void Timer::createButtons() { btnMinutesUp = lv_btn_create(lv_scr_act()); btnMinutesUp->user_data = this; lv_obj_add_event_cb(btnMinutesUp, btnEventHandler, LV_EVENT_ALL, btnMinutesUp->user_data); - lv_obj_align(btnMinutesUp, LV_ALIGN_LEFT_MID, 20, -80); - lv_obj_set_height(btnMinutesUp, 40); - lv_obj_set_width(btnMinutesUp, 60); + lv_obj_set_size(btnMinutesUp, 60, 40); + lv_obj_align(btnMinutesUp, LV_ALIGN_LEFT_MID, 20, -85); txtMUp = lv_label_create(btnMinutesUp); lv_label_set_text(txtMUp, "+"); + lv_obj_center(txtMUp); btnMinutesDown = lv_btn_create(lv_scr_act()); btnMinutesDown->user_data = this; lv_obj_add_event_cb(btnMinutesDown, btnEventHandler, LV_EVENT_ALL, btnMinutesDown->user_data); - lv_obj_align(btnMinutesDown, LV_ALIGN_LEFT_MID, 20, +40); - lv_obj_set_height(btnMinutesDown, 40); - lv_obj_set_width(btnMinutesDown, 60); + lv_obj_set_size(btnMinutesDown, 60, 40); + lv_obj_align(btnMinutesDown, LV_ALIGN_LEFT_MID, 20, 35); txtMDown = lv_label_create(btnMinutesDown); lv_label_set_text(txtMDown, "-"); + lv_obj_center(txtMDown); btnSecondsUp = lv_btn_create(lv_scr_act()); btnSecondsUp->user_data = this; lv_obj_add_event_cb(btnSecondsUp, btnEventHandler, LV_EVENT_ALL, btnSecondsUp->user_data); - lv_obj_align(btnSecondsUp, LV_ALIGN_RIGHT_MID, 10, -80); - lv_obj_set_height(btnSecondsUp, 40); - lv_obj_set_width(btnSecondsUp, 60); + lv_obj_set_size(btnSecondsUp, 60, 40); + lv_obj_align(btnSecondsUp, LV_ALIGN_RIGHT_MID, -20, -85); txtSUp = lv_label_create(btnSecondsUp); lv_label_set_text(txtSUp, "+"); + lv_obj_center(txtSUp); btnSecondsDown = lv_btn_create(lv_scr_act()); btnSecondsDown->user_data = this; lv_obj_add_event_cb(btnSecondsDown, btnEventHandler, LV_EVENT_ALL, btnSecondsDown->user_data); - lv_obj_align(btnSecondsDown, LV_ALIGN_RIGHT_MID, 10, +40); - lv_obj_set_height(btnSecondsDown, 40); - lv_obj_set_width(btnSecondsDown, 60); + lv_obj_set_size(btnSecondsDown, 60, 40); + lv_obj_align(btnSecondsDown, LV_ALIGN_RIGHT_MID, -20, 35); txtSDown = lv_label_create(btnSecondsDown); lv_label_set_text(txtSDown, "-"); + lv_obj_center(txtSDown); } Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController) @@ -59,7 +59,7 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController) uint32_t seconds = timerController.GetTimeRemaining() / 1000; lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60); - lv_obj_align(time, LV_ALIGN_LEFT_MID, 0, -20); + lv_obj_align(time, LV_ALIGN_CENTER, 0, -25); btnPlayPause = lv_btn_create(lv_scr_act()); btnPlayPause->user_data = this; @@ -85,7 +85,14 @@ Timer::~Timer() { void Timer::Refresh() { if (timerController.IsRunning()) { uint32_t seconds = timerController.GetTimeRemaining() / 1000; - lv_label_set_text_fmt(time, "%02lu:%02lu", seconds / 60, seconds % 60); + uint8_t curMinutes = seconds / 60; + uint8_t curSeconds = seconds % 60; + // Avoids constant redrawing + if (curMinutes != pMinutes || curSeconds != pSeconds) { + pMinutes = curMinutes; + pSeconds = curSeconds; + lv_label_set_text_fmt(time, "%02u:%02u", curMinutes, curSeconds); + } } } diff --git a/src/displayapp/screens/Timer.h b/src/displayapp/screens/Timer.h index 5fb87b8a5b..59261e7744 100644 --- a/src/displayapp/screens/Timer.h +++ b/src/displayapp/screens/Timer.h @@ -27,6 +27,8 @@ namespace Pinetime::Applications::Screens { bool running; uint8_t secondsToSet = 0; uint8_t minutesToSet = 0; + uint8_t pSeconds = 0; + uint8_t pMinutes = 0; Controllers::TimerController& timerController; void createButtons(); diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 029d9fcba7..9e217710d0 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -22,27 +22,25 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a lv_obj_align(timebar, LV_ALIGN_TOP_LEFT, 5, 0); // Display the time - - timeDD1 = lv_label_create(timebar); + timeDD1 = lv_label_create(lv_scr_act()); lv_obj_set_style_text_font(timeDD1, &open_sans_light, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_text_color(timeDD1, Convert(settingsController.GetPTSColorTime()), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(timeDD1, "12"); - lv_obj_align(timeDD1, LV_ALIGN_TOP_MID, 5, 5); + lv_obj_align_to(timeDD1, timebar, LV_ALIGN_TOP_MID, 5, 5); - timeDD2 = lv_label_create(timebar); + timeDD2 = lv_label_create(lv_scr_act()); lv_obj_set_style_text_font(timeDD2, &open_sans_light, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_text_color(timeDD2, Convert(settingsController.GetPTSColorTime()), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(timeDD2, "34"); - lv_obj_align(timeDD2, LV_ALIGN_BOTTOM_MID, 5, -5); + lv_obj_align_to(timeDD2, timebar, LV_ALIGN_BOTTOM_MID, 5, -5); - timeAMPM = lv_label_create(timebar); + timeAMPM = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(timeAMPM, Convert(settingsController.GetPTSColorTime()), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_text_line_space(timeAMPM, -3, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(timeAMPM, "A\nM"); - lv_obj_align(timeAMPM, LV_ALIGN_BOTTOM_LEFT, 2, -20); + lv_obj_align_to(timeAMPM, timebar, LV_ALIGN_BOTTOM_LEFT, 2, -20); // Create a 40px wide bar down the right side of the screen - sidebar = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(sidebar, Convert(settingsController.GetPTSColorBar()), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(sidebar, 0, LV_PART_MAIN | LV_STATE_DEFAULT); @@ -50,83 +48,79 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a lv_obj_align(sidebar, LV_ALIGN_TOP_RIGHT, 0, 0); // Display icons - - batteryIcon = lv_label_create(sidebar); + batteryIcon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(batteryIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(batteryIcon, Symbols::batteryFull); - lv_obj_align(batteryIcon, LV_ALIGN_TOP_MID, 0, 2); + lv_obj_align_to(batteryIcon, sidebar, LV_ALIGN_TOP_MID, 0, 2); - bleIcon = lv_label_create(sidebar); + bleIcon = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(bleIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_label_set_text(bleIcon, Symbols::bluetooth); - lv_obj_align(bleIcon, LV_ALIGN_TOP_MID, 0, 25); + lv_obj_align_to(bleIcon, sidebar, LV_ALIGN_TOP_MID, 0, 25); // Calendar icon - - calendarOuter = lv_obj_create(sidebar); + calendarOuter = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(calendarOuter, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(calendarOuter, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarOuter, 34, 34); - lv_obj_align(calendarOuter, LV_ALIGN_CENTER, 0, 0); + lv_obj_align_to(calendarOuter, sidebar, LV_ALIGN_CENTER, 0, 0); - calendarInner = lv_obj_create(calendarOuter); + calendarInner = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(calendarInner, lv_color_hex(0xffffff), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(calendarInner, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarInner, 27, 27); - lv_obj_align(calendarInner, LV_ALIGN_CENTER, 0, 0); + lv_obj_align_to(calendarInner, calendarOuter, LV_ALIGN_CENTER, 0, 0); - calendarBar1 = lv_obj_create(calendarOuter); + calendarBar1 = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(calendarBar1, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(calendarBar1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarBar1, 3, 12); - lv_obj_align(calendarBar1, LV_ALIGN_TOP_MID, -6, -3); + lv_obj_align_to(calendarBar1, calendarOuter, LV_ALIGN_TOP_MID, -6, -3); - calendarBar2 = lv_obj_create(calendarOuter); + calendarBar2 = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(calendarBar2, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(calendarBar2, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarBar2, 3, 12); - lv_obj_align(calendarBar2, LV_ALIGN_TOP_MID, 6, -3); + lv_obj_align_to(calendarBar2, calendarOuter, LV_ALIGN_TOP_MID, 6, -3); - calendarCrossBar1 = lv_obj_create(calendarBar1); + calendarCrossBar1 = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(calendarCrossBar1, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(calendarCrossBar1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarCrossBar1, 8, 3); - lv_obj_align(calendarCrossBar1, LV_ALIGN_BOTTOM_MID, 0, 0); + lv_obj_align_to(calendarCrossBar1, calendarBar1, LV_ALIGN_BOTTOM_MID, 0, 0); - calendarCrossBar2 = lv_obj_create(calendarBar2); + calendarCrossBar2 = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_color(calendarCrossBar2, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_radius(calendarCrossBar2, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_size(calendarCrossBar2, 8, 3); - lv_obj_align(calendarCrossBar2, LV_ALIGN_BOTTOM_MID, 0, 0); + lv_obj_align_to(calendarCrossBar2, calendarBar2, LV_ALIGN_BOTTOM_MID, 0, 0); // Display date - - dateDayOfWeek = lv_label_create(sidebar); + dateDayOfWeek = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(dateDayOfWeek, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateDayOfWeek, "THU"); - lv_obj_align(dateDayOfWeek, LV_ALIGN_CENTER, 0, -34); + lv_obj_align_to(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34); - dateDay = lv_label_create(sidebar); + dateDay = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(dateDay, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateDay, "25"); - lv_obj_align(dateDay, LV_ALIGN_CENTER, 0, 3); + lv_obj_align_to(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3); - dateMonth = lv_label_create(sidebar); + dateMonth = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(dateMonth, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateMonth, "MAR"); - lv_obj_align(dateMonth, LV_ALIGN_CENTER, 0, 32); + lv_obj_align_to(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32); // Step count gauge needle_color = lv_color_white(); - stepMeter = lv_meter_create(sidebar); + stepMeter = lv_meter_create(lv_scr_act()); stepScale = lv_meter_add_scale(stepMeter); stepIndicator = lv_meter_add_needle_line(stepMeter, stepScale, 3, needle_color, 0); lv_meter_set_scale_range(stepMeter, stepScale, 0, 100, 360, 180); lv_meter_set_scale_ticks(stepMeter, stepScale, 11, 4, 4, lv_color_black()); lv_obj_set_size(stepMeter, 40, 40); - lv_obj_align(stepMeter, LV_ALIGN_BOTTOM_MID, 0, 0); + lv_obj_align_to(stepMeter, sidebar, LV_ALIGN_BOTTOM_MID, 0, 0); lv_meter_set_indicator_value(stepMeter, stepIndicator, 0); - + lv_obj_set_style_pad_right(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_left(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_bottom(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); From 22e3d88f31c4fab7259f3e5009079a89e0d2ca75 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Tue, 12 Oct 2021 12:39:35 -0400 Subject: [PATCH 18/25] Next attempt at fixing screen transitions. A bit more graceful and doesn't mess with any task schedulers. --- src/displayapp/DisplayApp.cpp | 3 +++ src/displayapp/DisplayApp.h | 1 + src/displayapp/LittleVgl.cpp | 29 ++++++++-------------- src/displayapp/LittleVgl.h | 2 +- src/displayapp/screens/ApplicationList.h | 1 + src/displayapp/screens/Screen.h | 10 ++++++++ src/displayapp/screens/ScreenList.h | 1 + src/displayapp/screens/settings/Settings.h | 1 + 8 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 6e5cb5763d..4f31916ac7 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -149,6 +149,9 @@ void DisplayApp::InitHw() { void DisplayApp::Refresh() { TickType_t queueTimeout; + if (currentScreen.get()->IsNew()){ + doScreenTransition(); + } switch (state) { case States::Idle: queueTimeout = portMAX_DELAY; diff --git a/src/displayapp/DisplayApp.h b/src/displayapp/DisplayApp.h index a87cab0b99..9ac115f303 100644 --- a/src/displayapp/DisplayApp.h +++ b/src/displayapp/DisplayApp.h @@ -70,6 +70,7 @@ namespace Pinetime { void SetFullRefresh(FullRefreshDirections direction); void Register(Pinetime::System::SystemTask* systemTask); + void doScreenTransition(){lvgl.StartTransitionAnimation();} private: Pinetime::Drivers::St7789& lcd; diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index bdf84c5f77..ddcf84d0bc 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -81,10 +81,6 @@ void LittleVgl::SetFullRefresh(FullRefreshDirections direction) { void LittleVgl::DisplayDownScroll(){ - // We are controlling the drawing process, disable lvgl timers - lv_timer_enable(false); - vTaskSuspendAll(); - // For each segment, draw the full width, 4 lines at a time starting from the bottom // TODO: Should probably calculate this from the size of the draw buffer int16_t height = 4; @@ -134,14 +130,9 @@ void LittleVgl::DisplayDownScroll(){ // Done! clear flags and enable timers scrollDirection = FullRefreshDirections::None; animating = false; - xTaskResumeAll(); - lv_timer_enable(true); } void LittleVgl::DisplayHorizAnim() { - lv_timer_enable(false); - vTaskSuspendAll(); - int16_t height, width, x1, x2; lv_area_t area; @@ -179,7 +170,6 @@ void LittleVgl::DisplayHorizAnim() { } else { // Not set for a horizontal animation! - lv_timer_enable(true); return; } @@ -201,18 +191,21 @@ void LittleVgl::DisplayHorizAnim() { } scrollDirection = FullRefreshDirections::None; animating = false; - xTaskResumeAll(); - lv_timer_enable(true); } void LittleVgl::StartTransitionAnimation() { + lv_disp_t* disp = lv_disp_get_default(); switch(scrollDirection){ case FullRefreshDirections::Down: + lv_obj_update_layout(disp->act_scr); + _lv_inv_area(disp, nullptr); animating = true; DisplayDownScroll(); break; case FullRefreshDirections::RightAnim: case FullRefreshDirections::LeftAnim: + lv_obj_update_layout(disp->act_scr); + _lv_inv_area(disp, nullptr); animating = true; DisplayHorizAnim(); break; @@ -228,12 +221,12 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { // NOtification is still needed (even if there is a mutex on SPI) because of the DataCommand pin // which cannot be set/clear during a transfert. - if (!animating && (scrollDirection == FullRefreshDirections::Down || - scrollDirection == FullRefreshDirections::RightAnim || - scrollDirection == FullRefreshDirections::LeftAnim)){ - StartTransitionAnimation(); - return; - } +// if (!animating && (scrollDirection == FullRefreshDirections::Down || +// scrollDirection == FullRefreshDirections::RightAnim || +// scrollDirection == FullRefreshDirections::LeftAnim)){ +// StartTransitionAnimation(); +// return; +// } if ((scrollDirection == FullRefreshDirections::Up) && (area->y1 == 0)) { writeOffset = (writeOffset + visibleNbLines) % totalNbLines; diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index 57e7b048bf..487bcf2b8f 100644 --- a/src/displayapp/LittleVgl.h +++ b/src/displayapp/LittleVgl.h @@ -25,13 +25,13 @@ namespace Pinetime { bool GetTouchPadInfo(lv_indev_data_t* ptr); void SetFullRefresh(FullRefreshDirections direction); void SetNewTouchPoint(uint16_t x, uint16_t y, bool contact); + void StartTransitionAnimation(); private: void InitDisplay(); void InitTouchpad(); void InitTheme(); - void StartTransitionAnimation(); void DisplayDownScroll(); void DisplayHorizAnim(); diff --git a/src/displayapp/screens/ApplicationList.h b/src/displayapp/screens/ApplicationList.h index 103c38ae0d..e59955b654 100644 --- a/src/displayapp/screens/ApplicationList.h +++ b/src/displayapp/screens/ApplicationList.h @@ -18,6 +18,7 @@ namespace Pinetime { Pinetime::Controllers::Battery& batteryController, Controllers::DateTime& dateTimeController); ~ApplicationList() override; + bool IsNew() { return screens.IsNew(); } bool OnTouchEvent(TouchEvents event) override; private: diff --git a/src/displayapp/screens/Screen.h b/src/displayapp/screens/Screen.h index c36a88da9c..8296c4ae26 100644 --- a/src/displayapp/screens/Screen.h +++ b/src/displayapp/screens/Screen.h @@ -42,6 +42,7 @@ namespace Pinetime { private: virtual void Refresh() { } + bool newScreen {true}; public: explicit Screen(DisplayApp* app) : app {app} { @@ -53,6 +54,15 @@ namespace Pinetime { bool IsRunning() const { return running; } + + virtual bool IsNew() { + if(!newScreen) { + return false; + } else{ + newScreen = false; + return true; + } + } /** @return false if the button hasn't been handled by the app, true if it has been handled */ virtual bool OnButtonPushed() { diff --git a/src/displayapp/screens/ScreenList.h b/src/displayapp/screens/ScreenList.h index a9d747aa0f..2db55e1aef 100644 --- a/src/displayapp/screens/ScreenList.h +++ b/src/displayapp/screens/ScreenList.h @@ -30,6 +30,7 @@ namespace Pinetime { lv_obj_clean(lv_scr_act()); } + bool IsNew() { return current->IsNew(); } bool OnTouchEvent(TouchEvents event) override { if (mode == ScreenListModes::UpDown) { diff --git a/src/displayapp/screens/settings/Settings.h b/src/displayapp/screens/settings/Settings.h index 6c54cdeb03..0ce925a571 100644 --- a/src/displayapp/screens/settings/Settings.h +++ b/src/displayapp/screens/settings/Settings.h @@ -15,6 +15,7 @@ namespace Pinetime { ~Settings() override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; + bool IsNew() { return screens.IsNew(); } private: Controllers::Settings& settingsController; From 60a7229fed5f7788da771b98f4e2b218f37fd7be Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Tue, 12 Oct 2021 13:14:14 -0400 Subject: [PATCH 19/25] add screen transitions for SystemInfo. --- src/displayapp/screens/SystemInfo.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/displayapp/screens/SystemInfo.h b/src/displayapp/screens/SystemInfo.h index bfcc3aa4e6..f87a3f3ab2 100644 --- a/src/displayapp/screens/SystemInfo.h +++ b/src/displayapp/screens/SystemInfo.h @@ -31,6 +31,7 @@ namespace Pinetime { Pinetime::Controllers::MotionController& motionController, Pinetime::Drivers::Cst816S& touchPanel); ~SystemInfo() override; + bool IsNew() { return screens.IsNew(); } bool OnTouchEvent(TouchEvents event) override; private: From 1c06449637e14877e09e52f3639aeece895dd6d0 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Tue, 12 Oct 2021 17:21:56 -0400 Subject: [PATCH 20/25] Fix alignments for QuickSettings and Settings (List). Use flexbox for Quicksettings --- src/displayapp/screens/List.cpp | 43 +++++------ .../screens/settings/QuickSettings.cpp | 77 +++++++++---------- .../screens/settings/QuickSettings.h | 4 + 3 files changed, 59 insertions(+), 65 deletions(-) diff --git a/src/displayapp/screens/List.cpp b/src/displayapp/screens/List.cpp index b0b09d039d..2f1808e60e 100644 --- a/src/displayapp/screens/List.cpp +++ b/src/displayapp/screens/List.cpp @@ -20,7 +20,7 @@ List::List(uint8_t screenID, : Screen(app), settingsController {settingsController} { // Set the background to Black - lv_obj_set_style_bg_color(lv_scr_act(), lv_color_make(0, 0, 0), LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_color(lv_scr_act(), lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT); settingsController.SetSettingsMenu(screenID); @@ -52,50 +52,43 @@ List::List(uint8_t screenID, lv_obj_t* container1 = lv_obj_create(lv_scr_act()); lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_all(container1, 2, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_gap(container1, 4, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_border_width(container1, 0, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_pos(container1, 0, 0); - lv_obj_set_width(container1, LV_HOR_RES - 8); + lv_obj_set_width(container1, LV_HOR_RES - 2); lv_obj_set_height(container1, LV_VER_RES); lv_obj_set_layout(container1, LV_LAYOUT_FLEX); lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_START); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_SPACE_AROUND, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); lv_obj_t* labelBt; lv_obj_t* labelBtIco; for (int i = 0; i < MAXLISTITEMS; i++) { apps[i] = applications[i].application; - if (applications[i].application != Apps::None) { - - itemApps[i] = lv_btn_create(container1); - itemApps[i]->user_data = this; + + itemApps[i] = lv_btn_create(container1); + itemApps[i]->user_data = this; + lv_obj_set_flex_grow(itemApps[i], 1); + lv_obj_set_width(itemApps[i], lv_pct(100)); + + if (applications[i].application == Apps::None){ + lv_obj_set_style_bg_opa(itemApps[i], LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); + } else{ lv_obj_set_style_bg_opa(itemApps[i], LV_OPA_20, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_radius(itemApps[i], 57, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_radius(itemApps[i], LV_RADIUS_CIRCLE, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_bg_color(itemApps[i], lv_color_hex(0x00FFFF), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_width(itemApps[i], LV_HOR_RES - 8); - lv_obj_set_height(itemApps[i], 57); lv_obj_add_event_cb(itemApps[i], ButtonEventHandler, LV_EVENT_ALL, itemApps[i]->user_data); - lv_obj_set_layout(itemApps[i], LV_LAYOUT_FLEX); - lv_obj_set_flex_flow(itemApps[i], LV_FLEX_FLOW_ROW); - lv_obj_set_flex_align(itemApps[i], LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START); - - labelBtIco = lv_label_create(itemApps[i]); - lv_obj_set_style_text_color(labelBtIco, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_label_set_text_static(labelBtIco, applications[i].icon); - + labelBt = lv_label_create(itemApps[i]); - lv_label_set_text_fmt(labelBt, " %s", applications[i].name); + lv_label_set_recolor(labelBt, true); + lv_label_set_text_fmt(labelBt, "#FFEB3B %s #%s", applications[i].icon, applications[i].name); + lv_obj_align(labelBt, LV_ALIGN_LEFT_MID, 10, 0); } } - - lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act()); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); - lv_obj_set_size(backgroundLabel, LV_HOR_RES, LV_VER_RES); - lv_obj_set_pos(backgroundLabel, 0, 0); - lv_label_set_text_static(backgroundLabel, ""); } List::~List() { diff --git a/src/displayapp/screens/settings/QuickSettings.cpp b/src/displayapp/screens/settings/QuickSettings.cpp index 7499255f8c..30383b37ca 100644 --- a/src/displayapp/screens/settings/QuickSettings.cpp +++ b/src/displayapp/screens/settings/QuickSettings.cpp @@ -32,90 +32,87 @@ QuickSettings::QuickSettings(Pinetime::Applications::DisplayApp* app, // This is the distance (padding) between all objects on this screen. static constexpr uint8_t innerDistance = 10; + static constexpr uint8_t barHeight = 20; + static constexpr uint8_t buttonHeight = (LV_VER_RES_MAX - barHeight - innerDistance*3) / 2; + //=== Top bar // Time label_time = lv_label_create(lv_scr_act()); lv_label_set_text_fmt(label_time, "%02i:%02i", dateTimeController.Hours(), dateTimeController.Minutes()); lv_obj_set_style_text_align(label_time, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_align(label_time, LV_ALIGN_TOP_LEFT, 0, 0); - + // Battery batteryIcon = lv_label_create(lv_scr_act()); lv_label_set_text(batteryIcon, BatteryIcon::GetBatteryIcon(batteryController.PercentRemaining())); lv_obj_align(batteryIcon, LV_ALIGN_TOP_RIGHT, 0, 0); - - static constexpr uint8_t barHeight = 20 + innerDistance; - static constexpr uint8_t buttonHeight = (LV_VER_RES_MAX - barHeight - innerDistance) / 2; - static constexpr uint8_t buttonWidth = (LV_HOR_RES_MAX - innerDistance) / 2; // wide buttons - //static constexpr uint8_t buttonWidth = buttonHeight; // square buttons - static constexpr uint8_t buttonXOffset = (LV_HOR_RES_MAX - buttonWidth * 2 - innerDistance) / 2; - + + //=== Buttons + // Button Style lv_style_init(&btn_style); lv_style_set_radius(&btn_style, buttonHeight / 4); lv_style_set_bg_color(&btn_style, lv_color_hex(0x111111)); - - brightnessButton = lv_btn_create(lv_scr_act()); + lv_style_set_flex_grow(&btn_style, 1); + lv_style_set_max_height(&btn_style, lv_pct(50)-innerDistance/2); + lv_style_set_height(&btn_style, lv_pct(100)); + lv_style_set_text_font(&btn_style, &lv_font_sys_48); + + // Flex container + container1 = lv_obj_create(lv_scr_act()); + lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_ROW_WRAP); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_SPACE_EVENLY); + lv_obj_set_size(container1, LV_HOR_RES, LV_VER_RES - barHeight); + lv_obj_align(container1, LV_ALIGN_BOTTOM_MID, 0, 0); + lv_obj_set_style_bg_opa(container1, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_gap(container1, innerDistance, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_pad_all(container1, innerDistance, LV_PART_MAIN | LV_STATE_DEFAULT); + + // Buttons + brightnessButton = lv_btn_create(container1); brightnessButton->user_data = this; lv_obj_add_event_cb(brightnessButton, ButtonEventHandler, LV_EVENT_ALL, brightnessButton->user_data); lv_obj_add_style(brightnessButton, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_size(brightnessButton, buttonWidth, buttonHeight); - lv_obj_align(brightnessButton, LV_ALIGN_TOP_LEFT, buttonXOffset, barHeight); - + brightnessLabel = lv_label_create(brightnessButton); - lv_obj_set_style_text_font(brightnessLabel, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(brightnessLabel, brightness.GetIcon()); lv_obj_center(brightnessLabel); - flashlightButton = lv_btn_create(lv_scr_act()); + + flashlightButton = lv_btn_create(container1); flashlightButton->user_data = this; lv_obj_add_event_cb(flashlightButton, ButtonEventHandler, LV_EVENT_ALL, flashlightButton->user_data); lv_obj_add_style(flashlightButton, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_size(flashlightButton, buttonWidth, buttonHeight); - lv_obj_align(flashlightButton, LV_ALIGN_TOP_RIGHT, - buttonXOffset, barHeight); - - lv_obj_t* flashlightLabel; + flashlightLabel = lv_label_create(flashlightButton); - lv_obj_set_style_text_font(flashlightLabel, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text_static(flashlightLabel, Symbols::highlight); lv_obj_center(flashlightLabel); - notificationButton = lv_btn_create(lv_scr_act()); + + notificationButton = lv_btn_create(container1); notificationButton->user_data = this; lv_obj_add_event_cb(notificationButton, ButtonEventHandler, LV_EVENT_ALL, notificationButton->user_data); - lv_obj_add_flag(notificationButton, LV_OBJ_FLAG_CHECKABLE); lv_obj_add_style(notificationButton, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_add_flag(notificationButton, LV_OBJ_FLAG_CHECKABLE | LV_OBJ_FLAG_FLEX_IN_NEW_TRACK); lv_obj_set_style_bg_color(notificationButton, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_CHECKED); - lv_obj_set_size(notificationButton, buttonWidth, buttonHeight); - lv_obj_align(notificationButton, LV_ALIGN_BOTTOM_LEFT, buttonXOffset, 0); - + notificationLabel = lv_label_create(notificationButton); - lv_obj_set_style_text_font(notificationLabel, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_center(notificationLabel); - if (settingsController.GetNotificationStatus() == Controllers::Settings::Notification::ON) { lv_obj_add_state(notificationButton, LV_STATE_CHECKED); lv_label_set_text_static(notificationLabel, Symbols::notificationsOn); } else { lv_label_set_text_static(notificationLabel, Symbols::notificationsOff); } + lv_obj_center(notificationLabel); - settingsButton = lv_btn_create(lv_scr_act()); + + settingsButton = lv_btn_create(container1); settingsButton->user_data = this; lv_obj_add_event_cb(settingsButton, ButtonEventHandler, LV_EVENT_ALL, settingsButton->user_data); lv_obj_add_style(settingsButton, &btn_style, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_size(settingsButton, buttonWidth, buttonHeight); - lv_obj_align(settingsButton, LV_ALIGN_BOTTOM_RIGHT, - buttonXOffset, 0); - - lv_obj_t *settingsLabel= lv_label_create(settingsButton); - lv_obj_set_style_text_font(settingsLabel, &lv_font_sys_48, LV_PART_MAIN | LV_STATE_DEFAULT); + + settingsLabel = lv_label_create(settingsButton); lv_label_set_text_static(settingsLabel, Symbols::settings); lv_obj_center(settingsLabel); - lv_obj_t* backgroundLabel = lv_label_create(lv_scr_act()); - lv_label_set_long_mode(backgroundLabel, LV_LABEL_LONG_CLIP); - lv_obj_set_size(backgroundLabel, 240, 240); - lv_obj_set_pos(backgroundLabel, 0, 0); - lv_label_set_text_static(backgroundLabel, ""); - taskUpdate = lv_timer_create(lv_update_task, 5000, this); } diff --git a/src/displayapp/screens/settings/QuickSettings.h b/src/displayapp/screens/settings/QuickSettings.h index ff123860d9..5289d6ad70 100644 --- a/src/displayapp/screens/settings/QuickSettings.h +++ b/src/displayapp/screens/settings/QuickSettings.h @@ -47,9 +47,13 @@ namespace Pinetime { lv_obj_t* brightnessButton; lv_obj_t* brightnessLabel; lv_obj_t* flashlightButton; + lv_obj_t* flashlightLabel; lv_obj_t* notificationButton; lv_obj_t* notificationLabel; lv_obj_t* settingsButton; + lv_obj_t* settingsLabel; + + lv_obj_t* container1; }; } } From 9ab44a34ac594b08c0ecfb5698b4549b72401946 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Tue, 12 Oct 2021 21:22:52 -0400 Subject: [PATCH 21/25] Fix most other alignment issues fix arc theming fix notification scroll animation improved redundant drawing in steps, stopwatch --- src/displayapp/lv_pinetime_theme.c | 15 ++++--- src/displayapp/screens/FirmwareValidation.cpp | 2 + src/displayapp/screens/HeartRate.cpp | 18 ++++++-- src/displayapp/screens/HeartRate.h | 4 ++ src/displayapp/screens/Metronome.cpp | 2 + src/displayapp/screens/Music.cpp | 6 +-- src/displayapp/screens/Notifications.cpp | 3 ++ src/displayapp/screens/Notifications.h | 14 ++++++- src/displayapp/screens/PineTimeStyle.cpp | 42 ++++++++++--------- src/displayapp/screens/PineTimeStyle.h | 1 + src/displayapp/screens/Steps.cpp | 11 +++-- src/displayapp/screens/StopWatch.cpp | 10 ++++- src/displayapp/screens/StopWatch.h | 1 + src/displayapp/screens/Timer.cpp | 1 + .../screens/settings/SettingDisplay.cpp | 2 +- .../screens/settings/SettingTimeFormat.cpp | 2 +- .../screens/settings/SettingWakeUp.cpp | 2 +- .../screens/settings/SettingWatchFace.cpp | 2 +- 18 files changed, 93 insertions(+), 45 deletions(-) diff --git a/src/displayapp/lv_pinetime_theme.c b/src/displayapp/lv_pinetime_theme.c index abec609688..f5dfc5c16e 100644 --- a/src/displayapp/lv_pinetime_theme.c +++ b/src/displayapp/lv_pinetime_theme.c @@ -256,14 +256,14 @@ static void style_init(void) lv_style_set_pad_right(&style_slider_knob_pressed, 14); style_init_reset(&style_arc_indic); - lv_style_set_line_color(&style_arc_indic, LV_PINETIME_BLUE); - lv_style_set_line_width(&style_arc_indic, LV_DPX(25)); - lv_style_set_line_rounded(&style_arc_indic, true); + lv_style_set_arc_color(&style_arc_indic, LV_PINETIME_BLUE); + lv_style_set_arc_width(&style_arc_indic, LV_DPX(25)); + lv_style_set_arc_rounded(&style_arc_indic, true); style_init_reset(&style_arc_bg); - lv_style_set_line_color(&style_arc_bg, LV_PINETIME_GRAY); - lv_style_set_line_width(&style_arc_bg, LV_DPX(25)); - lv_style_set_line_rounded(&style_arc_bg, true); + lv_style_set_arc_color(&style_arc_bg, LV_PINETIME_GRAY); + lv_style_set_arc_width(&style_arc_bg, LV_DPX(25)); + lv_style_set_arc_rounded(&style_arc_bg, true); lv_style_set_pad_all(&style_arc_bg, LV_DPX(5)); lv_style_reset(&style_arc_knob); @@ -381,6 +381,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) if (lv_obj_get_parent(obj) == NULL) { lv_obj_add_style(obj, &style_bg, 0); lv_obj_add_style(obj, &style_label_white, 0); + // Make screens not scrollable by default + lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLLABLE); return; } @@ -431,6 +433,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) #if LV_USE_CHECKBOX else if (lv_obj_check_type(obj, &lv_checkbox_class)) { lv_obj_add_style(obj, &style_cb_bg, 0); + lv_obj_add_style(obj, &style_label_white, 0); lv_obj_add_style(obj, &style_btn, LV_PART_INDICATOR); lv_obj_add_style(obj, &style_btn_checked, LV_PART_INDICATOR | LV_STATE_CHECKED); diff --git a/src/displayapp/screens/FirmwareValidation.cpp b/src/displayapp/screens/FirmwareValidation.cpp index 3f30e647bb..f892410215 100644 --- a/src/displayapp/screens/FirmwareValidation.cpp +++ b/src/displayapp/screens/FirmwareValidation.cpp @@ -46,6 +46,7 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app, labelButtonValidate = lv_label_create(buttonValidate); lv_label_set_text_static(labelButtonValidate, "Validate"); + lv_obj_center(labelButtonValidate); buttonReset = lv_btn_create(lv_scr_act()); buttonReset->user_data = this; @@ -56,6 +57,7 @@ FirmwareValidation::FirmwareValidation(Pinetime::Applications::DisplayApp* app, labelButtonReset = lv_label_create(buttonReset); lv_label_set_text_static(labelButtonReset, "Reset"); + lv_obj_center(labelButtonReset); } } diff --git a/src/displayapp/screens/HeartRate.cpp b/src/displayapp/screens/HeartRate.cpp index 850cbb0126..987c61c613 100644 --- a/src/displayapp/screens/HeartRate.cpp +++ b/src/displayapp/screens/HeartRate.cpp @@ -77,18 +77,28 @@ HeartRate::~HeartRate() { void HeartRate::Refresh() { auto state = heartRateController.State(); + switch (state) { case Controllers::HeartRateController::States::NoTouch: case Controllers::HeartRateController::States::NotEnoughData: // case Controllers::HeartRateController::States::Stopped: - lv_label_set_text(label_hr, "000"); + if (state != prevState) { + lv_label_set_text(label_hr, "000"); + } break; default: - lv_label_set_text_fmt(label_hr, "%03d", heartRateController.HeartRate()); + uint8_t heartRate = heartRateController.HeartRate(); + if (heartRate != prevHeartRate) { + lv_label_set_text_fmt(label_hr, "%03d", heartRate); + prevHeartRate = heartRate; + } } - lv_label_set_text(label_status, ToString(state)); - lv_obj_align_to(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); + if (state != prevState) { + lv_label_set_text(label_status, ToString(state)); + lv_obj_align_to(label_status, label_hr, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); + } + prevState = state; } void HeartRate::OnStartStopEvent(lv_event_t* event) { diff --git a/src/displayapp/screens/HeartRate.h b/src/displayapp/screens/HeartRate.h index 4775203e62..7fd8dca93e 100644 --- a/src/displayapp/screens/HeartRate.h +++ b/src/displayapp/screens/HeartRate.h @@ -3,6 +3,7 @@ #include #include #include "Screen.h" +#include #include #include "systemtask/SystemTask.h" #include @@ -28,6 +29,9 @@ namespace Pinetime { Controllers::HeartRateController& heartRateController; Pinetime::System::SystemTask& systemTask; void UpdateStartStopButton(bool isRunning); + Controllers::HeartRateController::States prevState = Controllers::HeartRateController::States::Stopped; + uint8_t prevHeartRate = 0; + lv_obj_t* label_hr; lv_obj_t* label_bpm; lv_obj_t* label_status; diff --git a/src/displayapp/screens/Metronome.cpp b/src/displayapp/screens/Metronome.cpp index aaf4579f7c..9ad58e49f8 100644 --- a/src/displayapp/screens/Metronome.cpp +++ b/src/displayapp/screens/Metronome.cpp @@ -53,9 +53,11 @@ Metronome::Metronome(DisplayApp* app, Controllers::MotorController& motorControl // lv_obj_set_style_pad_left(bpbDropdown, 20, LV_DROPDOWN_PART_LIST | LV_STATE_DEFAULT); lv_obj_set_size(bpbDropdown, 115, 50); lv_obj_align(bpbDropdown, LV_ALIGN_BOTTOM_LEFT, 0, 0); + lv_obj_set_style_text_align(bpbDropdown, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); lv_dropdown_set_options(bpbDropdown, "1\n2\n3\n4\n5\n6\n7\n8\n9"); lv_dropdown_set_selected(bpbDropdown, bpb - 1); lv_dropdown_set_text(bpbDropdown, ""); + lv_dropdown_set_symbol(bpbDropdown, nullptr); currentBpbText = lv_label_create(bpbDropdown); lv_label_set_text_fmt(currentBpbText, "%d bpb", bpb); diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp index 823631ac3e..e1b3191b32 100644 --- a/src/displayapp/screens/Music.cpp +++ b/src/displayapp/screens/Music.cpp @@ -111,7 +111,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SCROLL); lv_obj_align(txtTrackDuration, LV_ALIGN_TOP_LEFT, 12, 20); lv_label_set_text(txtTrackDuration, "--:--/--:--"); - lv_obj_set_align(txtTrackDuration, LV_ALIGN_LEFT_MID); + lv_obj_set_style_text_align(txtTrackDuration, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_width(txtTrackDuration, LV_HOR_RES); constexpr uint8_t FONT_HEIGHT = 12; @@ -120,7 +120,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus txtArtist = lv_label_create(lv_scr_act()); lv_label_set_long_mode(txtArtist, LV_LABEL_LONG_SCROLL_CIRCULAR); lv_obj_align(txtArtist, LV_ALIGN_LEFT_MID, 12, MIDDLE_OFFSET + 1 * FONT_HEIGHT); - lv_obj_set_align(txtArtist, LV_ALIGN_LEFT_MID); + lv_obj_set_style_text_align(txtArtist, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_width(txtArtist, LV_HOR_RES - 12); lv_label_set_text(txtArtist, "Artist Name"); @@ -128,7 +128,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus lv_label_set_long_mode(txtTrack, LV_LABEL_LONG_SCROLL_CIRCULAR); lv_obj_align(txtTrack, LV_ALIGN_LEFT_MID, 12, MIDDLE_OFFSET + 2 * FONT_HEIGHT + LINE_PAD); - lv_obj_set_align(txtTrack, LV_ALIGN_LEFT_MID); + lv_obj_set_style_text_align(txtTrack, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_width(txtTrack, LV_HOR_RES - 12); lv_label_set_text(txtTrack, "This is a very long getTrack name"); diff --git a/src/displayapp/screens/Notifications.cpp b/src/displayapp/screens/Notifications.cpp index 4fbe91fe5d..a0087ab4a6 100644 --- a/src/displayapp/screens/Notifications.cpp +++ b/src/displayapp/screens/Notifications.cpp @@ -212,6 +212,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_obj_align(bt_accept, LV_ALIGN_BOTTOM_LEFT, 0, 0); label_accept = lv_label_create(bt_accept); lv_label_set_text(label_accept, Symbols::phone); + lv_obj_center(label_accept); lv_obj_set_style_bg_color(bt_accept, lv_palette_main(LV_PALETTE_GREEN), LV_PART_MAIN | LV_STATE_DEFAULT); bt_reject = lv_btn_create(lv_scr_act()); @@ -221,6 +222,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_obj_align(bt_reject, LV_ALIGN_BOTTOM_MID, 0, 0); label_reject = lv_label_create(bt_reject); lv_label_set_text(label_reject, Symbols::phoneSlash); + lv_obj_center(label_reject); lv_obj_set_style_bg_color(bt_reject, lv_palette_main(LV_PALETTE_RED), LV_PART_MAIN | LV_STATE_DEFAULT); bt_mute = lv_btn_create(lv_scr_act()); @@ -230,6 +232,7 @@ Notifications::NotificationItem::NotificationItem(const char* title, lv_obj_align(bt_mute, LV_ALIGN_BOTTOM_RIGHT, 0, 0); label_mute = lv_label_create(bt_mute); lv_label_set_text(label_mute, Symbols::volumMute); + lv_obj_center(label_mute); lv_obj_set_style_bg_color(bt_mute, lv_palette_main(LV_PALETTE_GREY), LV_PART_MAIN | LV_STATE_DEFAULT); } break; } diff --git a/src/displayapp/screens/Notifications.h b/src/displayapp/screens/Notifications.h index 81843bf5dd..6ed8a958f4 100644 --- a/src/displayapp/screens/Notifications.h +++ b/src/displayapp/screens/Notifications.h @@ -23,10 +23,10 @@ namespace Pinetime { Pinetime::Controllers::MotorController& motorController, Modes mode); ~Notifications() override; - + bool IsNew() { return currentItem->IsNew(); } void Refresh() override; bool OnTouchEvent(Pinetime::Applications::TouchEvents event) override; - + class NotificationItem { public: NotificationItem(const char* title, @@ -41,6 +41,15 @@ namespace Pinetime { return running; } void OnCallButtonEvent(lv_obj_t* obj, lv_event_t* event); + + bool IsNew() { + if(!newScreen) { + return false; + } else{ + newScreen = false; + return true; + } + } private: lv_obj_t* container1; @@ -53,6 +62,7 @@ namespace Pinetime { Modes mode; Pinetime::Controllers::AlertNotificationService& alertNotificationService; bool running = true; + bool newScreen = true; }; private: diff --git a/src/displayapp/screens/PineTimeStyle.cpp b/src/displayapp/screens/PineTimeStyle.cpp index c6ac0250a0..0435818fe2 100644 --- a/src/displayapp/screens/PineTimeStyle.cpp +++ b/src/displayapp/screens/PineTimeStyle.cpp @@ -96,18 +96,18 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_obj_align(sidebar, LV_ALIGN_TOP_RIGHT, 0, 0); // Display icons - batteryIcon = lv_label_create(lv_scr_act()); + batteryIcon = lv_label_create(sidebar); lv_obj_set_style_text_color(batteryIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(batteryIcon, Symbols::batteryFull); - lv_obj_align_to(batteryIcon, sidebar, LV_ALIGN_TOP_MID, 0, 2); + lv_obj_align(batteryIcon, LV_ALIGN_TOP_MID, 0, 2); - bleIcon = lv_label_create(lv_scr_act()); + bleIcon = lv_label_create(sidebar); lv_obj_set_style_text_color(bleIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align_to(bleIcon, sidebar, LV_ALIGN_TOP_MID, 0, 25); + lv_obj_align(bleIcon, LV_ALIGN_TOP_MID, 0, 25); - notificationIcon = lv_label_create(lv_scr_act()); + notificationIcon = lv_label_create(sidebar); lv_obj_set_style_text_color(notificationIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align_to(notificationIcon, sidebar, LV_ALIGN_TOP_MID, 0, 40); + lv_obj_align(notificationIcon, LV_ALIGN_TOP_MID, 0, 40); // Calendar icon calendarOuter = lv_obj_create(lv_scr_act()); @@ -152,10 +152,10 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_label_set_text(dateDayOfWeek, "THU"); lv_obj_align_to(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34); - dateDay = lv_label_create(lv_scr_act()); + dateDay = lv_label_create(calendarInner); lv_obj_set_style_text_color(dateDay, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateDay, "25"); - lv_obj_align_to(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3); + lv_obj_center(dateDay); dateMonth = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(dateMonth, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); @@ -163,24 +163,26 @@ PineTimeStyle::PineTimeStyle(DisplayApp* app, lv_obj_align_to(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32); // Step count gauge + stepCont = lv_obj_create(lv_scr_act()); + lv_obj_set_size(stepCont, 40, 40); + lv_obj_align(stepCont, LV_ALIGN_BOTTOM_RIGHT, 0, 0); + needle_color = lv_color_white(); - stepMeter = lv_meter_create(lv_scr_act()); + stepMeter = lv_meter_create(stepCont); + lv_obj_set_size(stepMeter, 37, 37); + lv_obj_center(stepMeter); + stepScale = lv_meter_add_scale(stepMeter); - stepIndicator = lv_meter_add_needle_line(stepMeter, stepScale, 3, needle_color, 0); + stepIndicator = lv_meter_add_needle_line(stepMeter, stepScale, 2, needle_color, -6); lv_meter_set_scale_range(stepMeter, stepScale, 0, 100, 360, 180); lv_meter_set_scale_ticks(stepMeter, stepScale, 11, 4, 4, lv_color_black()); - lv_obj_set_size(stepMeter, 40, 40); - lv_obj_align_to(stepMeter, sidebar, LV_ALIGN_BOTTOM_MID, 0, 0); lv_meter_set_indicator_value(stepMeter, stepIndicator, 0); - lv_obj_set_style_pad_right(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_left(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_bottom(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_line_opa(stepMeter, LV_OPA_COVER, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_line_width(stepMeter, 4, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_line_color(stepMeter, lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_line_opa(stepMeter, LV_OPA_COVER, LV_PART_INDICATOR | LV_STATE_DEFAULT); - lv_obj_set_style_pad_gap(stepMeter, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT);; + lv_obj_set_style_pad_all(stepMeter, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_opa(stepMeter, LV_OPA_TRANSP, LV_PART_INDICATOR | LV_STATE_DEFAULT); + lv_obj_set_style_bg_opa(stepMeter, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_color(stepMeter, lv_color_black(), LV_PART_TICKS | LV_STATE_DEFAULT); + lv_obj_set_style_bg_opa(stepCont, LV_OPA_TRANSP, 0); backgroundLabel = lv_label_create(lv_scr_act()); lv_obj_add_flag(backgroundLabel, LV_OBJ_FLAG_CLICKABLE); diff --git a/src/displayapp/screens/PineTimeStyle.h b/src/displayapp/screens/PineTimeStyle.h index abbc398dca..5bd2bb0556 100644 --- a/src/displayapp/screens/PineTimeStyle.h +++ b/src/displayapp/screens/PineTimeStyle.h @@ -66,6 +66,7 @@ namespace Pinetime { lv_obj_t* calendarCrossBar1; lv_obj_t* calendarCrossBar2; lv_obj_t* notificationIcon; + lv_obj_t* stepCont; lv_obj_t* stepMeter; lv_meter_scale_t* stepScale; lv_meter_indicator_t* stepIndicator; diff --git a/src/displayapp/screens/Steps.cpp b/src/displayapp/screens/Steps.cpp index 2b6ead16f7..60212d6c73 100644 --- a/src/displayapp/screens/Steps.cpp +++ b/src/displayapp/screens/Steps.cpp @@ -20,6 +20,7 @@ Steps::Steps(Pinetime::Applications::DisplayApp* app, lv_obj_set_size(stepsArc, 220, 220); lv_arc_set_range(stepsArc, 0, 500); lv_obj_align(stepsArc, LV_ALIGN_CENTER, 0, 0); + lv_obj_clear_flag(stepsArc, LV_OBJ_FLAG_CLICKABLE); stepsCount = motionController.NbSteps(); @@ -57,10 +58,12 @@ Steps::~Steps() { } void Steps::Refresh() { - stepsCount = motionController.NbSteps(); + if (motionController.NbSteps() != stepsCount) { + stepsCount = motionController.NbSteps(); - lv_label_set_text_fmt(lSteps, "%li", stepsCount); - lv_obj_align(lSteps, LV_ALIGN_CENTER, 0, -20); + lv_label_set_text_fmt(lSteps, "%li", stepsCount); + lv_obj_align(lSteps, LV_ALIGN_CENTER, 0, -20); - lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal())); + lv_arc_set_value(stepsArc, int16_t(500 * stepsCount / settingsController.GetStepsGoal())); + } } diff --git a/src/displayapp/screens/StopWatch.cpp b/src/displayapp/screens/StopWatch.cpp index 24f12e2ba3..e907f1b2ed 100644 --- a/src/displayapp/screens/StopWatch.cpp +++ b/src/displayapp/screens/StopWatch.cpp @@ -142,6 +142,7 @@ void StopWatch::start() { lv_label_set_text(txtStopLap, Symbols::lapsFlag); startTime = xTaskGetTickCount(); currentState = States::Running; + prevTime = {0,0,0}; systemTask.PushMessage(Pinetime::System::Messages::DisableSleeping); } @@ -162,8 +163,13 @@ void StopWatch::Refresh() { timeElapsed = calculateDelta(startTime, xTaskGetTickCount()); currentTimeSeparated = convertTicksToTimeSegments((oldTimeElapsed + timeElapsed)); - lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs); - lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.hundredths); + if (currentTimeSeparated.mins != prevTime.mins || currentTimeSeparated.secs != prevTime.secs) { + lv_label_set_text_fmt(time, "%02d:%02d", currentTimeSeparated.mins, currentTimeSeparated.secs); + } + if (currentTimeSeparated.hundredths != prevTime.hundredths) { + lv_label_set_text_fmt(msecTime, "%02d", currentTimeSeparated.hundredths); + } + prevTime = currentTimeSeparated; } } diff --git a/src/displayapp/screens/StopWatch.h b/src/displayapp/screens/StopWatch.h index 1c4645dd74..62b8f89dda 100644 --- a/src/displayapp/screens/StopWatch.h +++ b/src/displayapp/screens/StopWatch.h @@ -81,6 +81,7 @@ namespace Pinetime::Applications::Screens { TickType_t startTime; TickType_t oldTimeElapsed; TimeSeparated_t currentTimeSeparated; // Holds Mins, Secs, millisecs + TimeSeparated_t prevTime; LapTextBuffer_t<2> lapBuffer; int lapNr = 0; lv_obj_t *time, *msecTime, *btnPlayPause, *btnStopLap, *txtPlayPause, *txtStopLap; diff --git a/src/displayapp/screens/Timer.cpp b/src/displayapp/screens/Timer.cpp index 9b3a5dc3d7..15acb4a7f1 100644 --- a/src/displayapp/screens/Timer.cpp +++ b/src/displayapp/screens/Timer.cpp @@ -67,6 +67,7 @@ Timer::Timer(DisplayApp* app, Controllers::TimerController& timerController) lv_obj_align(btnPlayPause, LV_ALIGN_BOTTOM_MID, 0, -10); lv_obj_set_height(btnPlayPause, 40); txtPlayPause = lv_label_create(btnPlayPause); + lv_obj_center(txtPlayPause); if (timerController.IsRunning()) { lv_label_set_text(txtPlayPause, Symbols::pause); } else { diff --git a/src/displayapp/screens/settings/SettingDisplay.cpp b/src/displayapp/screens/settings/SettingDisplay.cpp index ace3c4e083..f0c8ac63cb 100644 --- a/src/displayapp/screens/settings/SettingDisplay.cpp +++ b/src/displayapp/screens/settings/SettingDisplay.cpp @@ -29,7 +29,7 @@ SettingDisplay::SettingDisplay(Pinetime::Applications::DisplayApp* app, Pinetime lv_obj_set_height(container1, LV_VER_RES - 50); lv_obj_set_layout(container1, LV_LAYOUT_FLEX); lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); lv_obj_t* title = lv_label_create(lv_scr_act()); diff --git a/src/displayapp/screens/settings/SettingTimeFormat.cpp b/src/displayapp/screens/settings/SettingTimeFormat.cpp index d3d4b0c1f0..4ad52076e7 100644 --- a/src/displayapp/screens/settings/SettingTimeFormat.cpp +++ b/src/displayapp/screens/settings/SettingTimeFormat.cpp @@ -28,7 +28,7 @@ SettingTimeFormat::SettingTimeFormat(Pinetime::Applications::DisplayApp* app, Pi lv_obj_set_height(container1, LV_VER_RES - 50); lv_obj_set_layout(container1, LV_LAYOUT_FLEX); lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); lv_obj_t* title = lv_label_create(lv_scr_act()); lv_label_set_text_static(title, "Time format"); diff --git a/src/displayapp/screens/settings/SettingWakeUp.cpp b/src/displayapp/screens/settings/SettingWakeUp.cpp index 4d05997f7b..93b778ae71 100644 --- a/src/displayapp/screens/settings/SettingWakeUp.cpp +++ b/src/displayapp/screens/settings/SettingWakeUp.cpp @@ -29,7 +29,7 @@ SettingWakeUp::SettingWakeUp(Pinetime::Applications::DisplayApp* app, Pinetime:: lv_obj_set_height(container1, LV_VER_RES - 50); lv_obj_set_layout(container1, LV_LAYOUT_FLEX); lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); lv_obj_t* title = lv_label_create(lv_scr_act()); diff --git a/src/displayapp/screens/settings/SettingWatchFace.cpp b/src/displayapp/screens/settings/SettingWatchFace.cpp index 78cbd36558..04b01c5e50 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.cpp +++ b/src/displayapp/screens/settings/SettingWatchFace.cpp @@ -28,7 +28,7 @@ SettingWatchFace::SettingWatchFace(Pinetime::Applications::DisplayApp* app, Pine lv_obj_set_height(container1, LV_VER_RES - 50); lv_obj_set_layout(container1, LV_LAYOUT_FLEX); lv_obj_set_flex_flow(container1, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); + lv_obj_set_flex_align(container1, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER); lv_obj_t* title = lv_label_create(lv_scr_act()); lv_label_set_text_static(title, "Watch face"); From dd9ba775e8c7e454d6303c99a8cb7da4a55aa86f Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Tue, 12 Oct 2021 21:48:35 -0400 Subject: [PATCH 22/25] Port PTS fixes to SettingPTS --- .../screens/settings/SettingPineTimeStyle.cpp | 38 ++++++++++--------- .../screens/settings/SettingPineTimeStyle.h | 1 + 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp index 9e217710d0..a0cebaf3e1 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.cpp +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.cpp @@ -48,14 +48,14 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a lv_obj_align(sidebar, LV_ALIGN_TOP_RIGHT, 0, 0); // Display icons - batteryIcon = lv_label_create(lv_scr_act()); + batteryIcon = lv_label_create(sidebar); lv_obj_set_style_text_color(batteryIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(batteryIcon, Symbols::batteryFull); - lv_obj_align_to(batteryIcon, sidebar, LV_ALIGN_TOP_MID, 0, 2); + lv_obj_align(batteryIcon, LV_ALIGN_TOP_MID, 0, 2); - bleIcon = lv_label_create(lv_scr_act()); + bleIcon = lv_label_create(sidebar); lv_obj_set_style_text_color(bleIcon, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_align_to(bleIcon, sidebar, LV_ALIGN_TOP_MID, 0, 25); + lv_obj_align(bleIcon, LV_ALIGN_TOP_MID, 0, 25); // Calendar icon calendarOuter = lv_obj_create(lv_scr_act()); @@ -100,10 +100,10 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a lv_label_set_text(dateDayOfWeek, "THU"); lv_obj_align_to(dateDayOfWeek, sidebar, LV_ALIGN_CENTER, 0, -34); - dateDay = lv_label_create(lv_scr_act()); + dateDay = lv_label_create(calendarInner); lv_obj_set_style_text_color(dateDay, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(dateDay, "25"); - lv_obj_align_to(dateDay, sidebar, LV_ALIGN_CENTER, 0, 3); + lv_obj_center(dateDay); dateMonth = lv_label_create(lv_scr_act()); lv_obj_set_style_text_color(dateMonth, lv_color_hex(0x000000), LV_PART_MAIN | LV_STATE_DEFAULT); @@ -111,24 +111,26 @@ SettingPineTimeStyle::SettingPineTimeStyle(Pinetime::Applications::DisplayApp* a lv_obj_align_to(dateMonth, sidebar, LV_ALIGN_CENTER, 0, 32); // Step count gauge + stepCont = lv_obj_create(lv_scr_act()); + lv_obj_set_size(stepCont, 40, 40); + lv_obj_align(stepCont, LV_ALIGN_BOTTOM_RIGHT, 0, 0); + needle_color = lv_color_white(); - stepMeter = lv_meter_create(lv_scr_act()); + stepMeter = lv_meter_create(stepCont); + lv_obj_set_size(stepMeter, 37, 37); + lv_obj_center(stepMeter); + stepScale = lv_meter_add_scale(stepMeter); - stepIndicator = lv_meter_add_needle_line(stepMeter, stepScale, 3, needle_color, 0); + stepIndicator = lv_meter_add_needle_line(stepMeter, stepScale, 2, needle_color, -6); lv_meter_set_scale_range(stepMeter, stepScale, 0, 100, 360, 180); lv_meter_set_scale_ticks(stepMeter, stepScale, 11, 4, 4, lv_color_black()); - lv_obj_set_size(stepMeter, 40, 40); - lv_obj_align_to(stepMeter, sidebar, LV_ALIGN_BOTTOM_MID, 0, 0); lv_meter_set_indicator_value(stepMeter, stepIndicator, 0); - lv_obj_set_style_pad_right(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_left(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_pad_bottom(stepMeter, 3, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_line_opa(stepMeter, LV_OPA_COVER, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_line_width(stepMeter, 4, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_line_color(stepMeter, lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_set_style_line_opa(stepMeter, LV_OPA_COVER, LV_PART_INDICATOR | LV_STATE_DEFAULT); - lv_obj_set_style_pad_gap(stepMeter, 4, LV_PART_INDICATOR | LV_STATE_DEFAULT);; + lv_obj_set_style_pad_all(stepMeter, 0, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_bg_opa(stepMeter, LV_OPA_TRANSP, LV_PART_INDICATOR | LV_STATE_DEFAULT); + lv_obj_set_style_bg_opa(stepMeter, LV_OPA_TRANSP, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_line_color(stepMeter, lv_color_black(), LV_PART_TICKS | LV_STATE_DEFAULT); + lv_obj_set_style_bg_opa(stepCont, LV_OPA_TRANSP, 0); backgroundLabel = lv_label_create(lv_scr_act()); lv_obj_add_flag(backgroundLabel, LV_OBJ_FLAG_CLICKABLE); diff --git a/src/displayapp/screens/settings/SettingPineTimeStyle.h b/src/displayapp/screens/settings/SettingPineTimeStyle.h index cd281fb6c9..e373d6263f 100644 --- a/src/displayapp/screens/settings/SettingPineTimeStyle.h +++ b/src/displayapp/screens/settings/SettingPineTimeStyle.h @@ -49,6 +49,7 @@ namespace Pinetime { lv_obj_t * calendarCrossBar1; lv_obj_t * calendarCrossBar2; lv_obj_t * stepMeter; + lv_obj_t* stepCont; lv_meter_scale_t * stepScale; lv_meter_indicator_t * stepIndicator; lv_color_t needle_color; From ce63f51e83a5117cf176044428e845c2d33e36e5 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Wed, 13 Oct 2021 15:10:41 -0400 Subject: [PATCH 23/25] Another attempt fixing animation issues Move all transition animations to the new logic --- src/displayapp/DisplayApp.cpp | 2 +- src/displayapp/LittleVgl.cpp | 102 ++++++++++++++----------------- src/displayapp/LittleVgl.h | 2 +- src/displayapp/screens/Music.cpp | 2 +- 4 files changed, 50 insertions(+), 58 deletions(-) diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 4f31916ac7..1ca35ae0ab 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -149,7 +149,7 @@ void DisplayApp::InitHw() { void DisplayApp::Refresh() { TickType_t queueTimeout; - if (currentScreen.get()->IsNew()){ + if (currentScreen->IsNew()){ doScreenTransition(); } switch (state) { diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index ddcf84d0bc..fbe22b26a3 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -80,41 +80,67 @@ void LittleVgl::SetFullRefresh(FullRefreshDirections direction) { } -void LittleVgl::DisplayDownScroll(){ +void LittleVgl::DisplayVerScroll(){ // For each segment, draw the full width, 4 lines at a time starting from the bottom // TODO: Should probably calculate this from the size of the draw buffer int16_t height = 4; int16_t width = 240; int16_t y2 = 240; int16_t y1 = 240 - height; + int16_t stepSign = -1; lv_area_t area; area.x1 = 0; area.x2 = width; - // Start from the bottom and create a 4 line high box - for (y1 = 240 - height; y1 >= 0; y1 -= height) { + bool (*CheckEnd)(int16_t){}; + + if (scrollDirection == FullRefreshDirections::Down){ + y1 = 240 - height; + CheckEnd = [](int16_t y) -> bool { + return (y >= 0); + }; + stepSign = -1; + // move past the non visible lines + writeOffset = scrollOffset; + writeOffset += (totalNbLines - visibleNbLines); + // and wrap around to the start of address space + writeOffset %= totalNbLines; + + + } else if (scrollDirection == FullRefreshDirections::Up){ + y1 = 0; + CheckEnd = [](int16_t y) -> bool { + return (y < LV_VER_RES); + }; + stepSign = 1; + // When scrolling up, we want to start writing at the line after the current screen + writeOffset = scrollOffset+visibleNbLines; + // Wrap if needed + writeOffset %= totalNbLines; + } + + // Loop over 4 px high boxes either up or down + for (; CheckEnd(y1); y1 += stepSign*height) { y2 = y1 + height - 1; - // If the box has reached the end of the visible line on the lcd controller... - if (y2 == visibleNbLines - 1) { - // move past the non visible lines - writeOffset += (totalNbLines - visibleNbLines); - // and wrap around to the start of address space - writeOffset %= totalNbLines; - } // Set new box area.y1 = y1; area.y2 = y2; // Scroll as we draw - uint16_t toScroll = height; - if (scrollOffset >= toScroll) - scrollOffset -= toScroll; - else { // now we need to wrap the scroll address - toScroll -= scrollOffset; - scrollOffset = totalNbLines - toScroll; + // The old logic works fine -- this looks more clear to me. + // The old logic can be ported back if wanted. + auto newScrollOffset = (int16_t)scrollOffset; + newScrollOffset += (stepSign*height); + // If the result is negative, wrap up + if (newScrollOffset < 0){ + newScrollOffset += totalNbLines; + } else { + // else wrap down + newScrollOffset %= totalNbLines; } + scrollOffset = (uint16_t)newScrollOffset; lcd.VerticalScrollStartAddress(scrollOffset); lv_disp_t* disp = lv_disp_get_default(); @@ -124,7 +150,7 @@ void LittleVgl::DisplayDownScroll(){ _lv_inv_area(disp, &area); // cancel any current flushes in the display driver // Since we've stopped timers, it will be waiting forever if there is currently a flush - lv_disp_flush_ready(disp->driver); +// lv_disp_flush_ready(disp->driver); lv_refr_now(disp); } // Done! clear flags and enable timers @@ -186,7 +212,7 @@ void LittleVgl::DisplayHorizAnim() { lv_disp_t* disp = lv_disp_get_default(); _lv_inv_area(disp, nullptr); _lv_inv_area(disp, &area); - lv_disp_flush_ready(disp->driver); +// lv_disp_flush_ready(disp->driver); lv_refr_now(disp); } scrollDirection = FullRefreshDirections::None; @@ -196,11 +222,12 @@ void LittleVgl::DisplayHorizAnim() { void LittleVgl::StartTransitionAnimation() { lv_disp_t* disp = lv_disp_get_default(); switch(scrollDirection){ + case FullRefreshDirections::Up: case FullRefreshDirections::Down: lv_obj_update_layout(disp->act_scr); _lv_inv_area(disp, nullptr); animating = true; - DisplayDownScroll(); + DisplayVerScroll(); break; case FullRefreshDirections::RightAnim: case FullRefreshDirections::LeftAnim: @@ -212,6 +239,7 @@ void LittleVgl::StartTransitionAnimation() { default: break; } +// lv_timer_resume(disp->refr_timer); } void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { @@ -220,17 +248,6 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { ulTaskNotifyTake(pdTRUE, 200); // NOtification is still needed (even if there is a mutex on SPI) because of the DataCommand pin // which cannot be set/clear during a transfert. - -// if (!animating && (scrollDirection == FullRefreshDirections::Down || -// scrollDirection == FullRefreshDirections::RightAnim || -// scrollDirection == FullRefreshDirections::LeftAnim)){ -// StartTransitionAnimation(); -// return; -// } - - if ((scrollDirection == FullRefreshDirections::Up) && (area->y1 == 0)) { - writeOffset = (writeOffset + visibleNbLines) % totalNbLines; - } y1 = (area->y1 + writeOffset) % totalNbLines; y2 = (area->y2 + writeOffset) % totalNbLines; @@ -238,31 +255,6 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { width = (area->x2 - area->x1) + 1; height = (area->y2 - area->y1) + 1; - if (scrollDirection == FullRefreshDirections::Up) { - - if (area->y1 > 0) { - if (area->y2 == visibleNbLines - 1) { - scrollOffset += (height * 2); - scrollDirection = FullRefreshDirections::None; -// lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); - } else { - scrollOffset += height; - } - scrollOffset = scrollOffset % totalNbLines; - lcd.VerticalScrollStartAddress(scrollOffset); - } - } else if (scrollDirection == FullRefreshDirections::Left or scrollDirection == FullRefreshDirections::LeftAnim) { - if (area->x2 == visibleNbLines - 1) { - scrollDirection = FullRefreshDirections::None; -// lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); - } - } else if (scrollDirection == FullRefreshDirections::Right or scrollDirection == FullRefreshDirections::RightAnim) { - if (area->x1 == 0) { - scrollDirection = FullRefreshDirections::None; -// lv_disp_set_rotation(lv_disp_get_default(), LV_DISP_ROT_NONE); - } - } - if (y2 < y1) { height = totalNbLines - y1; diff --git a/src/displayapp/LittleVgl.h b/src/displayapp/LittleVgl.h index 487bcf2b8f..42b55ac65d 100644 --- a/src/displayapp/LittleVgl.h +++ b/src/displayapp/LittleVgl.h @@ -32,7 +32,7 @@ namespace Pinetime { void InitTouchpad(); void InitTheme(); - void DisplayDownScroll(); + void DisplayVerScroll(); void DisplayHorizAnim(); Pinetime::Drivers::St7789& lcd; diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp index e1b3191b32..675021fac2 100644 --- a/src/displayapp/screens/Music.cpp +++ b/src/displayapp/screens/Music.cpp @@ -130,7 +130,7 @@ Music::Music(Pinetime::Applications::DisplayApp* app, Pinetime::Controllers::Mus lv_obj_set_style_text_align(txtTrack, LV_TEXT_ALIGN_LEFT, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_width(txtTrack, LV_HOR_RES - 12); - lv_label_set_text(txtTrack, "This is a very long getTrack name"); + lv_label_set_text(txtTrack, "Track name"); /** Init animation */ imgDisc = lv_img_create(lv_scr_act()); From ce2376750df305a79be07f7d60039b5fb50ceeb0 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Thu, 14 Oct 2021 18:03:01 -0400 Subject: [PATCH 24/25] Fix screen animation errors (testing with actual ST7789) Removed the notification to protect the data/cmd lcd pin, instead stuffed that logic inside the mutex of the Spi driver... This probably isn't the BEST way to do it, but it's working great for now. --- src/components/gfx/Gfx.cpp | 2 +- src/displayapp/DisplayApp.cpp | 2 +- src/displayapp/DisplayAppRecovery.cpp | 6 +-- src/displayapp/LittleVgl.cpp | 4 +- src/drivers/Spi.cpp | 4 +- src/drivers/Spi.h | 2 +- src/drivers/SpiMaster.cpp | 10 +++- src/drivers/SpiMaster.h | 2 +- src/drivers/St7789.cpp | 71 +++++++++++++-------------- src/drivers/St7789.h | 3 +- src/recoveryLoader.cpp | 4 +- 11 files changed, 58 insertions(+), 52 deletions(-) diff --git a/src/components/gfx/Gfx.cpp b/src/components/gfx/Gfx.cpp index cf271032d7..5557efa966 100644 --- a/src/components/gfx/Gfx.cpp +++ b/src/components/gfx/Gfx.cpp @@ -184,7 +184,7 @@ void Gfx::NotifyEndOfTransfer(TaskHandle_t task) { } void Gfx::WaitTransferFinished() const { - ulTaskNotifyTake(pdTRUE, 500); +// ulTaskNotifyTake(pdTRUE, 500); } void Gfx::SetScrollArea(uint16_t topFixedLines, uint16_t scrollLines, uint16_t bottomFixedLines) { diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 1ca35ae0ab..1601bb20f1 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -135,7 +135,7 @@ void DisplayApp::Process(void* instance) { app->InitHw(); // Send a dummy notification to unlock the lvgl display driver for the first iteration - xTaskNotifyGive(xTaskGetCurrentTaskHandle()); +// xTaskNotifyGive(xTaskGetCurrentTaskHandle()); while (true) { app->Refresh(); diff --git a/src/displayapp/DisplayAppRecovery.cpp b/src/displayapp/DisplayAppRecovery.cpp index a42d81a2e5..588e40173c 100644 --- a/src/displayapp/DisplayAppRecovery.cpp +++ b/src/displayapp/DisplayAppRecovery.cpp @@ -39,7 +39,7 @@ void DisplayApp::Process(void* instance) { NRF_LOG_INFO("displayapp task started!"); // Send a dummy notification to unlock the lvgl display driver for the first iteration - xTaskNotifyGive(xTaskGetCurrentTaskHandle()); +// xTaskNotifyGive(xTaskGetCurrentTaskHandle()); app->InitHw(); while (true) { @@ -94,7 +94,7 @@ void DisplayApp::DisplayLogo(uint16_t color) { Pinetime::Tools::RleDecoder rleDecoder(infinitime_nb, sizeof(infinitime_nb), color, colorBlack); for (int i = 0; i < displayWidth; i++) { rleDecoder.DecodeNext(displayBuffer, displayWidth * bytesPerPixel); - ulTaskNotifyTake(pdTRUE, 500); +// ulTaskNotifyTake(pdTRUE, 500); lcd.DrawBuffer(0, i, displayWidth, 1, reinterpret_cast(displayBuffer), displayWidth * bytesPerPixel); } } @@ -103,7 +103,7 @@ void DisplayApp::DisplayOtaProgress(uint8_t percent, uint16_t color) { const uint8_t barHeight = 20; std::fill(displayBuffer, displayBuffer + (displayWidth * bytesPerPixel), color); for (int i = 0; i < barHeight; i++) { - ulTaskNotifyTake(pdTRUE, 500); +// ulTaskNotifyTake(pdTRUE, 500); uint16_t barWidth = std::min(static_cast(percent) * 2.4f, static_cast(displayWidth)); lcd.DrawBuffer(0, displayWidth - barHeight + i, barWidth, 1, reinterpret_cast(displayBuffer), barWidth * bytesPerPixel); } diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index fbe22b26a3..4aab93a1d8 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -245,7 +245,7 @@ void LittleVgl::StartTransitionAnimation() { void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { uint16_t y1, y2, width, height = 0; - ulTaskNotifyTake(pdTRUE, 200); + // ulTaskNotifyTake(pdTRUE, 200); // NOtification is still needed (even if there is a mutex on SPI) because of the DataCommand pin // which cannot be set/clear during a transfert. @@ -260,7 +260,7 @@ void LittleVgl::FlushDisplay(const lv_area_t* area, lv_color_t* color_p) { if (height > 0) { lcd.DrawBuffer(area->x1, y1, width, height, reinterpret_cast(color_p), width * height * 2); - ulTaskNotifyTake(pdTRUE, 100); +// ulTaskNotifyTake(pdTRUE, 100); } uint16_t pixOffset = width * height; diff --git a/src/drivers/Spi.cpp b/src/drivers/Spi.cpp index a55d2888f3..87b5afde48 100644 --- a/src/drivers/Spi.cpp +++ b/src/drivers/Spi.cpp @@ -9,8 +9,8 @@ Spi::Spi(SpiMaster& spiMaster, uint8_t pinCsn) : spiMaster {spiMaster}, pinCsn { nrf_gpio_pin_set(pinCsn); } -bool Spi::Write(const uint8_t* data, size_t size) { - return spiMaster.Write(pinCsn, data, size); +bool Spi::Write(const uint8_t* data, size_t size, uint8_t pinLcdCmd, bool isData) { + return spiMaster.Write(pinCsn, data, size, pinLcdCmd, isData); } bool Spi::Read(uint8_t* cmd, size_t cmdSize, uint8_t* data, size_t dataSize) { diff --git a/src/drivers/Spi.h b/src/drivers/Spi.h index 6875710da1..ecc6a4447b 100644 --- a/src/drivers/Spi.h +++ b/src/drivers/Spi.h @@ -14,7 +14,7 @@ namespace Pinetime { Spi& operator=(Spi&&) = delete; bool Init(); - bool Write(const uint8_t* data, size_t size); + bool Write(const uint8_t* data, size_t size, uint8_t pinLcdCmd = -1, bool isLcdData = true); bool Read(uint8_t* cmd, size_t cmdSize, uint8_t* data, size_t dataSize); bool WriteCmdAndBuffer(const uint8_t* cmd, size_t cmdSize, const uint8_t* data, size_t dataSize); void Sleep(); diff --git a/src/drivers/SpiMaster.cpp b/src/drivers/SpiMaster.cpp index c45e1294af..e70a1c4a9e 100644 --- a/src/drivers/SpiMaster.cpp +++ b/src/drivers/SpiMaster.cpp @@ -176,7 +176,7 @@ void SpiMaster::PrepareRx(const volatile uint32_t cmdAddress, spiBaseAddress->EVENTS_END = 0; } -bool SpiMaster::Write(uint8_t pinCsn, const uint8_t* data, size_t size) { +bool SpiMaster::Write(uint8_t pinCsn, const uint8_t* data, size_t size, uint8_t pinLcdCmd=-1, bool isLcdData = true) { if (data == nullptr) return false; auto ok = xSemaphoreTake(mutex, portMAX_DELAY); @@ -190,6 +190,14 @@ bool SpiMaster::Write(uint8_t pinCsn, const uint8_t* data, size_t size) { } else { DisableWorkaroundForFtpan58(spiBaseAddress, 0, 0); } + + if (pinLcdCmd >= 0){ + if (isLcdData) { + nrf_gpio_pin_set(pinLcdCmd); + } else{ + nrf_gpio_pin_clear(pinLcdCmd); + } + } nrf_gpio_pin_clear(this->pinCsn); diff --git a/src/drivers/SpiMaster.h b/src/drivers/SpiMaster.h index 5ea624f255..ae4d8fecd5 100644 --- a/src/drivers/SpiMaster.h +++ b/src/drivers/SpiMaster.h @@ -30,7 +30,7 @@ namespace Pinetime { SpiMaster& operator=(SpiMaster&&) = delete; bool Init(); - bool Write(uint8_t pinCsn, const uint8_t* data, size_t size); + bool Write(uint8_t pinCsn, const uint8_t* data, size_t size, uint8_t pinLcdCmd, bool isLcdData); bool Read(uint8_t pinCsn, uint8_t* cmd, size_t cmdSize, uint8_t* data, size_t dataSize); bool WriteCmdAndBuffer(uint8_t pinCsn, const uint8_t* cmd, size_t cmdSize, const uint8_t* data, size_t dataSize); diff --git a/src/drivers/St7789.cpp b/src/drivers/St7789.cpp index 0f1dc02efd..1923d67688 100644 --- a/src/drivers/St7789.cpp +++ b/src/drivers/St7789.cpp @@ -19,6 +19,7 @@ void St7789::Init() { SleepOut(); ColMod(); MemoryDataAccessControl(); + VerticalScrollDefinition(0,320,0); ColumnAddressSet(); RowAddressSet(); DisplayInversionOn(); @@ -27,17 +28,15 @@ void St7789::Init() { } void St7789::WriteCommand(uint8_t cmd) { - nrf_gpio_pin_clear(pinDataCommand); - WriteSpi(&cmd, 1); + spi.Write(&cmd, 1, pinDataCommand, false); } -void St7789::WriteData(uint8_t data) { - nrf_gpio_pin_set(pinDataCommand); - WriteSpi(&data, 1); +void St7789::WriteDataByte(uint8_t data) { + spi.Write(&data, 1, pinDataCommand, true); } -void St7789::WriteSpi(const uint8_t* data, size_t size) { - spi.Write(data, size); +void St7789::WriteData(const uint8_t* data, size_t size) { + spi.Write(data, size, pinDataCommand, true); } void St7789::SoftwareReset() { @@ -55,29 +54,29 @@ void St7789::SleepIn() { void St7789::ColMod() { WriteCommand(static_cast(Commands::ColMod)); - WriteData(0x55); + WriteDataByte(0x55); nrf_delay_ms(10); } void St7789::MemoryDataAccessControl() { WriteCommand(static_cast(Commands::MemoryDataAccessControl)); - WriteData(0x00); + WriteDataByte(0x00); } void St7789::ColumnAddressSet() { WriteCommand(static_cast(Commands::ColumnAddressSet)); - WriteData(0x00); - WriteData(0x00); - WriteData(Width >> 8u); - WriteData(Width & 0xffu); + WriteDataByte(0x00); + WriteDataByte(0x00); + WriteDataByte(Width >> 8u); + WriteDataByte(Width & 0xffu); } void St7789::RowAddressSet() { WriteCommand(static_cast(Commands::RowAddressSet)); - WriteData(0x00); - WriteData(0x00); - WriteData(320u >> 8u); - WriteData(320u & 0xffu); + WriteDataByte(0x00); + WriteDataByte(0x00); + WriteDataByte(320u >> 8u); + WriteDataByte(320u & 0xffu); } void St7789::DisplayInversionOn() { @@ -96,16 +95,16 @@ void St7789::DisplayOn() { void St7789::SetAddrWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { WriteCommand(static_cast(Commands::ColumnAddressSet)); - WriteData(x0 >> 8); - WriteData(x0 & 0xff); - WriteData(x1 >> 8); - WriteData(x1 & 0xff); + WriteDataByte(x0 >> 8); + WriteDataByte(x0 & 0xff); + WriteDataByte(x1 >> 8); + WriteDataByte(x1 & 0xff); WriteCommand(static_cast(Commands::RowAddressSet)); - WriteData(y0 >> 8); - WriteData(y0 & 0xff); - WriteData(y1 >> 8); - WriteData(y1 & 0xff); + WriteDataByte(y0 >> 8); + WriteDataByte(y0 & 0xff); + WriteDataByte(y1 >> 8); + WriteDataByte(y1 & 0xff); WriteToRam(); } @@ -121,19 +120,19 @@ void St7789::DisplayOff() { void St7789::VerticalScrollDefinition(uint16_t topFixedLines, uint16_t scrollLines, uint16_t bottomFixedLines) { WriteCommand(static_cast(Commands::VerticalScrollDefinition)); - WriteData(topFixedLines >> 8u); - WriteData(topFixedLines & 0x00ffu); - WriteData(scrollLines >> 8u); - WriteData(scrollLines & 0x00ffu); - WriteData(bottomFixedLines >> 8u); - WriteData(bottomFixedLines & 0x00ffu); + WriteDataByte(topFixedLines >> 8u); + WriteDataByte(topFixedLines & 0x00ffu); + WriteDataByte(scrollLines >> 8u); + WriteDataByte(scrollLines & 0x00ffu); + WriteDataByte(bottomFixedLines >> 8u); + WriteDataByte(bottomFixedLines & 0x00ffu); } void St7789::VerticalScrollStartAddress(uint16_t line) { verticalScrollingStartAddress = line; WriteCommand(static_cast(Commands::VerticalScrollStartAddress)); - WriteData(line >> 8u); - WriteData(line & 0x00ffu); + WriteDataByte(line >> 8u); + WriteDataByte(line & 0x00ffu); } void St7789::Uninit() { @@ -146,14 +145,12 @@ void St7789::DrawPixel(uint16_t x, uint16_t y, uint32_t color) { SetAddrWindow(x, y, x + 1, y + 1); - nrf_gpio_pin_set(pinDataCommand); - WriteSpi(reinterpret_cast(&color), 2); + WriteData(reinterpret_cast(&color), 2); } void St7789::DrawBuffer(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t* data, size_t size) { SetAddrWindow(x, y, x + width - 1, y + height - 1); - nrf_gpio_pin_set(pinDataCommand); - WriteSpi(data, size); + WriteData(data, size); } void St7789::HardwareReset() { diff --git a/src/drivers/St7789.h b/src/drivers/St7789.h index 4fbccbeb8b..8c1c8f98d4 100644 --- a/src/drivers/St7789.h +++ b/src/drivers/St7789.h @@ -62,7 +62,8 @@ namespace Pinetime { VerticalScrollStartAddress = 0x37, ColMod = 0x3a, }; - void WriteData(uint8_t data); + void WriteData(const uint8_t* data, size_t s); + void WriteDataByte(uint8_t data); void ColumnAddressSet(); static constexpr uint16_t Width = 240; diff --git a/src/recoveryLoader.cpp b/src/recoveryLoader.cpp index acec14c8ad..eead491161 100644 --- a/src/recoveryLoader.cpp +++ b/src/recoveryLoader.cpp @@ -124,7 +124,7 @@ void DisplayLogo() { Pinetime::Tools::RleDecoder rleDecoder(infinitime_nb, sizeof(infinitime_nb)); for (int i = 0; i < displayWidth; i++) { rleDecoder.DecodeNext(displayBuffer, displayWidth * bytesPerPixel); - ulTaskNotifyTake(pdTRUE, 500); +// ulTaskNotifyTake(pdTRUE, 500); lcd.DrawBuffer(0, i, displayWidth, 1, reinterpret_cast(displayBuffer), displayWidth * bytesPerPixel); } } @@ -133,7 +133,7 @@ void DisplayProgressBar(uint8_t percent, uint16_t color) { static constexpr uint8_t barHeight = 20; std::fill(displayBuffer, displayBuffer + (displayWidth * bytesPerPixel), color); for (int i = 0; i < barHeight; i++) { - ulTaskNotifyTake(pdTRUE, 500); +// ulTaskNotifyTake(pdTRUE, 500); uint16_t barWidth = std::min(static_cast(percent) * 2.4f, static_cast(displayWidth)); lcd.DrawBuffer(0, displayWidth - barHeight + i, barWidth, 1, reinterpret_cast(displayBuffer), barWidth * bytesPerPixel); } From 24c72b7bbc3603261037c93b9513b638d565ec07 Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Fri, 15 Oct 2021 14:07:43 -0400 Subject: [PATCH 25/25] Improve lvgl8 performance for system info screen. Fix theming for basic labels. Add short url for github address. --- src/displayapp/LittleVgl.cpp | 5 + src/displayapp/lv_pinetime_theme.c | 6 ++ src/displayapp/screens/Label.cpp | 49 ++++++++- src/displayapp/screens/Label.h | 7 +- src/displayapp/screens/SystemInfo.cpp | 146 ++++++++++---------------- src/libs/lv_conf.h | 2 +- 6 files changed, 120 insertions(+), 95 deletions(-) diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index 4aab93a1d8..b03a1fc62c 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -6,6 +6,11 @@ //#include #include "drivers/Cst816s.h" #include "drivers/St7789.h" +#include + +extern void lv_refr_areas(); +extern void lv_refr_area(const lv_area_t * area_p); +extern void lv_refr_area_part(const lv_area_t * area_p); using namespace Pinetime::Components; diff --git a/src/displayapp/lv_pinetime_theme.c b/src/displayapp/lv_pinetime_theme.c index f5dfc5c16e..92e6d74c16 100644 --- a/src/displayapp/lv_pinetime_theme.c +++ b/src/displayapp/lv_pinetime_theme.c @@ -414,6 +414,12 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj) lv_obj_add_style(obj, &style_bar_indic, LV_PART_INDICATOR); } #endif + + #if LV_USE_LABEL + else if(lv_obj_check_type(obj, &lv_label_class)) { + lv_obj_add_style(obj, &style_label_white, LV_PART_MAIN | LV_STATE_DEFAULT); + } + #endif #if LV_USE_SLIDER else if (lv_obj_check_type(obj, &lv_slider_class)) { diff --git a/src/displayapp/screens/Label.cpp b/src/displayapp/screens/Label.cpp index 5cb9ac6665..eb4e023084 100644 --- a/src/displayapp/screens/Label.cpp +++ b/src/displayapp/screens/Label.cpp @@ -2,9 +2,22 @@ using namespace Pinetime::Applications::Screens; -Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::DisplayApp* app, lv_obj_t* labelText) - : Screen(app), labelText {labelText} { +Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::DisplayApp* app) + : Label(screenID, numScreens, app, nullptr){}; +Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::DisplayApp* app, lv_obj_t* container) + : Screen(app), labelText {container} { + + if (labelText == nullptr){ + labelText = lv_obj_create(lv_scr_act()); + lv_obj_set_layout(labelText, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(labelText, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(labelText, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER); + lv_obj_set_style_bg_opa(labelText, LV_OPA_TRANSP, 0); + lv_obj_set_size(labelText, LV_HOR_RES, LV_SIZE_CONTENT); + lv_obj_center(labelText); + } + if (numScreens > 1) { pageIndicatorBasePoints[0].x = LV_HOR_RES - 1; pageIndicatorBasePoints[0].y = 0; @@ -36,3 +49,35 @@ Label::Label(uint8_t screenID, uint8_t numScreens, Pinetime::Applications::Displ Label::~Label() { lv_obj_clean(lv_scr_act()); } + +lv_obj_t* Label::addLine(){ + lv_obj_t* label = lv_label_create(labelText); + lv_label_set_text(label, ""); + return label; +} + +LV_FORMAT_ATTRIBUTE(2, 3) lv_obj_t* Label::addLine(const char* fmt, ...){ + lv_obj_t* label = lv_label_create(labelText); + lv_label_set_recolor(label, true); + + va_list args; + va_start(args, fmt); + (reinterpret_cast(label))->text = _lv_txt_set_text_vfmt(fmt, args); + va_end(args); + return label; +} + +LV_FORMAT_ATTRIBUTE(2, 3) lv_obj_t* Label::addLineCenter(const char* fmt, ...){ + lv_obj_t* label = lv_label_create(labelText); + lv_label_set_recolor(label, true); + + va_list args; + va_start(args, fmt); + (reinterpret_cast(label))->text = _lv_txt_set_text_vfmt(fmt, args); + va_end(args); + + lv_obj_set_width(label, LV_PCT(100)); + lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0); + + return label; +} diff --git a/src/displayapp/screens/Label.h b/src/displayapp/screens/Label.h index f1e49079cb..a30f4d5ecf 100644 --- a/src/displayapp/screens/Label.h +++ b/src/displayapp/screens/Label.h @@ -9,8 +9,13 @@ namespace Pinetime { class Label : public Screen { public: - Label(uint8_t screenID, uint8_t numScreens, DisplayApp* app, lv_obj_t* labelText); + Label(uint8_t screenID, uint8_t numScreens, DisplayApp* app, lv_obj_t* container); + Label(uint8_t screenID, uint8_t numScreens, DisplayApp* app); ~Label() override; + + lv_obj_t* addLine(); + lv_obj_t* addLine(const char* fmt, ...); + lv_obj_t* addLineCenter(const char* fmt, ...); private: lv_obj_t* labelText = nullptr; diff --git a/src/displayapp/screens/SystemInfo.cpp b/src/displayapp/screens/SystemInfo.cpp index 31dfd19a04..09bb7e777d 100644 --- a/src/displayapp/screens/SystemInfo.cpp +++ b/src/displayapp/screens/SystemInfo.cpp @@ -72,29 +72,24 @@ bool SystemInfo::OnTouchEvent(Pinetime::Applications::TouchEvents event) { } std::unique_ptr SystemInfo::CreateScreen1() { - lv_obj_t* label = lv_label_create(lv_scr_act()); - lv_label_set_recolor(label, true); - lv_label_set_text_fmt(label, - "#FFFF00 InfiniTime#\n\n" - "#444444 Version# %ld.%ld.%ld\n" - "#444444 Short Ref# %s\n" - "#444444 Build date#\n" - "%s\n" - "%s\n\n" - "#444444 Bootloader# %s", - Version::Major(), - Version::Minor(), - Version::Patch(), - Version::GitCommitHash(), - __DATE__, - __TIME__, - BootloaderVersion::VersionString()); - lv_obj_center(label); - return std::make_unique(0, 5, app, label); + + auto newScreen = std::make_unique(0, 5, app); + + newScreen->addLineCenter("#FFFF00 InfiniTime#"); + newScreen->addLine(); + newScreen->addLineCenter("#444444 Version# %ld.%ld.%ld", Version::Major(), Version::Minor(), Version::Patch()); + newScreen->addLineCenter("#444444 Short Ref# %s", Version::GitCommitHash()); + newScreen->addLineCenter("#444444 Build date#"); + newScreen->addLineCenter("%s", __TIME__); + newScreen->addLineCenter("%s", __DATE__); + newScreen->addLine(); + newScreen->addLineCenter("#444444 Bootloader# %s", BootloaderVersion::VersionString()); + + return std::move(newScreen); } std::unique_ptr SystemInfo::CreateScreen2() { - auto batteryPercent = batteryController.PercentRemaining(); + uint8_t batteryPercent = batteryController.PercentRemaining(); auto resetReason = [this]() { switch (watchdog.ResetReason()) { case Drivers::Watchdog::ResetReasons::Watchdog: @@ -133,71 +128,41 @@ std::unique_ptr SystemInfo::CreateScreen2() { uptimeSeconds = uptimeSeconds % secondsInAMinute; // TODO handle more than 100 days of uptime - lv_obj_t* label = lv_label_create(lv_scr_act()); - lv_label_set_recolor(label, true); - lv_label_set_text_fmt(label, - "#444444 Date# %02d/%02d/%04d\n" - "#444444 Time# %02d:%02d:%02d\n" - "#444444 Uptime#\n %02lud %02lu:%02lu:%02lu\n" - "#444444 Battery# %d%%/%03imV\n" - "#444444 Backlight# %s\n" - "#444444 Last reset# %s\n" - "#444444 Accel.# %s\n" - "#444444 Touch.# %x.%x.%x\n", - dateTimeController.Day(), - static_cast(dateTimeController.Month()), - dateTimeController.Year(), - dateTimeController.Hours(), - dateTimeController.Minutes(), - dateTimeController.Seconds(), - uptimeDays, - uptimeHours, - uptimeMinutes, - uptimeSeconds, - batteryPercent, - batteryController.Voltage(), - brightnessController.ToString(), - resetReason, - ToString(motionController.DeviceType()), - touchPanel.GetChipId(), - touchPanel.GetVendorId(), - touchPanel.GetFwVersion()); - lv_obj_align(label, LV_ALIGN_CENTER, 0, 0); - return std::make_unique(1, 5, app, label); + auto newScreen = std::make_unique(1, 5, app); + newScreen->addLine("#444444 Date# %02hhu/%02hhu/%04hu", + dateTimeController.Day(), + static_cast(dateTimeController.Month()), + dateTimeController.Year()); + newScreen->addLine( + "#444444 Time# %02hhu:%02hhu:%02hhu", dateTimeController.Hours(), dateTimeController.Minutes(), dateTimeController.Seconds()); + newScreen->addLine("#444444 Uptime#"); + newScreen->addLine(" %02lud %02lu:%02lu:%02lu", uptimeDays, uptimeHours, uptimeMinutes, uptimeSeconds); + newScreen->addLine("#444444 Battery# %hhu%%/%03humV", batteryPercent, batteryController.Voltage()); + newScreen->addLine("#444444 Backlight# %s", brightnessController.ToString()); + newScreen->addLine("#444444 Last reset# %s", resetReason); + newScreen->addLine("#444444 Accel.# %s", ToString(motionController.DeviceType())); + newScreen->addLine("#444444 Touch.# %hhx.%hhx.%hhx", touchPanel.GetChipId(), touchPanel.GetVendorId(), touchPanel.GetFwVersion()); + + return std::move(newScreen); } std::unique_ptr SystemInfo::CreateScreen3() { lv_mem_monitor_t mon; lv_mem_monitor(&mon); - lv_obj_t* label = lv_label_create(lv_scr_act()); - lv_label_set_recolor(label, true); + auto newScreen = std::make_unique(2, 5, app); auto& bleAddr = bleController.Address(); - lv_label_set_text_fmt(label, - "#444444 BLE MAC#\n" - " %02x:%02x:%02x:%02x:%02x:%02x" - "\n" - "#444444 LVGL Memory#\n" - " #444444 used# %d (%d%%)\n" - " #444444 max used# %lu\n" - " #444444 frag# %d%%\n" - " #444444 free# %d" - "\n" - "#444444 Steps# %i", - bleAddr[5], - bleAddr[4], - bleAddr[3], - bleAddr[2], - bleAddr[1], - bleAddr[0], - static_cast(mon.total_size - mon.free_size), - mon.used_pct, - mon.max_used, - mon.frag_pct, - static_cast(mon.free_biggest_size), - 0); - lv_obj_center(label); - return std::make_unique(2, 5, app, label); + + newScreen->addLine("#444444 BLE MAC#"); + newScreen->addLine(" %02x:%02x:%02x:%02x:%02x:%02x", bleAddr[5], bleAddr[4], bleAddr[3], bleAddr[2], bleAddr[1], bleAddr[0]); + newScreen->addLine("#444444 LVGL Memory#"); + newScreen->addLine(" #444444 used# %d (%d%%)", static_cast(mon.total_size - mon.free_size), mon.used_pct); + newScreen->addLine(" #444444 max used# %lu", mon.max_used); + newScreen->addLine(" #444444 frag# %d%%", mon.frag_pct); + newScreen->addLine(" #444444 free# %d", static_cast(mon.free_biggest_size)); + newScreen->addLine("#444444 Steps# %i", 0); + + return std::move(newScreen); } bool SystemInfo::sortById(const TaskStatus_t& lhs, const TaskStatus_t& rhs) { @@ -257,17 +222,16 @@ std::unique_ptr SystemInfo::CreateScreen4() { } std::unique_ptr SystemInfo::CreateScreen5() { - lv_obj_t* label = lv_label_create(lv_scr_act()); - lv_label_set_recolor(label, true); - lv_label_set_text_static(label, - "Software Licensed\n" - "under the terms of\n" - "the GNU General\n" - "Public License v3\n" - "#444444 Source code#\n" - "#FFFF00 https://github.com/#\n" - "#FFFF00 JF002/InfiniTime#"); - lv_obj_set_style_text_align(label, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT); - lv_obj_center(label); - return std::make_unique(4, 5, app, label); + + auto newScreen = std::make_unique(4, 5, app); + + newScreen->addLineCenter("Software Licensed"); + newScreen->addLineCenter("under the terms of"); + newScreen->addLineCenter("the GNU General"); + newScreen->addLineCenter("Public License v3"); + newScreen->addLine(); + newScreen->addLineCenter("#444444 Source code#"); + newScreen->addLineCenter("#FFFF00 git.io/inftime"); + + return std::move(newScreen); } diff --git a/src/libs/lv_conf.h b/src/libs/lv_conf.h index 0bc2fa61b5..0066f0152f 100644 --- a/src/libs/lv_conf.h +++ b/src/libs/lv_conf.h @@ -402,7 +402,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ #define LV_USE_LABEL 1 #if LV_USE_LABEL # define LV_LABEL_TEXT_SELECTION 0 /*Enable selecting text of the label*/ -# define LV_LABEL_LONG_TXT_HINT 0 /*Store some extra info in labels to speed up drawing of very long texts*/ +# define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ #endif #define LV_USE_LINE 1