diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-10-03 10:37:29 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-10-03 10:37:29 +1100 |
| commit | 7d5536e2abca61f503ed68521603bd30700a7e5e (patch) | |
| tree | fc8b191a5d248a86de08a00d814359f335423e95 /src/ui/ui_fsm.cpp | |
| parent | f2bad894cdac88b94a358cebdb062f426b191d1b (diff) | |
| download | tangara-fw-7d5536e2abca61f503ed68521603bd30700a7e5e.tar.gz | |
Generalise the lvgl input driver in preparation for more input methods
Diffstat (limited to 'src/ui/ui_fsm.cpp')
| -rw-r--r-- | src/ui/ui_fsm.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
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<UiTask> UiState::sTask; std::shared_ptr<system_fsm::ServiceLocator> UiState::sServices; std::unique_ptr<drivers::Display> UiState::sDisplay; -std::shared_ptr<TouchWheelEncoder> UiState::sEncoder; +std::shared_ptr<EncoderInput> UiState::sInput; std::stack<std::shared_ptr<Screen>> UiState::sScreens; std::shared_ptr<Screen> 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<TouchWheelEncoder>()); + 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<drivers::RelativeWheel>(**touchwheel); - sEncoder = std::make_shared<TouchWheelEncoder>(std::move(relative_wheel)); - sTask->SetInputDevice(sEncoder); + sInput = std::make_shared<EncoderInput>(sServices->gpios(), **touchwheel); + sTask->input(sInput); } else { ESP_LOGE(kTag, "no input devices initialised!"); } |
