Fix calling of IMU/MAG data when no new data available

This commit is contained in:
Niklas Jensen
2025-12-26 22:52:06 +01:00
parent da87d12588
commit d1c2e5f447
3 changed files with 13 additions and 3 deletions
+8 -2
View File
@@ -56,8 +56,14 @@ void Peripherals::begin() {
};
void Peripherals::update() {
CALLS_PER_SECOND_TIMED_CALL(Peripherals_update, read_imu, readImu());
CALLS_PER_SECOND_TIMED_CALL(Peripherals_update, read_mag, readMag());
bool res = true;
CALLS_PER_SECOND_TIMED_CALL(Peripherals_update, read_imu, res = readImu());
#ifdef FT_ENABLED(USE_ICM20948)
// IF ICM_20948 fails to get IMU, it means that mag also does not have new data
CALLS_PER_SECOND_TIMED_CALL(Peripherals_update, read_mag, if (res) { res = readMag(); } );
#else
CALLS_PER_SECOND_TIMED_CALL(Peripherals_update, read_mag, res = readMag());
#endif
CALLS_PER_SECOND_TIMED_CALL(Peripherals_update, read_gesture, EXECUTE_EVERY_N_MS(100, { readGesture(); }) );
CALLS_PER_SECOND_TIMED_CALL(Peripherals_update, read_bmp, EXECUTE_EVERY_N_MS(500, { readBMP(); }) );
CALLS_PER_SECOND_TIMED_CALL(Peripherals_update, read_sonar, EXECUTE_EVERY_N_MS(500, { readSonar(); }) );