summaryrefslogtreecommitdiff
path: root/src/drivers/include
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-05-14 15:21:21 +1000
committerjacqueline <me@jacqueline.id.au>2024-05-14 15:21:21 +1000
commit00d6c2eca20571f1a53400f4f465c8dd7af557db (patch)
tree3c509cdec622f256fbb9be58cf2a5b35da743da1 /src/drivers/include
parentdefe838ab01da8502de13d3c75e008624d1e675a (diff)
downloadtangara-fw-00d6c2eca20571f1a53400f4f465c8dd7af557db.tar.gz
save lra calibration data to nvs
Diffstat (limited to 'src/drivers/include')
-rw-r--r--src/drivers/include/drivers/haptics.hpp16
-rw-r--r--src/drivers/include/drivers/nvs.hpp13
2 files changed, 16 insertions, 13 deletions
diff --git a/src/drivers/include/drivers/haptics.hpp b/src/drivers/include/drivers/haptics.hpp
index a9384fa4..e4666fad 100644
--- a/src/drivers/include/drivers/haptics.hpp
+++ b/src/drivers/include/drivers/haptics.hpp
@@ -14,23 +14,15 @@
#include <string>
#include <variant>
-namespace drivers {
+#include "drivers/nvs.hpp"
-typedef std::monostate ErmMotor;
-struct LraMotor {
- // TODO: fill out with calibration data from
- // https://www.ti.com/lit/ds/symlink/drv2605l.pdf
- bool hi;
-};
+namespace drivers {
class Haptics {
public:
- static auto Create(const std::variant<ErmMotor, LraMotor>& motor)
- -> Haptics* {
- return new Haptics(motor);
- }
+ static auto Create(NvsStorage& nvs) -> Haptics* { return new Haptics(nvs); }
- Haptics(const std::variant<ErmMotor, LraMotor>& motor);
+ Haptics(NvsStorage& nvs);
~Haptics();
// Not copyable or movable.
diff --git a/src/drivers/include/drivers/nvs.hpp b/src/drivers/include/drivers/nvs.hpp
index 83bb8097..88dd5ae0 100644
--- a/src/drivers/include/drivers/nvs.hpp
+++ b/src/drivers/include/drivers/nvs.hpp
@@ -78,7 +78,17 @@ class NvsStorage {
auto HapticMotorIsErm() -> bool;
auto HapticMotorIsErm(bool) -> void;
- // /Hardware Compatibility
+
+ struct LraData {
+ uint8_t compensation;
+ uint8_t back_emf;
+ uint8_t gain;
+
+ bool operator==(const LraData&) const = default;
+ };
+
+ auto LraCalibration() -> std::optional<LraData>;
+ auto LraCalibration(const LraData&) -> void;
auto PreferredBluetoothDevice() -> std::optional<bluetooth::MacAndName>;
auto PreferredBluetoothDevice(std::optional<bluetooth::MacAndName>) -> void;
@@ -135,6 +145,7 @@ class NvsStorage {
Setting<uint16_t> display_cols_;
Setting<uint16_t> display_rows_;
Setting<uint8_t> haptic_motor_type_;
+ Setting<LraData> lra_calibration_;
Setting<uint8_t> brightness_;
Setting<uint8_t> sensitivity_;