diff options
| author | Robin Howard <robin@rhoward.id.au> | 2023-11-07 15:46:07 +1100 |
|---|---|---|
| committer | Robin Howard <robin@rhoward.id.au> | 2023-11-07 16:31:55 +1100 |
| commit | 135185f12ba07dea8568b06c0a65a00a8af7deb7 (patch) | |
| tree | 19724b4caf02c6127766be4e9bfd33d006cfdd25 /src/system_fsm/include | |
| parent | 3abf599c4f8b04bed4ed67084588204f65a644d0 (diff) | |
| download | tangara-fw-135185f12ba07dea8568b06c0a65a00a8af7deb7.tar.gz | |
haptics: adds a wrapper for the DRV2605L haptic motor driver
... with facilities to trigger effects via the system fsm.
Diffstat (limited to 'src/system_fsm/include')
| -rw-r--r-- | src/system_fsm/include/service_locator.hpp | 10 | ||||
| -rw-r--r-- | src/system_fsm/include/system_events.hpp | 5 | ||||
| -rw-r--r-- | src/system_fsm/include/system_fsm.hpp | 2 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/system_fsm/include/service_locator.hpp b/src/system_fsm/include/service_locator.hpp index 327d0c50..4aa57df0 100644 --- a/src/system_fsm/include/service_locator.hpp +++ b/src/system_fsm/include/service_locator.hpp @@ -13,6 +13,7 @@ #include "collation.hpp" #include "database.hpp" #include "gpios.hpp" +#include "haptics.hpp" #include "nvs.hpp" #include "samd.hpp" #include "storage.hpp" @@ -79,6 +80,14 @@ class ServiceLocator { touchwheel_ = std::move(i); } + auto haptics() -> drivers::Haptics& { + return *haptics_; + } + + auto haptics(std::unique_ptr<drivers::Haptics> i) { + haptics_ = std::move(i); + } + auto database() -> std::weak_ptr<database::Database> { return database_; } auto database(std::unique_ptr<database::Database> i) { @@ -130,6 +139,7 @@ class ServiceLocator { std::unique_ptr<drivers::Samd> samd_; std::unique_ptr<drivers::NvsStorage> nvs_; std::unique_ptr<drivers::TouchWheel> touchwheel_; + std::unique_ptr<drivers::Haptics> haptics_; std::unique_ptr<drivers::Bluetooth> bluetooth_; std::unique_ptr<audio::TrackQueue> queue_; diff --git a/src/system_fsm/include/system_events.hpp b/src/system_fsm/include/system_events.hpp index 4db9beb0..2722fa80 100644 --- a/src/system_fsm/include/system_events.hpp +++ b/src/system_fsm/include/system_events.hpp @@ -10,6 +10,7 @@ #include "battery.hpp" #include "database.hpp" +#include "haptics.hpp" #include "service_locator.hpp" #include "tinyfsm.hpp" @@ -55,6 +56,10 @@ struct BatteryStateChanged : tinyfsm::Event { struct BluetoothDevicesChanged : tinyfsm::Event {}; +struct HapticTrigger : tinyfsm::Event { + drivers::Haptics::Effect effect; +}; + namespace internal { struct GpioInterrupt : tinyfsm::Event {}; diff --git a/src/system_fsm/include/system_fsm.hpp b/src/system_fsm/include/system_fsm.hpp index 28448e5a..c9803bef 100644 --- a/src/system_fsm/include/system_fsm.hpp +++ b/src/system_fsm/include/system_fsm.hpp @@ -50,6 +50,8 @@ class SystemState : public tinyfsm::Fsm<SystemState> { void react(const internal::GpioInterrupt&); void react(const internal::SamdInterrupt&); + void react(const HapticTrigger&); + virtual void react(const DisplayReady&) {} virtual void react(const BootComplete&) {} virtual void react(const StorageMounted&) {} |
