diff options
author | HampusM <hampus@hampusmat.com> | 2022-02-14 18:18:38 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-02-14 18:18:38 +0100 |
commit | 01ce0af940bd69c94a2fac8b65219262845cca98 (patch) | |
tree | 97c443782ce1cfba90b205183c8aab1e3edb0bb3 /src/calibration.hpp | |
parent | cb7a167c7dee2fa1a19bd09ede3bae8b140e79da (diff) |
refactor: clean sewage
Diffstat (limited to 'src/calibration.hpp')
-rw-r--r-- | src/calibration.hpp | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/src/calibration.hpp b/src/calibration.hpp index e66b6fc..e29602a 100644 --- a/src/calibration.hpp +++ b/src/calibration.hpp @@ -1,33 +1,32 @@ -#ifndef CALIBRATION_HPP -#define CALIBRATION_HPP +#pragma once #include "sensor/sensor.hpp" #include "utils/memory.hpp" #include "utils/serial.hpp" // Calibration precision -#define ACCEL_CAL_X_MAX 0.006 -#define ACCEL_CAL_X_MIN -0.006 +constexpr float ACCEL_CAL_X_MAX = 0.006; +constexpr float ACCEL_CAL_X_MIN = -0.006; -#define ACCEL_CAL_Y_MAX 0.006 -#define ACCEL_CAL_Y_MIN -0.006 +constexpr float ACCEL_CAL_Y_MAX = 0.006; +constexpr float ACCEL_CAL_Y_MIN = -0.006; -#define ACCEL_CAL_Z_MAX 0.006 -#define ACCEL_CAL_Z_MIN -0.006 +constexpr float ACCEL_CAL_Z_MAX = 0.006; +constexpr float ACCEL_CAL_Z_MIN = -0.006; -#define GYRO_CAL_X_MAX 0.06 -#define GYRO_CAL_X_MIN -0.06 +constexpr float GYRO_CAL_X_MAX = 0.06; +constexpr float GYRO_CAL_X_MIN = -0.06; -#define GYRO_CAL_Y_MAX 0.06 -#define GYRO_CAL_Y_MIN -0.06 +constexpr float GYRO_CAL_Y_MAX = 0.06; +constexpr float GYRO_CAL_Y_MIN = -0.06; -#define GYRO_CAL_Z_MAX 0.06 -#define GYRO_CAL_Z_MIN -0.06 +constexpr float GYRO_CAL_Z_MAX = 0.06; +constexpr float GYRO_CAL_Z_MIN = -0.06; -#define CALIBRATION_TIMEOUT 120000 // Milliseconds +constexpr uint32_t CALIBRATION_TIMEOUT = 120000; // Milliseconds -#define SENSOR_READ_CNT 20 -#define SENSOR_VAL_ADJUST 0.05 +constexpr unsigned int SENSOR_READ_CNT = 20; +constexpr float SENSOR_VAL_ADJUST = 0.05; /** * Sensor calibrator. @@ -41,7 +40,7 @@ public: * @param sensor A sensor to calibrate * @param sout A Serial output stream */ - SensorCalibrator(unique_ptr<Sensor> &sensor, SerialStream sout); + SensorCalibrator(UniquePtr<Sensor> &sensor, SerialStream sout); /** * Calibrates the sensor. @@ -60,17 +59,15 @@ private: void _adjustCalibration(); - unique_ptr<Sensor> &_sensor; + UniquePtr<Sensor> &_sensor; SerialStream _sout; - float _accel_x; - float _accel_y; - float _accel_z; + double _accel_x = 0; + double _accel_y = 0; + double _accel_z = 0; - float _gyro_x; - float _gyro_y; - float _gyro_z; + double _gyro_x = 0; + double _gyro_y = 0; + double _gyro_z = 0; }; - -#endif |