Skip to content

Commit

Permalink
sensors: Allow for difference in temperature readings across sensors
Browse files Browse the repository at this point in the history
We need to track the temperature change in each sensor instance individually when using it as basis for publication.
  • Loading branch information
priseborough authored and LorenzMeier committed Jan 21, 2017
1 parent 1beb291 commit 1d66d4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/modules/sensors/temperature_compensation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/modules/sensors/temperature_compensation.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ class TemperatureCompensation
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;
Expand Down

0 comments on commit 1d66d4b

Please sign in to comment.