summaryrefslogtreecommitdiff
path: root/src/gyronardo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gyronardo.cpp')
-rw-r--r--src/gyronardo.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/gyronardo.cpp b/src/gyronardo.cpp
index 148a21b..63b4bfc 100644
--- a/src/gyronardo.cpp
+++ b/src/gyronardo.cpp
@@ -16,17 +16,14 @@ constexpr unsigned int BAUD_RATE = 9600U;
constexpr unsigned int SENSOR_RETRY_TIME = 2000U;
SerialStream sout(Serial_(), BAUD_RATE);
-// SerialStream sout(Serial, BAUD_RATE);
-UniquePtr<Sensor> sensor;
+auto sensor = Sensor(SENSOR_ADDRESS, Wire, sout, SENSOR_THROTTLE_TIME);
void setup()
{
sout.waitReady();
- sensor = make_unique<Sensor>(SENSOR_ADDRESS, Wire, sout, SENSOR_THROTTLE_TIME);
-
- while (!sensor->begin())
+ while (!sensor.begin())
{
sout << "Error: Could not connect to the sensor. Retrying after 2000 "
"milliseconds..."
@@ -35,18 +32,18 @@ void setup()
delay(SENSOR_RETRY_TIME);
}
- if (!sensor->setAccelSensitivity(2)) // 8g
+ if (!sensor.setAccelSensitivity(2)) // 8g
{
sout << "Error: Failed to set the sensor's accelerometer sensitivity. Status: "
- << static_cast<int>(sensor->getStatus()) << endl;
+ << static_cast<int>(sensor.getStatus()) << endl;
stop();
}
- if (!sensor->setGyroSensitivity(1)) // 500 degrees/s
+ if (!sensor.setGyroSensitivity(1)) // 500 degrees/s
{
sout << "Error: Failed to set the sensor's gyro sensitivity. Status: "
- << static_cast<int>(sensor->getStatus()) << endl;
+ << static_cast<int>(sensor.getStatus()) << endl;
stop();
}
@@ -66,17 +63,17 @@ void setup()
sout << "Finished calibrating sensor\n";
sout << "Calibration values:\n"
- << "Accelerometer X: " << sensor->accel_cal_x << "\n"
- << "Accelerometer Y: " << sensor->accel_cal_y << "\n"
- << "Accelerometer Z: " << sensor->accel_cal_z << "\n"
- << "Gyro X: " << sensor->gyro_cal_x << "\n"
- << "Gyro Y: " << sensor->gyro_cal_y << "\n"
- << "Gyro Z: " << sensor->gyro_cal_z << "\n";
+ << "Accelerometer X: " << sensor.accel_cal_x << "\n"
+ << "Accelerometer Y: " << sensor.accel_cal_y << "\n"
+ << "Accelerometer Z: " << sensor.accel_cal_z << "\n"
+ << "Gyro X: " << sensor.gyro_cal_x << "\n"
+ << "Gyro Y: " << sensor.gyro_cal_y << "\n"
+ << "Gyro Z: " << sensor.gyro_cal_z << "\n";
sout << "Starting..." << endl;
- sout << "Pitch: " << sensor->getPitch() << " "
- << "Roll: " << sensor->getRoll() << endl;
+ sout << "Pitch: " << sensor.getPitch() << " "
+ << "Roll: " << sensor.getRoll() << endl;
}
void loop()