From 7d5536e2abca61f503ed68521603bd30700a7e5e Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 3 Oct 2023 10:37:29 +1100 Subject: Generalise the lvgl input driver in preparation for more input methods --- src/ui/ui_fsm.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/ui/ui_fsm.cpp') diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index f66e3e8a..bc976eab 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -15,6 +15,7 @@ #include "audio_events.hpp" #include "display.hpp" +#include "encoder_input.hpp" #include "event_queue.hpp" #include "gpios.hpp" #include "lvgl_task.hpp" @@ -35,7 +36,6 @@ #include "touchwheel.hpp" #include "track_queue.hpp" #include "ui_events.hpp" -#include "wheel_encoder.hpp" #include "widget_top_bar.hpp" namespace ui { @@ -47,7 +47,7 @@ static const std::size_t kRecordsPerPage = 15; std::unique_ptr UiState::sTask; std::shared_ptr UiState::sServices; std::unique_ptr UiState::sDisplay; -std::shared_ptr UiState::sEncoder; +std::shared_ptr UiState::sInput; std::stack> UiState::sScreens; std::shared_ptr UiState::sCurrentScreen; @@ -88,8 +88,7 @@ void UiState::PopScreen() { void UiState::react(const system_fsm::KeyLockChanged& ev) { sDisplay->SetDisplayOn(ev.falling); - sTask->SetInputDevice(ev.falling ? sEncoder - : std::shared_ptr()); + sInput->lock(!ev.falling); } void UiState::react(const system_fsm::BatteryStateChanged& ev) { @@ -138,10 +137,8 @@ void Splash::react(const system_fsm::BootComplete& ev) { auto touchwheel = sServices->touchwheel(); if (touchwheel) { - auto relative_wheel = - std::make_unique(**touchwheel); - sEncoder = std::make_shared(std::move(relative_wheel)); - sTask->SetInputDevice(sEncoder); + sInput = std::make_shared(sServices->gpios(), **touchwheel); + sTask->input(sInput); } else { ESP_LOGE(kTag, "no input devices initialised!"); } -- cgit v1.2.3