From 7892ef9d248c189be68ce7faf63230ec0a318b67 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 14 Feb 2022 10:11:32 +0100 Subject: refactor: reorganize & add debugging --- src/calibration.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src/calibration.cpp') 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, 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()) { -- cgit v1.2.3-18-g5258