Skip to content

Commit a5fb748

Browse files
committed
Precommit and gyro temp fix
1 parent 823fa65 commit a5fb748

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/gyro.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ GyroType GyroSensor::detectGyro() {
5858
if (MPU6050Gyro::isDeviceDetected(addr)) {
5959
Log.notice(F("GYRO: MPU6050 detected." CR));
6060
return GyroType::GYRO_MPU6050;
61-
}
62-
63-
else if (ICM42670pGyro::isDeviceDetected(addr)) {
61+
} else if (ICM42670pGyro::isDeviceDetected(addr)) {
6462
Log.notice(F("GYRO: ICM42670P detected." CR));
6563
return GyroType::GYRO_ICM42670P;
6664
}
@@ -108,16 +106,18 @@ bool GyroSensor::setup(GyroMode mode, bool force) {
108106
Log.notice(F("GYRO: Using ICM42670-p %x." CR), myRtcGyroData.Address);
109107
_impl.reset(new ICM42670pGyro(myRtcGyroData.Address, _gyroConfig));
110108
_currentMode = GyroMode::GYRO_RUN;
111-
} else
112-
#endif
113-
if (ICM42670pGyro::isDeviceDetected(addr)) {
109+
} else if (ICM42670pGyro::isDeviceDetected(addr)) {
114110
Log.notice(F("GYRO: Detected ICM42670-p %x." CR), addr);
115111
_impl.reset(new ICM42670pGyro(addr, _gyroConfig));
116-
#if defined(ESP32) && defined(ENABLE_RTCMEM)
117112
myRtcGyroData = {.Address = addr,
118113
.IsDataAvailable = GYRO_RTC_DATA_AVAILABLE};
119-
#endif
120114
}
115+
#else
116+
if (ICM42670pGyro::isDeviceDetected(addr)) {
117+
Log.notice(F("GYRO: Detected ICM42670-p %x." CR), addr);
118+
_impl.reset(new ICM42670pGyro(addr, _gyroConfig));
119+
}
120+
#endif
121121
} break;
122122
}
123123
}
@@ -151,7 +151,8 @@ bool GyroSensor::read() {
151151
_angle = SIMULATE_ANGLE;
152152
#endif
153153

154-
if (_initialSensorTemp == NAN) {
154+
if (isnan(_initialSensorTemp)) {
155+
Log.notice(F("GYRO: Assigning initial gyro temperature %F." CR), resultData.temp);
155156
_initialSensorTemp = resultData.temp;
156157
}
157158
#if defined(ESP32) && defined(ENABLE_RTCMEM)

0 commit comments

Comments
 (0)