mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-24 16:55:29 +03:00
Merge pull request #3978 from nmaggioni/osd_temperature
Gyro temperature element in OSD
This commit is contained in:
commit
f3b121f32c
3 changed files with 36 additions and 0 deletions
|
@ -245,6 +245,8 @@ static const OSD_Entry menuOsdElemsEntries[] =
|
|||
OSD_ELEMENT_ENTRY("WIND HOR", OSD_WIND_SPEED_HORIZONTAL),
|
||||
OSD_ELEMENT_ENTRY("WIND VERT", OSD_WIND_SPEED_VERTICAL),
|
||||
|
||||
OSD_ELEMENT_ENTRY("TEMPERATURE", OSD_TEMPERATURE),
|
||||
|
||||
OSD_BACK_ENTRY,
|
||||
OSD_END_ENTRY,
|
||||
};
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
#include "sensors/diagnostics.h"
|
||||
#include "sensors/sensors.h"
|
||||
#include "sensors/pitotmeter.h"
|
||||
#include "sensors/temperature.h"
|
||||
|
||||
#ifdef USE_HARDWARE_REVISION_DETECTION
|
||||
#include "hardware_revision.h"
|
||||
|
@ -484,6 +485,30 @@ static uint16_t osdConvertRSSI(void)
|
|||
return constrain(getRSSI() * 100 / RSSI_MAX_VALUE, 0, 99);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts temperature into a string based on the current unit system
|
||||
* postfixed with a symbol to indicate the unit used.
|
||||
* @param temperature Raw temperature (i.e. as taken from getCurrentTemperature() in degC)
|
||||
*/
|
||||
static void osdFormatTemperatureSymbol(char *buff, float temperature)
|
||||
{
|
||||
int units_symbol;
|
||||
switch ((osd_unit_e)osdConfig()->units) {
|
||||
case OSD_UNIT_IMPERIAL:
|
||||
units_symbol = SYM_TEMP_F;
|
||||
temperature = (temperature * (9.0f/5)) + 32;
|
||||
break;
|
||||
case OSD_UNIT_UK:
|
||||
FALLTHROUGH;
|
||||
case OSD_UNIT_METRIC:
|
||||
units_symbol = SYM_TEMP_C;
|
||||
break;
|
||||
}
|
||||
osdFormatCentiNumber(buff, (int32_t) (temperature * 100), 0, 0, 0, 3);
|
||||
buff[3] = units_symbol;
|
||||
buff[4] = '\0';
|
||||
}
|
||||
|
||||
static void osdFormatCoordinate(char *buff, char sym, int32_t val)
|
||||
{
|
||||
// up to 4 for number + 1 for the symbol + null terminator + fill the rest with decimals
|
||||
|
@ -2236,6 +2261,13 @@ static bool osdDrawSingleElement(uint8_t item)
|
|||
break;
|
||||
}
|
||||
|
||||
case OSD_TEMPERATURE:
|
||||
{
|
||||
int16_t temperature = getCurrentTemperature();
|
||||
osdFormatTemperatureSymbol(buff, temperature);
|
||||
break;
|
||||
}
|
||||
|
||||
case OSD_WIND_SPEED_HORIZONTAL:
|
||||
#ifdef USE_WIND_ESTIMATOR
|
||||
{
|
||||
|
@ -2452,6 +2484,7 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
|||
osdConfig->item_pos[0][OSD_MC_POS_XYZ_P_OUTPUTS] = OSD_POS(2, 12);
|
||||
|
||||
osdConfig->item_pos[0][OSD_POWER] = OSD_POS(15, 1);
|
||||
osdConfig->item_pos[0][OSD_TEMPERATURE] = OSD_POS(23, 2);
|
||||
|
||||
osdConfig->item_pos[0][OSD_AIR_SPEED] = OSD_POS(3, 5);
|
||||
osdConfig->item_pos[0][OSD_WIND_SPEED_HORIZONTAL] = OSD_POS(3, 6);
|
||||
|
|
|
@ -122,6 +122,7 @@ typedef enum {
|
|||
OSD_MC_VEL_Z_PID_OUTPUTS,
|
||||
OSD_MC_POS_XYZ_P_OUTPUTS,
|
||||
OSD_3D_SPEED,
|
||||
OSD_TEMPERATURE,
|
||||
OSD_ITEM_COUNT // MUST BE LAST
|
||||
} osd_items_e;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue