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

Merge pull request #4116 from DanNixon/osd_power_formatting

OSD power formatting
This commit is contained in:
Martin Budden 2017-09-10 17:25:32 +01:00 committed by GitHub
commit 9b0e0a4f20
2 changed files with 63 additions and 1 deletions

View file

@ -604,6 +604,68 @@ TEST(OsdTest, TestElementMahDrawn)
displayPortTestBufferSubstring(1, 11, "1042%c", SYM_MAH);
}
/*
* Tests the instantaneous electrical power OSD element.
*/
TEST(OsdTest, TestElementPower)
{
// given
osdConfigMutable()->item_pos[OSD_POWER] = OSD_POS(1, 10) | VISIBLE_FLAG;
// and
simulationBatteryVoltage = 100; // 10V
// and
simulationBatteryAmperage = 0; // 0A
// when
displayClearScreen(&testDisplayPort);
osdRefresh(simulationTime);
// then
displayPortTestBufferSubstring(1, 10, " 0W");
// given
simulationBatteryAmperage = 10; // 0.1A
// when
displayClearScreen(&testDisplayPort);
osdRefresh(simulationTime);
// then
displayPortTestBufferSubstring(1, 10, " 1W");
// given
simulationBatteryAmperage = 120; // 1.2A
// when
displayClearScreen(&testDisplayPort);
osdRefresh(simulationTime);
// then
displayPortTestBufferSubstring(1, 10, " 12W");
// given
simulationBatteryAmperage = 1230; // 12.3A
// when
displayClearScreen(&testDisplayPort);
osdRefresh(simulationTime);
// then
displayPortTestBufferSubstring(1, 10, " 123W");
// given
simulationBatteryAmperage = 12340; // 123.4A
// when
displayClearScreen(&testDisplayPort);
osdRefresh(simulationTime);
// then
displayPortTestBufferSubstring(1, 10, "1234W");
}
/*
* Tests the altitude OSD element.
*/