diff options
Diffstat (limited to 'src/gyro.cpp')
-rw-r--r-- | src/gyro.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/gyro.cpp b/src/gyro.cpp index 668cef1..1a81850 100644 --- a/src/gyro.cpp +++ b/src/gyro.cpp @@ -1,7 +1,8 @@ #include "Arduino.h" -#include "GY521.h" +#include "Wire.h" +#include "sensor.hpp" -GY521 sensor(0x68); +Sensor sensor(0x68, &Wire); void setup() { @@ -10,26 +11,23 @@ void setup() // Wait for Serial because the Arduino Leonardo is weird while (!Serial) {} - Wire.begin(); - - delay(100); - while (!sensor.wakeup()) + while (!sensor.begin()) { Serial.print(millis()); - Serial.println("Error: Could not connect to the GY521 sensor. Retrying after 2000 milliseconds..."); + 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.setThrottle(); + sensor.setThrottleEnabled(true); Serial.println("start..."); // Calibration values - sensor.axe = 0.198; - sensor.aye = -0.018; - sensor.gxe = 0.780; - sensor.gye = -1.495; + 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() |