From 01ce0af940bd69c94a2fac8b65219262845cca98 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 14 Feb 2022 18:18:38 +0100 Subject: refactor: clean sewage --- src/gyronardo.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src/gyronardo.cpp') diff --git a/src/gyronardo.cpp b/src/gyronardo.cpp index 53a1912..1133f3f 100644 --- a/src/gyronardo.cpp +++ b/src/gyronardo.cpp @@ -1,28 +1,31 @@ -#include "Arduino.h" - -#include "Wire.h" #include "calibration.hpp" #include "sensor/sensor.hpp" #include "utils/memory.hpp" - #include "utils/serial.hpp" -#define LINE_CLEAR_LENGTH 30 +#include +#include + +// constexpr unsigned int LINE_CLEAR_LENGTH = 30U; -#define SENSOR_ADDRESS 0x68 -#define SENSOR_THROTTLE_TIME 50 // milliseconds +constexpr unsigned int SENSOR_ADDRESS = 0x68U; +constexpr unsigned int SENSOR_THROTTLE_TIME = 50U; // milliseconds -unique_ptr sout_ptr = nullptr; +constexpr unsigned int BAUD_RATE = 9600U; -unique_ptr sensor = nullptr; +constexpr unsigned int SENSOR_RETRY_TIME = 2000U; + +UniquePtr sout_ptr; + +UniquePtr sensor; void setup() { - sout_ptr = make_unique(Serial, 9600); + sout_ptr = make_unique(Serial, BAUD_RATE); auto sout = *sout_ptr; - sensor = make_unique(SENSOR_ADDRESS, &Wire, sout, SENSOR_THROTTLE_TIME); + sensor = make_unique(SENSOR_ADDRESS, Wire, sout, SENSOR_THROTTLE_TIME); while (!sensor->begin()) { @@ -30,11 +33,9 @@ void setup() "milliseconds..." << endl; - delay(2000); + delay(SENSOR_RETRY_TIME); } - sout << "Skit!" << endl; - if (!sensor->setAccelSensitivity(2)) // 8g { sout << "Error: Failed to set the sensor's accelerometer sensitivity. Status: " -- cgit v1.2.3-18-g5258