diff --git a/src/modules/sensors/temperature_compensation.cpp b/src/modules/sensors/temperature_compensation.cpp index 2a07bdefc6..58d2b2dd5b 100644 --- a/src/modules/sensors/temperature_compensation.cpp +++ b/src/modules/sensors/temperature_compensation.cpp @@ -378,8 +378,8 @@ int TemperatureCompensation::apply_corrections_gyro(int topic_instance, math::Ve int8_t temperaturei = (int8_t)temperature; - if (temperaturei != _gyro_data.last_temperature) { - _gyro_data.last_temperature = temperaturei; + if (temperaturei != _gyro_data.last_temperature[topic_instance]) { + _gyro_data.last_temperature[topic_instance] = temperaturei; return 2; } @@ -409,8 +409,8 @@ int TemperatureCompensation::apply_corrections_accel(int topic_instance, math::V int8_t temperaturei = (int8_t)temperature; - if (temperaturei != _accel_data.last_temperature) { - _accel_data.last_temperature = temperaturei; + if (temperaturei != _accel_data.last_temperature[topic_instance]) { + _accel_data.last_temperature[topic_instance] = temperaturei; return 2; } @@ -438,8 +438,8 @@ int TemperatureCompensation::apply_corrections_baro(int topic_instance, float &s int8_t temperaturei = (int8_t)temperature; - if (temperaturei != _baro_data.last_temperature) { - _baro_data.last_temperature = temperaturei; + if (temperaturei != _baro_data.last_temperature[topic_instance]) { + _baro_data.last_temperature[topic_instance] = temperaturei; return 2; } diff --git a/src/modules/sensors/temperature_compensation.h b/src/modules/sensors/temperature_compensation.h index cfc9b586e4..9f2696a119 100644 --- a/src/modules/sensors/temperature_compensation.h +++ b/src/modules/sensors/temperature_compensation.h @@ -252,10 +252,10 @@ private: struct PerSensorData { PerSensorData() { - for (int i = 0; i < SENSOR_COUNT_MAX; ++i) { device_mapping[i] = 255; } + for (int i = 0; i < SENSOR_COUNT_MAX; ++i) { device_mapping[i] = 255; last_temperature[i] = -100; } } uint8_t device_mapping[SENSOR_COUNT_MAX]; /// map a topic instance to the parameters index - int8_t last_temperature = -100; + int8_t last_temperature[SENSOR_COUNT_MAX]; }; PerSensorData _gyro_data; PerSensorData _accel_data;