diff options
author | HampusM <hampus@hampusmat.com> | 2022-02-14 10:11:32 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-02-14 10:11:32 +0100 |
commit | 7892ef9d248c189be68ce7faf63230ec0a318b67 (patch) | |
tree | 7c3d07779d5ce96994f81c0cc22e8b667601ee9d /src/calibration.cpp | |
parent | a03dfe959fcafd238119bdf7f27c07b92064496e (diff) |
refactor: reorganize & add debugging
Diffstat (limited to 'src/calibration.cpp')
-rw-r--r-- | src/calibration.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/calibration.cpp b/src/calibration.cpp index f76d8f8..a772ae9 100644 --- a/src/calibration.cpp +++ b/src/calibration.cpp @@ -1,9 +1,11 @@ #include "calibration.hpp" -#include "time_utils.hpp" -SensorCalibrator::SensorCalibrator(Sensor *sensor) +#include "utils/general.hpp" +#include "utils/time.hpp" + +SensorCalibrator::SensorCalibrator(unique_ptr<Sensor> &sensor, SerialStream sout) + : _sensor(sensor), _sout(sout) { - _sensor = sensor; _resetValues(); } @@ -15,7 +17,9 @@ bool SensorCalibrator::calibrate(unsigned int throttle_time) while (!done) { if (time_now().diff(start_time).millisecs() >= CALIBRATION_TIMEOUT) + { return false; + } delay(throttle_time); @@ -28,19 +32,12 @@ bool SensorCalibrator::calibrate(unsigned int throttle_time) _adjustValues(); - Serial.print("Accel X: "); - Serial.print(_accel_x); - Serial.print(" Accel Y: "); - Serial.print(_accel_y); - Serial.print(" Accel Z: "); - Serial.print(_accel_z); - - Serial.print(" Gyro X: "); - Serial.print(_gyro_x); - Serial.print(" Gyro Y: "); - Serial.print(_gyro_y); - Serial.print(" Gyro Z: "); - Serial.println(_gyro_z); + _sout << "Accel X: " << _accel_x << " " + << "Accel Y: " << _accel_y << " " + << "Accel Z: " << _accel_z << " " + << "Gyro X: " << _gyro_x << " " + << "Gyro Y: " << _gyro_y << " " + << "Gyro Z: " << _gyro_z << endl; if (_isValuesInRange()) { |