diff options
author | HampusM <hampus@hampusmat.com> | 2022-03-01 09:43:10 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-03-01 09:43:10 +0100 |
commit | 5db3312a91637aebcb31ffc11538eb265c5e2967 (patch) | |
tree | 3d26557bb3cec36f4fb12403f369f57969a7b07f /src/sensor/calibration.hpp | |
parent | 249323fc5fa14dbc4c1a6316873cfc07f468f43b (diff) |
refactor: improve calibration value handling
Diffstat (limited to 'src/sensor/calibration.hpp')
-rw-r--r-- | src/sensor/calibration.hpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/sensor/calibration.hpp b/src/sensor/calibration.hpp index a808fe9..a2da58b 100644 --- a/src/sensor/calibration.hpp +++ b/src/sensor/calibration.hpp @@ -28,6 +28,18 @@ constexpr uint32_t CALIBRATION_TIMEOUT = 120000; // Milliseconds constexpr unsigned int SENSOR_READ_CNT = 20; constexpr float SENSOR_VAL_ADJUST = 0.05; +class SensorCalibratorValues +{ +public: + double accel_x = 0; + double accel_y = 0; + double accel_z = 0; + + double gyro_x = 0; + double gyro_y = 0; + double gyro_z = 0; +}; + /** * Sensor calibrator. */ @@ -52,22 +64,13 @@ public: bool calibrate(unsigned int throttle_time); private: - void _resetValues(); - void _updateValues(); - void _adjustValues(); - bool _isValuesInRange() const; + void _updateValues(SensorCalibratorValues &values); + void _adjustCalibrationWithValues(const SensorCalibratorValues &values); - void _adjustCalibration(); + static void _adjustValues(SensorCalibratorValues &values); + static bool _isValuesInRange(const SensorCalibratorValues &values); UniquePtr<Sensor> _sensor; SerialStream _sout; - - double _accel_x = 0; - double _accel_y = 0; - double _accel_z = 0; - - double _gyro_x = 0; - double _gyro_y = 0; - double _gyro_z = 0; }; |