diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-06-12 18:46:07 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-06-12 18:46:07 +1000 |
| commit | e58dcf6dc5332c60a346509436f9934d9e3bbfbb (patch) | |
| tree | f1b5cf9c7d99739008ff52dbd837c574b2b0ea36 /src/tangara | |
| parent | 64bd9053a25297f7a442ca831c7da5b44bd33f84 (diff) | |
| download | tangara-fw-e58dcf6dc5332c60a346509436f9934d9e3bbfbb.tar.gz | |
WIP fix issues introduced by lvgl version bump
Diffstat (limited to 'src/tangara')
28 files changed, 105 insertions, 223 deletions
diff --git a/src/tangara/input/feedback_haptics.cpp b/src/tangara/input/feedback_haptics.cpp index c834ca54..a447a69d 100644 --- a/src/tangara/input/feedback_haptics.cpp +++ b/src/tangara/input/feedback_haptics.cpp @@ -9,10 +9,8 @@ #include <cstdint> #include "core/lv_group.h" -#include "lvgl/lvgl.h" - -#include "core/lv_event.h" #include "esp_log.h" +#include "lvgl/lvgl.h" #include "drivers/haptics.hpp" diff --git a/src/tangara/input/feedback_tts.cpp b/src/tangara/input/feedback_tts.cpp index a9267aa8..e7e167c6 100644 --- a/src/tangara/input/feedback_tts.cpp +++ b/src/tangara/input/feedback_tts.cpp @@ -11,14 +11,14 @@ #include "lvgl/lvgl.h" -#include "core/lv_event.h" #include "core/lv_group.h" #include "core/lv_obj.h" #include "core/lv_obj_class.h" #include "core/lv_obj_tree.h" -#include "extra/widgets/list/lv_list.h" #include "tts/events.hpp" -#include "widgets/lv_label.h" +#include "widgets/button/lv_button.h" +#include "widgets/label/lv_label.h" +#include "widgets/list/lv_list.h" #include "tts/events.hpp" #include "tts/provider.hpp" @@ -51,8 +51,8 @@ auto TextToSpeech::feedback(lv_group_t* group, uint8_t event_type) -> void { } auto TextToSpeech::describe(lv_obj_t& obj) -> void { - if (lv_obj_check_type(&obj, &lv_btn_class) || - lv_obj_check_type(&obj, &lv_list_btn_class)) { + if (lv_obj_check_type(&obj, &lv_button_class) || + lv_obj_check_type(&obj, &lv_list_button_class)) { auto desc = findDescription(obj); tts_.feed(tts::SelectionChanged{ .new_selection = diff --git a/src/tangara/input/input_device.hpp b/src/tangara/input/input_device.hpp index e3d17c6c..da2b31cd 100644 --- a/src/tangara/input/input_device.hpp +++ b/src/tangara/input/input_device.hpp @@ -10,7 +10,7 @@ #include <string> #include <vector> -#include "hal/lv_hal_indev.h" +#include "indev/lv_indev.h" #include "input/input_hook.hpp" #include "lua/property.hpp" diff --git a/src/tangara/input/input_hook.cpp b/src/tangara/input/input_hook.cpp index 95ff8f2c..0867bb39 100644 --- a/src/tangara/input/input_hook.cpp +++ b/src/tangara/input/input_hook.cpp @@ -9,7 +9,7 @@ #include <functional> #include <optional> -#include "hal/lv_hal_indev.h" +#include "indev/lv_indev.h" #include "lua.hpp" #include "input/input_trigger.hpp" diff --git a/src/tangara/input/input_hook.hpp b/src/tangara/input/input_hook.hpp index 06fcb037..94a35850 100644 --- a/src/tangara/input/input_hook.hpp +++ b/src/tangara/input/input_hook.hpp @@ -10,7 +10,7 @@ #include <optional> #include <string> -#include "hal/lv_hal_indev.h" +#include "indev/lv_indev.h" #include "lua.hpp" #include "input/input_trigger.hpp" diff --git a/src/tangara/input/input_hook_actions.cpp b/src/tangara/input/input_hook_actions.cpp index bc3760ac..fea08754 100644 --- a/src/tangara/input/input_hook_actions.cpp +++ b/src/tangara/input/input_hook_actions.cpp @@ -8,7 +8,7 @@ #include <cstdint> -#include "hal/lv_hal_indev.h" +#include "indev/lv_indev.h" #include "events/event_queue.hpp" #include "ui/ui_events.hpp" diff --git a/src/tangara/input/input_hook_actions.hpp b/src/tangara/input/input_hook_actions.hpp index 71a560bc..bca82af6 100644 --- a/src/tangara/input/input_hook_actions.hpp +++ b/src/tangara/input/input_hook_actions.hpp @@ -6,7 +6,6 @@ #pragma once -#include "hal/lv_hal_indev.h" #include "input/input_hook.hpp" namespace input { diff --git a/src/tangara/input/input_nav_buttons.cpp b/src/tangara/input/input_nav_buttons.cpp index ba1f4b74..0c904a84 100644 --- a/src/tangara/input/input_nav_buttons.cpp +++ b/src/tangara/input/input_nav_buttons.cpp @@ -6,9 +6,10 @@ #include "input/input_nav_buttons.hpp" +#include "indev/lv_indev.h" + #include "drivers/gpios.hpp" #include "events/event_queue.hpp" -#include "hal/lv_hal_indev.h" #include "input/input_hook_actions.hpp" namespace input { diff --git a/src/tangara/input/input_nav_buttons.hpp b/src/tangara/input/input_nav_buttons.hpp index ce2312a0..64b547e6 100644 --- a/src/tangara/input/input_nav_buttons.hpp +++ b/src/tangara/input/input_nav_buttons.hpp @@ -8,14 +8,14 @@ #include <cstdint> -#include "drivers/gpios.hpp" -#include "hal/lv_hal_indev.h" +#include "indev/lv_indev.h" +#include "drivers/gpios.hpp" #include "drivers/haptics.hpp" +#include "drivers/touchwheel.hpp" #include "input/input_device.hpp" #include "input/input_hook.hpp" #include "input/input_trigger.hpp" -#include "drivers/touchwheel.hpp" namespace input { diff --git a/src/tangara/input/input_touch_dpad.cpp b/src/tangara/input/input_touch_dpad.cpp index 5d8e2dab..7dc9f04f 100644 --- a/src/tangara/input/input_touch_dpad.cpp +++ b/src/tangara/input/input_touch_dpad.cpp @@ -8,11 +8,10 @@ #include <cstdint> -#include "hal/lv_hal_indev.h" +#include "indev/lv_indev.h" #include "drivers/haptics.hpp" #include "drivers/touchwheel.hpp" - #include "events/event_queue.hpp" #include "input/input_device.hpp" #include "input/input_hook_actions.hpp" diff --git a/src/tangara/input/input_touch_dpad.hpp b/src/tangara/input/input_touch_dpad.hpp index 8fb14832..4e50819a 100644 --- a/src/tangara/input/input_touch_dpad.hpp +++ b/src/tangara/input/input_touch_dpad.hpp @@ -8,7 +8,7 @@ #include <cstdint> -#include "hal/lv_hal_indev.h" +#include "indev/lv_indev.h" #include "drivers/haptics.hpp" #include "input/input_device.hpp" diff --git a/src/tangara/input/input_touch_wheel.cpp b/src/tangara/input/input_touch_wheel.cpp index 75159320..0f61929d 100644 --- a/src/tangara/input/input_touch_wheel.cpp +++ b/src/tangara/input/input_touch_wheel.cpp @@ -9,7 +9,7 @@ #include <cstdint> #include <variant> -#include "hal/lv_hal_indev.h" +#include "indev/lv_indev.h" #include "drivers/haptics.hpp" #include "drivers/nvs.hpp" diff --git a/src/tangara/input/input_touch_wheel.hpp b/src/tangara/input/input_touch_wheel.hpp index d023873a..cf86eced 100644 --- a/src/tangara/input/input_touch_wheel.hpp +++ b/src/tangara/input/input_touch_wheel.hpp @@ -9,7 +9,7 @@ #include <sys/_stdint.h> #include <cstdint> -#include "hal/lv_hal_indev.h" +#include "indev/lv_indev.h" #include "drivers/haptics.hpp" #include "input/input_device.hpp" diff --git a/src/tangara/input/input_trigger.hpp b/src/tangara/input/input_trigger.hpp index 1b0e681d..9f0b7e19 100644 --- a/src/tangara/input/input_trigger.hpp +++ b/src/tangara/input/input_trigger.hpp @@ -9,13 +9,11 @@ #include <cstdint> #include <optional> -#include "hal/lv_hal_indev.h" - namespace input { const uint16_t kDoubleClickDelayMs = 500; -const uint16_t kLongPressDelayMs = LV_INDEV_DEF_LONG_PRESS_TIME; -const uint16_t kRepeatDelayMs = LV_INDEV_DEF_LONG_PRESS_REP_TIME; +const uint16_t kLongPressDelayMs = 400; +const uint16_t kRepeatDelayMs = 100; class Trigger { public: diff --git a/src/tangara/input/input_volume_buttons.hpp b/src/tangara/input/input_volume_buttons.hpp index 22a8acf2..4af14344 100644 --- a/src/tangara/input/input_volume_buttons.hpp +++ b/src/tangara/input/input_volume_buttons.hpp @@ -8,13 +8,13 @@ #include <cstdint> -#include "drivers/gpios.hpp" -#include "hal/lv_hal_indev.h" +#include "indev/lv_indev.h" +#include "drivers/gpios.hpp" #include "drivers/haptics.hpp" +#include "drivers/touchwheel.hpp" #include "input/input_device.hpp" #include "input/input_hook.hpp" -#include "drivers/touchwheel.hpp" namespace input { diff --git a/src/tangara/input/lvgl_input_driver.cpp b/src/tangara/input/lvgl_input_driver.cpp index 9c1ccff9..86f9b279 100644 --- a/src/tangara/input/lvgl_input_driver.cpp +++ b/src/tangara/input/lvgl_input_driver.cpp @@ -10,8 +10,8 @@ #include <memory> #include <variant> -#include "core/lv_event.h" -#include "core/lv_indev.h" +#include "core/lv_group.h" +#include "indev/lv_indev.h" #include "lua.hpp" #include "lvgl.h" @@ -25,6 +25,7 @@ #include "input/input_volume_buttons.hpp" #include "lua/lua_thread.hpp" #include "lua/property.hpp" +#include "misc/lv_event.h" [[maybe_unused]] static constexpr char kTag[] = "input"; @@ -33,16 +34,22 @@ static constexpr char kLuaOverrideText[] = "lua_callback"; namespace input { -static void read_cb(lv_indev_drv_t* drv, lv_indev_data_t* data) { +static void read_cb(lv_indev_t* dev, lv_indev_data_t* data) { LvglInputDriver* instance = - reinterpret_cast<LvglInputDriver*>(drv->user_data); + reinterpret_cast<LvglInputDriver*>(lv_indev_get_user_data(dev)); instance->read(data); } -static void feedback_cb(lv_indev_drv_t* drv, uint8_t event) { +static void feedback_cb(lv_event_t* ev) { LvglInputDriver* instance = - reinterpret_cast<LvglInputDriver*>(drv->user_data); - instance->feedback(event); + reinterpret_cast<LvglInputDriver*>(lv_event_get_user_data(ev)); + instance->feedback(lv_event_get_code(ev)); +} + +static void focus_cb(lv_group_t* group) { + LvglInputDriver* instance = + reinterpret_cast<LvglInputDriver*>(group->user_data); + instance->feedback(LV_EVENT_FOCUSED); } auto intToMode(int raw) -> std::optional<drivers::NvsStorage::InputModes> { @@ -77,29 +84,31 @@ LvglInputDriver::LvglInputDriver(drivers::NvsStorage& nvs, inputs_ = factory.createInputs(*mode); return true; }), - driver_(), - registration_(nullptr), inputs_(factory.createInputs(nvs.PrimaryInput())), feedbacks_(factory.createFeedbacks()), is_locked_(false) { - lv_indev_drv_init(&driver_); - driver_.type = LV_INDEV_TYPE_ENCODER; - driver_.read_cb = read_cb; - driver_.feedback_cb = feedback_cb; - driver_.user_data = this; - driver_.long_press_time = kLongPressDelayMs; - driver_.long_press_repeat_time = kRepeatDelayMs; - - registration_ = lv_indev_drv_register(&driver_); + device_ = lv_indev_create(); + lv_indev_set_type(device_, LV_INDEV_TYPE_ENCODER); + lv_indev_set_user_data(device_, this); + lv_indev_set_read_cb(device_, read_cb); + lv_indev_add_event_cb(device_, feedback_cb, LV_EVENT_ALL, this); } auto LvglInputDriver::setGroup(lv_group_t* g) -> void { + lv_group_t* prev = lv_indev_get_group(device_); + if (prev && prev != g) { + lv_group_set_focus_cb(prev, NULL); + } if (!g) { return; } - lv_indev_set_group(registration_, g); - // Emit a synthetic 'focus' event for the current selection, since otherwise - // our feedback devices won't know that the selection changed. + lv_indev_set_group(device_, g); + + g->user_data = this; + lv_group_set_focus_cb(g, focus_cb); + + // Emit a synthetic 'focus' event for the current selection, since + // otherwise our feedback devices won't know that the selection changed. feedback(LV_EVENT_FOCUSED); } @@ -119,7 +128,7 @@ auto LvglInputDriver::feedback(uint8_t event) -> void { return; } for (auto&& device : feedbacks_) { - device->feedback(registration_->group, event); + device->feedback(lv_indev_get_group(device_), event); } } diff --git a/src/tangara/input/lvgl_input_driver.hpp b/src/tangara/input/lvgl_input_driver.hpp index 0b6a7e76..ddbdee55 100644 --- a/src/tangara/input/lvgl_input_driver.hpp +++ b/src/tangara/input/lvgl_input_driver.hpp @@ -12,13 +12,13 @@ #include <set> #include "core/lv_group.h" -#include "drivers/gpios.hpp" -#include "hal/lv_hal_indev.h" -#include "input/device_factory.hpp" -#include "input/feedback_device.hpp" +#include "indev/lv_indev.h" +#include "drivers/gpios.hpp" #include "drivers/nvs.hpp" #include "drivers/touchwheel.hpp" +#include "input/device_factory.hpp" +#include "input/feedback_device.hpp" #include "input/input_device.hpp" #include "input/input_hook.hpp" #include "lua/lua_thread.hpp" @@ -50,8 +50,7 @@ class LvglInputDriver { DeviceFactory& factory_; lua::Property mode_; - lv_indev_drv_t driver_; - lv_indev_t* registration_; + lv_indev_t* device_; std::vector<std::shared_ptr<IInputDevice>> inputs_; std::vector<std::shared_ptr<IFeedbackDevice>> feedbacks_; diff --git a/src/tangara/lua/bridge.cpp b/src/tangara/lua/bridge.cpp index 51ad0b62..93b13abf 100644 --- a/src/tangara/lua/bridge.cpp +++ b/src/tangara/lua/bridge.cpp @@ -26,7 +26,6 @@ #include "lua/lua_version.hpp" #include "lvgl.h" -#include "font/lv_font_loader.h" #include "luavgl.h" #include "events/event_queue.hpp" @@ -61,7 +60,7 @@ static auto make_font_cb(const char* name, int size, int weight) return NULL; } -static auto delete_font_cb(lv_font_t* font) -> void {} +static auto delete_font_cb(const lv_font_t* font) -> void {} auto Bridge::Get(lua_State* state) -> Bridge* { lua_pushstring(state, kBridgeKey); diff --git a/src/tangara/ui/lvgl_task.cpp b/src/tangara/ui/lvgl_task.cpp index 4d12b24b..76274ba9 100644 --- a/src/tangara/ui/lvgl_task.cpp +++ b/src/tangara/ui/lvgl_task.cpp @@ -6,45 +6,27 @@ #include "ui/lvgl_task.hpp" -#include <dirent.h> -#include <stdint.h> -#include <stdio.h> - -#include <cstddef> -#include <cstdint> -#include <memory> - -#include "core/lv_disp.h" #include "core/lv_group.h" -#include "core/lv_indev.h" #include "core/lv_obj.h" #include "core/lv_obj_pos.h" #include "core/lv_obj_tree.h" -#include "drivers/touchwheel.hpp" +#include "core/lv_refr.h" +#include "display/lv_display.h" #include "esp_log.h" -#include "events/event_queue.hpp" -#include "extra/themes/basic/lv_theme_basic.h" -#include "font/lv_font.h" #include "freertos/portmacro.h" #include "freertos/projdefs.h" #include "freertos/timers.h" -#include "hal/gpio_types.h" -#include "hal/lv_hal_indev.h" -#include "hal/spi_types.h" -#include "input/lvgl_input_driver.hpp" #include "lua.h" -#include "lv_api_map.h" #include "lvgl/lvgl.h" #include "misc/lv_color.h" #include "misc/lv_style.h" #include "misc/lv_timer.h" -#include "tasks.hpp" -#include "ui/modal.hpp" -#include "ui/ui_fsm.hpp" -#include "widgets/lv_label.h" #include "drivers/display.hpp" -#include "drivers/gpios.hpp" +#include "events/event_queue.hpp" +#include "input/lvgl_input_driver.hpp" +#include "tasks.hpp" +#include "ui/ui_fsm.hpp" namespace ui { @@ -66,7 +48,7 @@ auto UiTask::Main() -> void { std::shared_ptr<Screen> screen = UiState::current_screen(); if (screen != current_screen_ && screen != nullptr) { - lv_scr_load(screen->root()); + lv_screen_load(screen->root()); if (input_) { input_->setGroup(screen->group()); } diff --git a/src/tangara/ui/modal.cpp b/src/tangara/ui/modal.cpp deleted file mode 100644 index 4f5a2432..00000000 --- a/src/tangara/ui/modal.cpp +++ /dev/null @@ -1,57 +0,0 @@ - -/* - * Copyright 2023 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#include "ui/modal.hpp" - -#include "misc/lv_color.h" - -#include "core/lv_event.h" -#include "esp_log.h" - -#include "core/lv_group.h" -#include "core/lv_obj_pos.h" -#include "database/index.hpp" -#include "events/event_queue.hpp" -#include "extra/widgets/list/lv_list.h" -#include "extra/widgets/menu/lv_menu.h" -#include "extra/widgets/spinner/lv_spinner.h" -#include "hal/lv_hal_disp.h" -#include "misc/lv_area.h" -#include "ui/screen.hpp" -#include "ui/themes.hpp" -#include "ui/ui_events.hpp" -#include "ui/ui_fsm.hpp" -#include "widgets/lv_label.h" - -namespace ui { - -Modal::Modal(Screen* host) - : root_(lv_obj_create(host->modal_content())), - group_(lv_group_create()), - host_(host) { - lv_obj_set_style_bg_opa(host->modal_content(), LV_OPA_40, 0); - - lv_obj_set_size(root_, 120, LV_SIZE_CONTENT); - lv_obj_center(root_); - - lv_obj_set_style_bg_opa(root_, LV_OPA_COVER, 0); - lv_obj_set_style_bg_color(root_, lv_color_white(), 0); - - host_->modal_group(group_); -} - -Modal::~Modal() { - host_->modal_group(nullptr); - lv_obj_set_style_bg_opa(host_->modal_content(), LV_OPA_TRANSP, 0); - - // The group *must* be deleted first. Otherwise, focus events will be - // generated whilst deleting the object tree, which causes a big mess. - lv_group_del(group_); - lv_obj_del(root_); -} - -} // namespace ui diff --git a/src/tangara/ui/modal.hpp b/src/tangara/ui/modal.hpp deleted file mode 100644 index bd5209a7..00000000 --- a/src/tangara/ui/modal.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2023 jacqueline <me@jacqueline.id.au> - * - * SPDX-License-Identifier: GPL-3.0-only - */ - -#pragma once - -#include <memory> - -#include "core/lv_group.h" -#include "core/lv_obj.h" -#include "core/lv_obj_tree.h" -#include "lvgl.h" - -#include "ui/screen.hpp" - -namespace ui { - -class Modal { - public: - Modal(Screen* host); - virtual ~Modal(); - - auto root() -> lv_obj_t* { return root_; } - auto group() -> lv_group_t* { return group_; } - - protected: - lv_obj_t* const root_; - lv_group_t* const group_; - - private: - Screen* host_; -}; - -} // namespace ui diff --git a/src/tangara/ui/screen.cpp b/src/tangara/ui/screen.cpp index 8357cfbd..5541b6be 100644 --- a/src/tangara/ui/screen.cpp +++ b/src/tangara/ui/screen.cpp @@ -10,7 +10,6 @@ #include "core/lv_obj_pos.h" #include "core/lv_obj_tree.h" -#include "hal/lv_hal_disp.h" #include "misc/lv_area.h" #include "misc/lv_color.h" @@ -19,20 +18,15 @@ namespace ui { Screen::Screen() : root_(lv_obj_create(NULL)), content_(lv_obj_create(root_)), - modal_content_(lv_obj_create(root_)), alert_(lv_obj_create(root_)), - group_(lv_group_create()), - modal_group_(nullptr) { + group_(lv_group_create()) { lv_obj_set_size(root_, lv_pct(100), lv_pct(100)); lv_obj_set_size(content_, lv_pct(100), lv_pct(100)); - lv_obj_set_size(modal_content_, lv_pct(100), lv_pct(100)); lv_obj_set_size(alert_, LV_SIZE_CONTENT, LV_SIZE_CONTENT); lv_obj_center(root_); lv_obj_center(content_); - lv_obj_center(modal_content_); lv_obj_center(alert_); - lv_obj_set_style_bg_opa(modal_content_, LV_OPA_TRANSP, 0); lv_obj_set_style_bg_opa(alert_, LV_OPA_TRANSP, 0); lv_obj_set_scrollbar_mode(root_, LV_SCROLLBAR_MODE_OFF); diff --git a/src/tangara/ui/screen.hpp b/src/tangara/ui/screen.hpp index 40284fda..4a9976ba 100644 --- a/src/tangara/ui/screen.hpp +++ b/src/tangara/ui/screen.hpp @@ -34,25 +34,16 @@ class Screen { auto content() -> lv_obj_t* { return content_; } auto alert() -> lv_obj_t* { return alert_; } - auto modal_content() -> lv_obj_t* { return modal_content_; } - auto modal_group(lv_group_t* g) -> void { modal_group_ = g; } - auto group() -> lv_group_t* { - if (modal_group_) { - return modal_group_; - } - return group_; - } + auto group() -> lv_group_t* { return group_; } virtual auto canPop() -> bool = 0; protected: lv_obj_t* const root_; lv_obj_t* content_; - lv_obj_t* modal_content_; lv_obj_t* alert_; lv_group_t* const group_; - lv_group_t* modal_group_; }; } // namespace ui diff --git a/src/tangara/ui/screen_splash.cpp b/src/tangara/ui/screen_splash.cpp index 651f00dd..3357eeef 100644 --- a/src/tangara/ui/screen_splash.cpp +++ b/src/tangara/ui/screen_splash.cpp @@ -23,6 +23,8 @@ Splash::Splash() { lv_obj_set_style_bg_color(root_, lv_color_black(), 0); lv_obj_t* logo = lv_img_create(root_); + lv_obj_set_style_bg_opa(logo, LV_OPA_COVER, 0); + lv_obj_set_style_bg_color(logo, lv_color_black(), 0); lv_img_set_src(logo, &splash); lv_obj_center(logo); } diff --git a/src/tangara/ui/themes.cpp b/src/tangara/ui/themes.cpp index 44638c55..726bd5f0 100644 --- a/src/tangara/ui/themes.cpp +++ b/src/tangara/ui/themes.cpp @@ -1,4 +1,11 @@ +/* + * Copyright 2024 jacqueline <me@jacqueline.id.au> + * + * SPDX-License-Identifier: GPL-3.0-only + */ + #include "ui/themes.hpp" + #include "core/lv_obj.h" #include "core/lv_obj_style.h" #include "core/lv_obj_tree.h" @@ -6,10 +13,9 @@ #include "esp_log.h" #include "misc/lv_color.h" #include "misc/lv_style.h" -#include "widgets/lv_bar.h" -#include "widgets/lv_slider.h" - -LV_FONT_DECLARE(font_fusion_12); +#include "widgets/bar/lv_bar.h" +#include "widgets/button/lv_button.h" +#include "widgets/slider/lv_slider.h" namespace ui { namespace themes { @@ -42,9 +48,9 @@ void Theme::Callback(lv_obj_t* obj) { // Determine class name std::string class_name; - if (lv_obj_check_type(obj, &lv_btn_class)) { + if (lv_obj_check_type(obj, &lv_button_class)) { class_name = "button"; - } else if (lv_obj_check_type(obj, &lv_list_btn_class)) { + } else if (lv_obj_check_type(obj, &lv_list_button_class)) { class_name = "listbutton"; } else if (lv_obj_check_type(obj, &lv_bar_class)) { class_name = "bar"; diff --git a/src/tangara/ui/ui_events.hpp b/src/tangara/ui/ui_events.hpp index cb446cd2..05fd4483 100644 --- a/src/tangara/ui/ui_events.hpp +++ b/src/tangara/ui/ui_events.hpp @@ -7,19 +7,17 @@ #pragma once #include <memory> + +#include "tinyfsm.hpp" + #include "database/database.hpp" #include "database/index.hpp" #include "drivers/gpios.hpp" #include "drivers/nvs.hpp" -#include "tinyfsm.hpp" #include "ui/screen.hpp" namespace ui { -// TODO(jacqueline): is this needed? is this good? -/* - * Event emitted by the main task on heartbeat. - */ struct OnStorageChange : tinyfsm::Event { bool is_mounted; }; @@ -44,9 +42,6 @@ struct ReindexDatabase : tinyfsm::Event {}; struct BackPressed : tinyfsm::Event {}; struct ShowNowPlaying : tinyfsm::Event {}; -struct ModalConfirmPressed : tinyfsm::Event {}; -struct ModalCancelPressed : tinyfsm::Event {}; - struct DismissAlerts : tinyfsm::Event {}; } // namespace internal diff --git a/src/tangara/ui/ui_fsm.cpp b/src/tangara/ui/ui_fsm.cpp index 3bd19bc5..968e2931 100644 --- a/src/tangara/ui/ui_fsm.cpp +++ b/src/tangara/ui/ui_fsm.cpp @@ -5,6 +5,7 @@ */ #include "ui/ui_fsm.hpp" +#include <stdint.h> #include <memory> #include <memory_resource> @@ -23,9 +24,8 @@ #include "freertos/projdefs.h" #include "lua.hpp" #include "luavgl.h" -#include "misc/lv_gc.h" +#include "tick/lv_tick.h" #include "tinyfsm.hpp" -#include "widgets/lv_label.h" #include "audio/audio_events.hpp" #include "audio/audio_fsm.hpp" @@ -74,7 +74,6 @@ std::unique_ptr<input::DeviceFactory> UiState::sDeviceFactory; std::stack<std::shared_ptr<Screen>> UiState::sScreens; std::shared_ptr<Screen> UiState::sCurrentScreen; -std::shared_ptr<Modal> UiState::sCurrentModal; std::shared_ptr<lua::LuaThread> UiState::sLua; static TimerHandle_t sAlertTimer; @@ -84,6 +83,14 @@ static void alert_timer_callback(TimerHandle_t timer) { events::Ui().Dispatch(internal::DismissAlerts{}); } +static auto lvgl_tick_cb() -> uint32_t { + return esp_timer_get_time() / 1000; +} + +static auto lvgl_delay_cb(uint32_t ms) -> void { + vTaskDelay(pdMS_TO_TICKS(ms)); +} + lua::Property UiState::sBatteryPct{0}; lua::Property UiState::sBatteryMv{0}; lua::Property UiState::sBatteryCharging{false}; @@ -281,6 +288,8 @@ auto UiState::InitBootSplash(drivers::IGpios& gpios, drivers::NvsStorage& nvs) void UiState::react(const internal::InitDisplay& ev) { // Init LVGL first, since the display driver registers itself with LVGL. lv_init(); + lv_tick_set_cb(lvgl_tick_cb); + lv_delay_set_cb(lvgl_delay_cb); drivers::displays::InitialisationData init_data = drivers::displays::kST7735R; @@ -448,9 +457,12 @@ void UiState::react(const system_fsm::BluetoothEvent& ev) { default: break; } - } else if (std::holds_alternative<drivers::bluetooth::RemoteVolumeChanged>(ev.event)) { + } else if (std::holds_alternative<drivers::bluetooth::RemoteVolumeChanged>( + ev.event)) { // Todo: Do something with this (ie, bt volume alert) - ESP_LOGI(kTag, "Recieved volume changed event with new volume: %d", std::get<drivers::bluetooth::RemoteVolumeChanged>(ev.event).new_vol); + ESP_LOGI( + kTag, "Recieved volume changed event with new volume: %d", + std::get<drivers::bluetooth::RemoteVolumeChanged>(ev.event).new_vol); } } @@ -469,7 +481,7 @@ void Splash::react(const system_fsm::BootComplete& ev) { // The system has finished booting! We now need to prepare to show real UI. // This basically just involves reading and applying the user's preferences. - lv_theme_t* base_theme = lv_theme_basic_init(NULL); + lv_theme_t* base_theme = lv_theme_simple_init(NULL); lv_disp_set_theme(NULL, base_theme); themes::Theme::instance()->Apply(); diff --git a/src/tangara/ui/ui_fsm.hpp b/src/tangara/ui/ui_fsm.hpp index aea1eb36..74c48b6e 100644 --- a/src/tangara/ui/ui_fsm.hpp +++ b/src/tangara/ui/ui_fsm.hpp @@ -32,7 +32,6 @@ #include "system_fsm/service_locator.hpp" #include "system_fsm/system_events.hpp" #include "ui/lvgl_task.hpp" -#include "ui/modal.hpp" #include "ui/screen.hpp" #include "ui/ui_events.hpp" @@ -81,13 +80,6 @@ class UiState : public tinyfsm::Fsm<UiState> { void react(const system_fsm::BluetoothEvent&); - virtual void react(const internal::ModalCancelPressed&) { - sCurrentModal.reset(); - } - virtual void react(const internal::ModalConfirmPressed&) { - sCurrentModal.reset(); - } - void react(const internal::ReindexDatabase&){}; protected: @@ -103,7 +95,6 @@ class UiState : public tinyfsm::Fsm<UiState> { static std::stack<std::shared_ptr<Screen>> sScreens; static std::shared_ptr<Screen> sCurrentScreen; - static std::shared_ptr<Modal> sCurrentModal; static std::shared_ptr<lua::LuaThread> sLua; static lua::Property sBatteryPct; |
