Skip to content

Commit

Permalink
Fix invalid references
Browse files Browse the repository at this point in the history
Recently, battery state changed events with an invalid source have been reported. This prevents the exception that would be thrown.
  • Loading branch information
englmaxi committed Sep 13, 2024
1 parent 18fc428 commit c59c18e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions boards/shields/dongle_display/widgets/battery_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ static void draw_battery(lv_obj_t *canvas, uint8_t level, bool usb_present) {
}

static void set_battery_symbol(lv_obj_t *widget, struct battery_state state) {
if (state.source >= ZMK_SPLIT_BLE_PERIPHERAL_COUNT + SOURCE_OFFSET) {
return;
}
LOG_DBG("source: %d, level: %d, usb: %d", state.source, state.level, state.usb_present);
lv_obj_t *symbol = lv_obj_get_child(widget, state.source * 2);
lv_obj_t *label = lv_obj_get_child(widget, state.source * 2 + 1);
Expand Down

0 comments on commit c59c18e

Please sign in to comment.