summaryrefslogtreecommitdiff
path: root/src/system_fsm
diff options
context:
space:
mode:
authorRobin Howard <robin@rhoward.id.au>2024-04-19 16:03:35 +1000
committerRobin Howard <robin@rhoward.id.au>2024-04-19 16:03:53 +1000
commit7c075cf5b776feaed2065f936dff0c176635b89d (patch)
treed89dae49799dc684a9870361117789085b132854 /src/system_fsm
parente39754ba105213c133407e2dacb5fd31f3873e4c (diff)
downloadtangara-fw-7c075cf5b776feaed2065f936dff0c176635b89d.tar.gz
Adds LRA haptic support (open-loop only for now).
Diffstat (limited to 'src/system_fsm')
-rw-r--r--src/system_fsm/booting.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/system_fsm/booting.cpp b/src/system_fsm/booting.cpp
index bd394428..a89f35d9 100644
--- a/src/system_fsm/booting.cpp
+++ b/src/system_fsm/booting.cpp
@@ -62,6 +62,10 @@ auto Booting::entry() -> void {
sServices->nvs(
std::unique_ptr<drivers::NvsStorage>(drivers::NvsStorage::OpenSync()));
+ // HACK: tell the unit that it has an ERM motor (we will likely default to
+ // LRAs in future, but all the current units in the field use ERMs.)
+ sServices->nvs().HapticMotorIsErm(true);
+
// HACK: fix up the switch polarity on newer dev units
// sServices->nvs().LockPolarity(false);
@@ -85,7 +89,11 @@ auto Booting::entry() -> void {
sServices->samd(std::unique_ptr<drivers::Samd>(drivers::Samd::Create()));
sServices->touchwheel(
std::unique_ptr<drivers::TouchWheel>{drivers::TouchWheel::Create()});
- sServices->haptics(std::make_unique<drivers::Haptics>());
+ sServices->haptics(std::make_unique<drivers::Haptics>(
+ sServices->nvs().HapticMotorIsErm()
+ ? std::variant<drivers::ErmMotor, drivers::LraMotor>(
+ drivers::ErmMotor())
+ : drivers::LraMotor()));
auto adc = drivers::AdcBattery::Create();
sServices->battery(std::make_unique<battery::Battery>(