From f921311a3793c9bcd332e50b294681bed95a7608 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 22 Dec 2021 15:02:40 +0100 Subject: refactor: correct the main source file name --- src/gyro.cpp | 44 -------------------------------------------- src/gyronardo.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 44 deletions(-) delete mode 100644 src/gyro.cpp create mode 100644 src/gyronardo.cpp diff --git a/src/gyro.cpp b/src/gyro.cpp deleted file mode 100644 index 1a81850..0000000 --- a/src/gyro.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "Arduino.h" -#include "Wire.h" -#include "sensor.hpp" - -Sensor sensor(0x68, &Wire); - -void setup() -{ - Serial.begin(9600); - - // Wait for Serial because the Arduino Leonardo is weird - while (!Serial) {} - - while (!sensor.begin()) - { - Serial.print(millis()); - Serial.println("Error: Could not connect to the sensor. Retrying after 2000 milliseconds..."); - delay(2000); - } - sensor.setAccelSensitivity(2); // 8g - sensor.setGyroSensitivity(1); // 500 degrees/s - - sensor.setThrottleEnabled(true); - Serial.println("start..."); - - // Calibration values - sensor.accel_cal_x = 0.198; - sensor.accel_cal_y = -0.018; - sensor.gyro_cal_x = 0.780; - sensor.gyro_cal_y = -1.495; -} - -void loop() -{ - sensor.read(); - float pitch = sensor.getPitch(); - float roll = sensor.getRoll(); - - Serial.print("Pitch: "); - Serial.print(pitch, 3); - Serial.print(" Roll: "); - Serial.print(roll, 3); - Serial.println(); -} diff --git a/src/gyronardo.cpp b/src/gyronardo.cpp new file mode 100644 index 0000000..1a81850 --- /dev/null +++ b/src/gyronardo.cpp @@ -0,0 +1,44 @@ +#include "Arduino.h" +#include "Wire.h" +#include "sensor.hpp" + +Sensor sensor(0x68, &Wire); + +void setup() +{ + Serial.begin(9600); + + // Wait for Serial because the Arduino Leonardo is weird + while (!Serial) {} + + while (!sensor.begin()) + { + Serial.print(millis()); + Serial.println("Error: Could not connect to the sensor. Retrying after 2000 milliseconds..."); + delay(2000); + } + sensor.setAccelSensitivity(2); // 8g + sensor.setGyroSensitivity(1); // 500 degrees/s + + sensor.setThrottleEnabled(true); + Serial.println("start..."); + + // Calibration values + sensor.accel_cal_x = 0.198; + sensor.accel_cal_y = -0.018; + sensor.gyro_cal_x = 0.780; + sensor.gyro_cal_y = -1.495; +} + +void loop() +{ + sensor.read(); + float pitch = sensor.getPitch(); + float roll = sensor.getRoll(); + + Serial.print("Pitch: "); + Serial.print(pitch, 3); + Serial.print(" Roll: "); + Serial.print(roll, 3); + Serial.println(); +} -- cgit v1.2.3-18-g5258