AP_Notify: update to use capacity_remaining_pct() as a bool

This commit is contained in:
Willian Galvani 2020-04-23 13:18:22 -03:00
parent 206d047ab1
commit 20779ba47c
1 changed files with 6 additions and 2 deletions

View File

@ -526,8 +526,12 @@ void Display::update_battery(uint8_t r)
{
char msg [DISPLAY_MESSAGE_SIZE];
AP_BattMonitor &battery = AP::battery();
uint8_t pct = battery.capacity_remaining_pct();
snprintf(msg, DISPLAY_MESSAGE_SIZE, "BAT:%4.2fV %2d%% ", (double)battery.voltage(), pct) ;
uint8_t pct;
if (battery.capacity_remaining_pct(pct)) {
snprintf(msg, DISPLAY_MESSAGE_SIZE, "BAT:%4.2fV %2d%% ", (double)battery.voltage(), pct) ;
} else {
snprintf(msg, DISPLAY_MESSAGE_SIZE, "BAT:%4.2fV --%% ", (double)battery.voltage()) ;
}
draw_text(COLUMN(0), ROW(r), msg);
}