summaryrefslogtreecommitdiff
path: root/src/calibration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/calibration.cpp')
-rw-r--r--src/calibration.cpp29
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())
{