1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 22:35:23 +03:00

Add temperature conversion for ESC temp, tidy formatting

This commit is contained in:
Dan Nixon 2018-01-14 20:56:40 +00:00
parent 52d45ff72b
commit ed42d59c94
2 changed files with 7 additions and 5 deletions

View file

@ -207,6 +207,7 @@ static int32_t osdGetMetersToSelectedUnit(int32_t meters)
} }
} }
#if defined(USE_ADC_INTERNAL) || defined(USE_ESC_SENSOR)
STATIC_UNIT_TESTED int osdConvertTemperatureToSelectedUnit(int tempInDeciDegrees) STATIC_UNIT_TESTED int osdConvertTemperatureToSelectedUnit(int tempInDeciDegrees)
{ {
switch (osdConfig()->units) { switch (osdConfig()->units) {
@ -226,6 +227,7 @@ static char osdGetTemperatureSymbolForSelectedUnit(void)
return 'C'; return 'C';
} }
} }
#endif
static void osdFormatAltitudeString(char * buff, int altitude, bool pad) static void osdFormatAltitudeString(char * buff, int altitude, bool pad)
{ {
@ -760,7 +762,7 @@ static bool osdDrawSingleElement(uint8_t item)
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
case OSD_ESC_TMP: case OSD_ESC_TMP:
tfp_sprintf(buff, "%3d%c", escData == NULL ? 0 : escData->temperature, SYM_TEMP_C); tfp_sprintf(buff, "%3d%c", osdConvertTemperatureToSelectedUnit(escData->temperature * 10) / 10, osdGetTemperatureSymbolForSelectedUnit());
break; break;
case OSD_ESC_RPM: case OSD_ESC_RPM:
@ -782,7 +784,7 @@ static bool osdDrawSingleElement(uint8_t item)
#ifdef USE_ADC_INTERNAL #ifdef USE_ADC_INTERNAL
case OSD_CORE_TEMPERATURE: case OSD_CORE_TEMPERATURE:
tfp_sprintf(buff, "%02d%c", osdConvertTemperatureToSelectedUnit(getCoreTemperatureCelsius() * 10) / 10, osdGetTemperatureSymbolForSelectedUnit()); tfp_sprintf(buff, "%3d%c", osdConvertTemperatureToSelectedUnit(getCoreTemperatureCelsius() * 10) / 10, osdGetTemperatureSymbolForSelectedUnit());
break; break;
#endif #endif

View file

@ -765,7 +765,7 @@ TEST(OsdTest, TestElementCoreTemperature)
osdRefresh(simulationTime); osdRefresh(simulationTime);
// then // then
displayPortTestBufferSubstring(1, 8, "00C"); displayPortTestBufferSubstring(1, 8, " 0C");
// given // given
simulationCoreTemperature = 33; simulationCoreTemperature = 33;
@ -775,7 +775,7 @@ TEST(OsdTest, TestElementCoreTemperature)
osdRefresh(simulationTime); osdRefresh(simulationTime);
// then // then
displayPortTestBufferSubstring(1, 8, "33C"); displayPortTestBufferSubstring(1, 8, " 33C");
// given // given
osdConfigMutable()->units = OSD_UNIT_IMPERIAL; osdConfigMutable()->units = OSD_UNIT_IMPERIAL;
@ -785,7 +785,7 @@ TEST(OsdTest, TestElementCoreTemperature)
osdRefresh(simulationTime); osdRefresh(simulationTime);
// then // then
displayPortTestBufferSubstring(1, 8, "91F"); displayPortTestBufferSubstring(1, 8, " 91F");
} }
/* /*