summaryrefslogtreecommitdiff
path: root/src/system_fsm
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-06-01 15:28:32 +1000
committerjacqueline <me@jacqueline.id.au>2023-06-01 15:28:54 +1000
commit6fd588e970470b15936187980829916d0dbe77bb (patch)
tree1b1e73ef52bef2e41499ee5ceadc45efd408050b /src/system_fsm
parentdb2e29a72d9b934e7b58f1d20ac3768eae484ab5 (diff)
downloadtangara-fw-6fd588e970470b15936187980829916d0dbe77bb.tar.gz
Add touchwheel -> encoder adapter
Diffstat (limited to 'src/system_fsm')
-rw-r--r--src/system_fsm/booting.cpp16
-rw-r--r--src/system_fsm/include/system_fsm.hpp2
-rw-r--r--src/system_fsm/system_fsm.cpp2
3 files changed, 14 insertions, 6 deletions
diff --git a/src/system_fsm/booting.cpp b/src/system_fsm/booting.cpp
index 383bba81..b14da10c 100644
--- a/src/system_fsm/booting.cpp
+++ b/src/system_fsm/booting.cpp
@@ -13,6 +13,7 @@
#include "event_queue.hpp"
#include "gpio_expander.hpp"
#include "lvgl/lvgl.h"
+#include "relative_wheel.hpp"
#include "spi.hpp"
#include "system_events.hpp"
#include "system_fsm.hpp"
@@ -43,25 +44,28 @@ auto Booting::entry() -> void {
assert(sGpioExpander != nullptr);
// Start bringing up LVGL now, since we have all of its prerequisites.
- ESP_LOGI(kTag, "starting ui");
+ ESP_LOGI(kTag, "installing ui drivers");
lv_init();
sDisplay.reset(drivers::Display::Create(sGpioExpander.get(),
drivers::displays::kST7735R));
assert(sDisplay != nullptr);
+ sTouch.reset(drivers::TouchWheel::Create());
+ if (sTouch != nullptr) {
+ sRelativeTouch.reset(new drivers::RelativeWheel(sTouch.get()));
+ }
// The UI FSM now has everything it needs to start setting up. Do this now,
// so that we can properly show the user any errors that appear later.
- ui::UiState::Init(sGpioExpander.get(), sTouch, sDisplay, sDatabase);
+ ui::UiState::Init(sGpioExpander.get(), sRelativeTouch, sDisplay);
events::Dispatch<DisplayReady, ui::UiState>(DisplayReady());
// These drivers are required for normal operation, but aren't critical for
// booting. We will transition to the error state if these aren't present.
ESP_LOGI(kTag, "installing required drivers");
sSamd.reset(drivers::Samd::Create());
- sTouch.reset(drivers::TouchWheel::Create());
-
auto dac_res = drivers::AudioDac::create(sGpioExpander.get());
- if (dac_res.has_error() || !sSamd || !sTouch) {
+
+ if (dac_res.has_error() || !sSamd || !sRelativeTouch) {
events::Dispatch<FatalError, SystemState, ui::UiState, audio::AudioState>(
FatalError());
return;
@@ -70,7 +74,7 @@ auto Booting::entry() -> void {
// These drivers are initialised on boot, but are recoverable (if weird) if
// they fail.
- ESP_LOGI(kTag, "installing extra drivers");
+ ESP_LOGI(kTag, "installing optional drivers");
sBattery.reset(drivers::Battery::Create());
// All drivers are now loaded, so we can finish initing the other state
diff --git a/src/system_fsm/include/system_fsm.hpp b/src/system_fsm/include/system_fsm.hpp
index 0153e403..4413f64e 100644
--- a/src/system_fsm/include/system_fsm.hpp
+++ b/src/system_fsm/include/system_fsm.hpp
@@ -14,6 +14,7 @@
#include "database.hpp"
#include "display.hpp"
#include "gpio_expander.hpp"
+#include "relative_wheel.hpp"
#include "samd.hpp"
#include "storage.hpp"
#include "tinyfsm.hpp"
@@ -51,6 +52,7 @@ class SystemState : public tinyfsm::Fsm<SystemState> {
static std::shared_ptr<drivers::Samd> sSamd;
static std::shared_ptr<drivers::TouchWheel> sTouch;
+ static std::shared_ptr<drivers::RelativeWheel> sRelativeTouch;
static std::shared_ptr<drivers::Battery> sBattery;
static std::shared_ptr<drivers::SdStorage> sStorage;
static std::shared_ptr<drivers::Display> sDisplay;
diff --git a/src/system_fsm/system_fsm.cpp b/src/system_fsm/system_fsm.cpp
index 6956b87c..eb7cce52 100644
--- a/src/system_fsm/system_fsm.cpp
+++ b/src/system_fsm/system_fsm.cpp
@@ -5,6 +5,7 @@
*/
#include "system_fsm.hpp"
+#include "relative_wheel.hpp"
#include "system_events.hpp"
namespace system_fsm {
@@ -13,6 +14,7 @@ std::shared_ptr<drivers::GpioExpander> SystemState::sGpioExpander;
std::shared_ptr<drivers::Samd> SystemState::sSamd;
std::shared_ptr<drivers::TouchWheel> SystemState::sTouch;
+std::shared_ptr<drivers::RelativeWheel> SystemState::sRelativeTouch;
std::shared_ptr<drivers::Battery> SystemState::sBattery;
std::shared_ptr<drivers::SdStorage> SystemState::sStorage;
std::shared_ptr<drivers::Display> SystemState::sDisplay;