mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 00:35:39 +03:00
OSD temperature display and calculations cleanup
Remove unnecessary decidegrees conversions as all temperature providers are in degrees celcius. Fixed rounding for imperial units. Fixed data type error in core temp warning element. Temperature is captured as int16 and can be negative but logic was using uint8 leading to an underflow for negative temperatures and a false alarm triggering.
This commit is contained in:
parent
7b8fefabb6
commit
b31b2d0680
2 changed files with 16 additions and 12 deletions
|
@ -58,7 +58,7 @@ extern "C" {
|
|||
void osdRefresh(timeUs_t currentTimeUs);
|
||||
void osdFormatTime(char * buff, osd_timer_precision_e precision, timeUs_t time);
|
||||
void osdFormatTimer(char *buff, bool showSymbol, int timerIndex);
|
||||
int osdConvertTemperatureToSelectedUnit(int tempInDeciDegrees);
|
||||
int osdConvertTemperatureToSelectedUnit(int tempInDegreesCelcius);
|
||||
|
||||
uint16_t rssi;
|
||||
attitudeEulerAngles_t attitude;
|
||||
|
@ -941,11 +941,15 @@ TEST(OsdTest, TestConvertTemperatureUnits)
|
|||
{
|
||||
/* In Celsius */
|
||||
osdConfigMutable()->units = OSD_UNIT_METRIC;
|
||||
EXPECT_EQ(osdConvertTemperatureToSelectedUnit(330), 330);
|
||||
EXPECT_EQ(osdConvertTemperatureToSelectedUnit(40), 40);
|
||||
|
||||
/* In Fahrenheit */
|
||||
osdConfigMutable()->units = OSD_UNIT_IMPERIAL;
|
||||
EXPECT_EQ(osdConvertTemperatureToSelectedUnit(330), 914);
|
||||
EXPECT_EQ(osdConvertTemperatureToSelectedUnit(40), 104);
|
||||
|
||||
/* In Fahrenheit with rounding */
|
||||
osdConfigMutable()->units = OSD_UNIT_IMPERIAL;
|
||||
EXPECT_EQ(osdConvertTemperatureToSelectedUnit(41), 106);
|
||||
}
|
||||
|
||||
// STUBS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue