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)
{
switch (osdConfig()->units) {
@ -226,6 +227,7 @@ static char osdGetTemperatureSymbolForSelectedUnit(void)
return 'C';
}
}
#endif
static void osdFormatAltitudeString(char * buff, int altitude, bool pad)
{
@ -760,7 +762,7 @@ static bool osdDrawSingleElement(uint8_t item)
#ifdef USE_ESC_SENSOR
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;
case OSD_ESC_RPM:
@ -782,7 +784,7 @@ static bool osdDrawSingleElement(uint8_t item)
#ifdef USE_ADC_INTERNAL
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;
#endif

View File

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