From 00d6c2eca20571f1a53400f4f465c8dd7af557db Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 14 May 2024 15:21:21 +1000 Subject: save lra calibration data to nvs --- src/drivers/include/drivers/haptics.hpp | 16 ++++------------ src/drivers/include/drivers/nvs.hpp | 13 ++++++++++++- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'src/drivers/include') 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 #include -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& motor) - -> Haptics* { - return new Haptics(motor); - } + static auto Create(NvsStorage& nvs) -> Haptics* { return new Haptics(nvs); } - Haptics(const std::variant& 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; + auto LraCalibration(const LraData&) -> void; auto PreferredBluetoothDevice() -> std::optional; auto PreferredBluetoothDevice(std::optional) -> void; @@ -135,6 +145,7 @@ class NvsStorage { Setting display_cols_; Setting display_rows_; Setting haptic_motor_type_; + Setting lra_calibration_; Setting brightness_; Setting sensitivity_; -- cgit v1.2.3