diff options
Diffstat (limited to 'src/sensor')
-rw-r--r-- | src/sensor/calibration.cpp | 28 | ||||
-rw-r--r-- | src/sensor/calibration.hpp | 5 |
2 files changed, 16 insertions, 17 deletions
diff --git a/src/sensor/calibration.cpp b/src/sensor/calibration.cpp index 1538baa..42f5010 100644 --- a/src/sensor/calibration.cpp +++ b/src/sensor/calibration.cpp @@ -3,7 +3,7 @@ #include "std/time.hpp" #include "utils.hpp" -SensorCalibrator::SensorCalibrator(UniquePtr<Sensor> sensor, SerialStream sout) +SensorCalibrator::SensorCalibrator(Sensor sensor, SerialStream sout) : _sensor(sensor), _sout(sout) { } @@ -51,26 +51,26 @@ bool SensorCalibrator::calibrate(unsigned int throttle_time) void SensorCalibrator::_updateValues(SensorCalibratorValues &values) { - _sensor->read(); + _sensor.read(); - values.accel_x -= _sensor->getAccelX(); - values.accel_y -= _sensor->getAccelY(); - values.accel_z -= _sensor->getAccelZ(); + values.accel_x -= _sensor.getAccelX(); + values.accel_y -= _sensor.getAccelY(); + values.accel_z -= _sensor.getAccelZ(); - values.gyro_x -= _sensor->getGyroX(); - values.gyro_y -= _sensor->getGyroY(); - values.gyro_z -= _sensor->getGyroZ(); + values.gyro_x -= _sensor.getGyroX(); + values.gyro_y -= _sensor.getGyroY(); + values.gyro_z -= _sensor.getGyroZ(); } void SensorCalibrator::_adjustCalibrationWithValues(const SensorCalibratorValues &values) { - _sensor->accel_cal_x += values.accel_x; - _sensor->accel_cal_y += values.accel_y; - _sensor->accel_cal_z += values.accel_z; + _sensor.accel_cal_x += values.accel_x; + _sensor.accel_cal_y += values.accel_y; + _sensor.accel_cal_z += values.accel_z; - _sensor->gyro_cal_x += values.gyro_x; - _sensor->gyro_cal_y += values.gyro_y; - _sensor->gyro_cal_z += values.gyro_z; + _sensor.gyro_cal_x += values.gyro_x; + _sensor.gyro_cal_y += values.gyro_y; + _sensor.gyro_cal_z += values.gyro_z; } void SensorCalibrator::_adjustValues(SensorCalibratorValues &values) diff --git a/src/sensor/calibration.hpp b/src/sensor/calibration.hpp index a2da58b..090fd27 100644 --- a/src/sensor/calibration.hpp +++ b/src/sensor/calibration.hpp @@ -2,7 +2,6 @@ #include "sensor/sensor.hpp" #include "serial.hpp" -#include "std/memory.hpp" // Calibration precision constexpr float ACCEL_CAL_X_MAX = 0.006; @@ -52,7 +51,7 @@ public: * @param sensor A sensor to calibrate * @param sout A Serial output stream */ - SensorCalibrator(UniquePtr<Sensor> sensor, SerialStream sout); + SensorCalibrator(Sensor sensor, SerialStream sout); /** * Calibrates the sensor. @@ -70,7 +69,7 @@ private: static void _adjustValues(SensorCalibratorValues &values); static bool _isValuesInRange(const SensorCalibratorValues &values); - UniquePtr<Sensor> _sensor; + Sensor _sensor; SerialStream _sout; }; |