Fixed crash bug in gyro.cpp
This commit is contained in:
parent
adc21b5527
commit
5b6ce7d672
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user