Fix calling of IMU/MAG data when no new data available
This commit is contained in:
@@ -142,8 +142,10 @@ class IMU : public SensorBase<IMUAnglesMsg> {
|
|||||||
#ifndef ICM20948_GET_AGMT_UPDATED_ONCE_PER_LOOP
|
#ifndef ICM20948_GET_AGMT_UPDATED_ONCE_PER_LOOP
|
||||||
#define ICM20948_GET_AGMT_UPDATED_ONCE_PER_LOOP
|
#define ICM20948_GET_AGMT_UPDATED_ONCE_PER_LOOP
|
||||||
if (_imu->dataReady())
|
if (_imu->dataReady())
|
||||||
{
|
{
|
||||||
_imu->getAGMT();
|
_imu->getAGMT();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
_msg.rpy[0] = _imu->accX();
|
_msg.rpy[0] = _imu->accX();
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ class Magnetometer : public SensorBase<MagnetometerMsg> {
|
|||||||
if (_imu->dataReady())
|
if (_imu->dataReady())
|
||||||
{
|
{
|
||||||
_imu->getAGMT();
|
_imu->getAGMT();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
_msg.rpy[0] = _mag->magX();
|
_msg.rpy[0] = _mag->magX();
|
||||||
|
|||||||
@@ -56,8 +56,14 @@ void Peripherals::begin() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void Peripherals::update() {
|
void Peripherals::update() {
|
||||||
CALLS_PER_SECOND_TIMED_CALL(Peripherals_update, read_imu, readImu());
|
bool res = true;
|
||||||
CALLS_PER_SECOND_TIMED_CALL(Peripherals_update, read_mag, readMag());
|
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_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_bmp, EXECUTE_EVERY_N_MS(500, { readBMP(); }) );
|
||||||
CALLS_PER_SECOND_TIMED_CALL(Peripherals_update, read_sonar, EXECUTE_EVERY_N_MS(500, { readSonar(); }) );
|
CALLS_PER_SECOND_TIMED_CALL(Peripherals_update, read_sonar, EXECUTE_EVERY_N_MS(500, { readSonar(); }) );
|
||||||
|
|||||||
Reference in New Issue
Block a user