diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-06-14 13:34:41 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-06-14 13:34:41 +1000 |
| commit | 5086ab96ea648cd842addb02b188f29bff7bbadd (patch) | |
| tree | 7a3579d655c906ace9e76c394c33eb164d7ce7aa /src/tangara/ui/ui_fsm.cpp | |
| parent | 194f0e6b59259986b36448c376788c227d490f06 (diff) | |
| parent | 37ed3996017e43b343e4880981d70c4a6d4a5636 (diff) | |
| download | tangara-fw-5086ab96ea648cd842addb02b188f29bff7bbadd.tar.gz | |
Merge branch 'jqln/lvgl-bump'
Diffstat (limited to 'src/tangara/ui/ui_fsm.cpp')
| -rw-r--r-- | src/tangara/ui/ui_fsm.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
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(); |
