mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
Add BATT NOT FULL warning to OSD
Shows BATT NOT FULL when the connected battery has an everage cell voltage of less than 0.2v lower then vbatmaxcellvoltage (when the craft has yet to be armed) Intended as a reminder to make sure pilots fly with a fresh battery Adds an additional configuration option for the voltage at which a cell is "full"
This commit is contained in:
parent
27b146e274
commit
20f7c77089
5 changed files with 101 additions and 1 deletions
|
@ -648,6 +648,84 @@ TEST(OsdTest, TestElementAltitude)
|
|||
displayPortTestBufferSubstring(23, 7, " -2.4%c", SYM_M);
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests the battery notifications shown on the warnings OSD element.
|
||||
*/
|
||||
TEST(OsdTest, TestElementWarningsBattery)
|
||||
{
|
||||
// given
|
||||
osdConfigMutable()->item_pos[OSD_WARNINGS] = OSD_POS(9, 10) | VISIBLE_FLAG;
|
||||
|
||||
// and
|
||||
batteryConfigMutable()->vbatfullcellvoltage = 41;
|
||||
|
||||
// and
|
||||
// 4S battery
|
||||
simulationBatteryCellCount = 4;
|
||||
|
||||
// and
|
||||
// full battery
|
||||
simulationBatteryVoltage = 168;
|
||||
simulationBatteryState = BATTERY_OK;
|
||||
|
||||
// when
|
||||
displayClearScreen(&testDisplayPort);
|
||||
osdRefresh(simulationTime);
|
||||
|
||||
// then
|
||||
displayPortTestBufferSubstring(9, 10, " ");
|
||||
|
||||
// given
|
||||
// low battery
|
||||
simulationBatteryVoltage = 140;
|
||||
simulationBatteryState = BATTERY_WARNING;
|
||||
|
||||
// when
|
||||
displayClearScreen(&testDisplayPort);
|
||||
osdRefresh(simulationTime);
|
||||
|
||||
// then
|
||||
displayPortTestBufferSubstring(9, 10, "LOW BATTERY ");
|
||||
|
||||
// given
|
||||
// crtical battery
|
||||
simulationBatteryVoltage = 132;
|
||||
simulationBatteryState = BATTERY_CRITICAL;
|
||||
|
||||
// when
|
||||
displayClearScreen(&testDisplayPort);
|
||||
osdRefresh(simulationTime);
|
||||
|
||||
// then
|
||||
displayPortTestBufferSubstring(9, 10, " LAND NOW ");
|
||||
|
||||
// given
|
||||
// used battery
|
||||
simulationBatteryVoltage = ((batteryConfig()->vbatmaxcellvoltage - 2) * simulationBatteryCellCount) - 1;
|
||||
simulationBatteryState = BATTERY_OK;
|
||||
|
||||
// when
|
||||
displayClearScreen(&testDisplayPort);
|
||||
osdRefresh(simulationTime);
|
||||
|
||||
// then
|
||||
displayPortTestBufferSubstring(9, 10, "BATT NOT FULL");
|
||||
|
||||
// given
|
||||
// full battery
|
||||
simulationBatteryVoltage = ((batteryConfig()->vbatmaxcellvoltage - 2) * simulationBatteryCellCount);
|
||||
simulationBatteryState = BATTERY_OK;
|
||||
|
||||
// when
|
||||
displayClearScreen(&testDisplayPort);
|
||||
osdRefresh(simulationTime);
|
||||
|
||||
// then
|
||||
displayPortTestBufferSubstring(9, 10, " ");
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests the time string formatting function with a series of precision settings and time values.
|
||||
*/
|
||||
|
@ -744,6 +822,10 @@ extern "C" {
|
|||
return simulationBatteryVoltage;
|
||||
}
|
||||
|
||||
uint16_t getBatteryAverageCellVoltage() {
|
||||
return simulationBatteryVoltage / simulationBatteryCellCount;
|
||||
}
|
||||
|
||||
int32_t getAmperage() {
|
||||
return simulationBatteryAmperage;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue