summaryrefslogtreecommitdiff
path: root/src/gyronardo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gyronardo.cpp')
-rw-r--r--src/gyronardo.cpp29
1 files changed, 15 insertions, 14 deletions
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 <Arduino.h>
+#include <Wire.h>
+
+// 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<SerialStream> sout_ptr = nullptr;
+constexpr unsigned int BAUD_RATE = 9600U;
-unique_ptr<Sensor> sensor = nullptr;
+constexpr unsigned int SENSOR_RETRY_TIME = 2000U;
+
+UniquePtr<SerialStream> sout_ptr;
+
+UniquePtr<Sensor> sensor;
void setup()
{
- sout_ptr = make_unique<SerialStream>(Serial, 9600);
+ sout_ptr = make_unique<SerialStream>(Serial, BAUD_RATE);
auto sout = *sout_ptr;
- sensor = make_unique<Sensor>(SENSOR_ADDRESS, &Wire, sout, SENSOR_THROTTLE_TIME);
+ sensor = make_unique<Sensor>(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: "