1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-23 08:15:26 +03:00

refactor and add getCurrentTemperature()

This commit is contained in:
giacomo892 2018-11-02 21:29:36 +01:00
parent d06144989b
commit f40b209feb
2 changed files with 8 additions and 10 deletions

View file

@ -32,29 +32,29 @@
#include "sensors/gyro.h"
#include "sensors/barometer.h"
static bool tempSensorValid[TEMP_COUNT];
static int16_t tempSensorValue[TEMP_COUNT];
bool isTemperatureSensorValid(tempSensor_e sensor)
{
return tempSensorValid[sensor];
}
static tempSensor_e tempSensorValid;
int16_t getTemperature(tempSensor_e sensor)
{
return tempSensorValue[sensor];
}
int16_t getCurrentTemperature(void)
{
return tempSensorValue[tempSensorValid];
}
void temperatureUpdate(void)
{
// TEMP_GYRO: Update gyro temperature in decidegrees
if (gyroReadTemperature()) {
tempSensorValid[TEMP_GYRO] = true;
tempSensorValue[TEMP_GYRO] = gyroGetTemperature();
tempSensorValid=TEMP_GYRO;
}
// TEMP_BARO: Update baro temperature in decidegrees
if(sensors(SENSOR_BARO)){
tempSensorValid[TEMP_BARO] = true;
tempSensorValue[TEMP_BARO] = baroGetTemperature();
tempSensorValid=TEMP_BARO;
}
}

View file

@ -26,7 +26,5 @@ typedef enum {
} tempSensor_e;
// Temperature is returned in degC*10
bool isTemperatureSensorValid(tempSensor_e sensor);
int16_t getTemperature(tempSensor_e sensor);
void temperatureUpdate(void);