Fixed crash bug in gyro.cpp

This commit is contained in:
Magnus Persson 2022-01-13 09:08:53 +01:00
parent adc21b5527
commit 5b6ce7d672
2 changed files with 3 additions and 3 deletions

View File

@ -25,6 +25,7 @@ SOFTWARE.
#include <helper.hpp>
GyroSensor myGyro;
MPU6050 accelgyro;
#define GYRO_USE_INTERRUPT // Use interrupt to detect when new sample is ready
#define SENSOR_MOVING_THREASHOLD 500
@ -45,7 +46,6 @@ bool GyroSensor::setup() {
Wire.begin(D3, D4);
Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having
// compilation difficulties
accelgyro.initialize();
if (!accelgyro.testConnection()) {
Log.error(F("GYRO: Failed to connect to MPU6050 (gyro)." CR));
@ -54,6 +54,7 @@ bool GyroSensor::setup() {
#if !defined(GYRO_DISABLE_LOGGING)
Log.notice(F("GYRO: Connected to MPU6050 (gyro)." CR));
#endif
accelgyro.initialize();
sensorConnected = true;
// Configure the sensor

View File

@ -50,7 +50,6 @@ struct RawGyroDataL { // Used for average multiple readings
class GyroSensor {
private:
MPU6050 accelgyro;
bool sensorConnected = false;
bool validValue = false;
float angle = 0;