Skip to content

Commit

Permalink
AP_Notify: Bug fix hang for update_battery
Browse files Browse the repository at this point in the history
Fixed an issue where update_battery would cause a hang
  • Loading branch information
haydendonald committed Jan 23, 2024
1 parent 1ec61c5 commit 4ee81bc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions libraries/AP_Notify/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,16 +533,19 @@ void Display::update_ekf(uint8_t r)
void Display::update_battery(uint8_t r)
{
char msg [DISPLAY_MESSAGE_SIZE];
AP_BattMonitor &battery = AP::battery();
AP_BattMonitor *battery = AP_BattMonitor::get_singleton();
if (battery == nullptr) {
return;
}
uint8_t pct;
if (battery.capacity_remaining_pct(pct)) {
snprintf(msg, DISPLAY_MESSAGE_SIZE, "BAT:%4.2fV %2d%% ", (double)battery.voltage(), 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()) ;
snprintf(msg, DISPLAY_MESSAGE_SIZE, "BAT:%4.2fV --%% ", (double)battery->voltage()) ;
}
draw_text(COLUMN(0), ROW(r), msg);
}

void Display::update_mode(uint8_t r)
{
char msg [DISPLAY_MESSAGE_SIZE];
Expand Down

0 comments on commit 4ee81bc

Please sign in to comment.