mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 00:35:34 +03:00
refactor and add getCurrentTemperature()
This commit is contained in:
parent
d06144989b
commit
f40b209feb
2 changed files with 8 additions and 10 deletions
|
@ -32,29 +32,29 @@
|
||||||
#include "sensors/gyro.h"
|
#include "sensors/gyro.h"
|
||||||
#include "sensors/barometer.h"
|
#include "sensors/barometer.h"
|
||||||
|
|
||||||
static bool tempSensorValid[TEMP_COUNT];
|
|
||||||
static int16_t tempSensorValue[TEMP_COUNT];
|
static int16_t tempSensorValue[TEMP_COUNT];
|
||||||
|
static tempSensor_e tempSensorValid;
|
||||||
bool isTemperatureSensorValid(tempSensor_e sensor)
|
|
||||||
{
|
|
||||||
return tempSensorValid[sensor];
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t getTemperature(tempSensor_e sensor)
|
int16_t getTemperature(tempSensor_e sensor)
|
||||||
{
|
{
|
||||||
return tempSensorValue[sensor];
|
return tempSensorValue[sensor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t getCurrentTemperature(void)
|
||||||
|
{
|
||||||
|
return tempSensorValue[tempSensorValid];
|
||||||
|
}
|
||||||
|
|
||||||
void temperatureUpdate(void)
|
void temperatureUpdate(void)
|
||||||
{
|
{
|
||||||
// TEMP_GYRO: Update gyro temperature in decidegrees
|
// TEMP_GYRO: Update gyro temperature in decidegrees
|
||||||
if (gyroReadTemperature()) {
|
if (gyroReadTemperature()) {
|
||||||
tempSensorValid[TEMP_GYRO] = true;
|
|
||||||
tempSensorValue[TEMP_GYRO] = gyroGetTemperature();
|
tempSensorValue[TEMP_GYRO] = gyroGetTemperature();
|
||||||
|
tempSensorValid=TEMP_GYRO;
|
||||||
}
|
}
|
||||||
// TEMP_BARO: Update baro temperature in decidegrees
|
// TEMP_BARO: Update baro temperature in decidegrees
|
||||||
if(sensors(SENSOR_BARO)){
|
if(sensors(SENSOR_BARO)){
|
||||||
tempSensorValid[TEMP_BARO] = true;
|
|
||||||
tempSensorValue[TEMP_BARO] = baroGetTemperature();
|
tempSensorValue[TEMP_BARO] = baroGetTemperature();
|
||||||
|
tempSensorValid=TEMP_BARO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,5 @@ typedef enum {
|
||||||
} tempSensor_e;
|
} tempSensor_e;
|
||||||
|
|
||||||
// Temperature is returned in degC*10
|
// Temperature is returned in degC*10
|
||||||
|
|
||||||
bool isTemperatureSensorValid(tempSensor_e sensor);
|
|
||||||
int16_t getTemperature(tempSensor_e sensor);
|
int16_t getTemperature(tempSensor_e sensor);
|
||||||
void temperatureUpdate(void);
|
void temperatureUpdate(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue