mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +03:00
Merge pull request #4116 from DanNixon/osd_power_formatting
OSD power formatting
This commit is contained in:
commit
9b0e0a4f20
2 changed files with 63 additions and 1 deletions
|
@ -572,7 +572,7 @@ static void osdDrawSingleElement(uint8_t item)
|
||||||
}
|
}
|
||||||
|
|
||||||
case OSD_POWER:
|
case OSD_POWER:
|
||||||
tfp_sprintf(buff, "%dW", getAmperage() * getBatteryVoltage() / 1000);
|
tfp_sprintf(buff, "%4dW", getAmperage() * getBatteryVoltage() / 1000);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OSD_PIDRATE_PROFILE:
|
case OSD_PIDRATE_PROFILE:
|
||||||
|
|
|
@ -604,6 +604,68 @@ TEST(OsdTest, TestElementMahDrawn)
|
||||||
displayPortTestBufferSubstring(1, 11, "1042%c", SYM_MAH);
|
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.
|
* Tests the altitude OSD element.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue