Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/boards/shields/nice_view/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ config NICE_VIEW_WIDGET_STATUS
config NICE_VIEW_WIDGET_INVERTED
bool "Invert custom status widget colors"

config NICE_VIEW_WIDGET_BATTERY_SHOW_PERCENTAGE
bool "Show battery percentage in status widget"

if !ZMK_SPLIT || ZMK_SPLIT_ROLE_CENTRAL

config NICE_VIEW_WIDGET_STATUS
Expand Down
11 changes: 11 additions & 0 deletions app/boards/shields/nice_view/widgets/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ void draw_battery(lv_obj_t *canvas, const struct status_state *state) {

lv_canvas_draw_rect(canvas, 0, 2, 29, 12, &rect_white_dsc);
lv_canvas_draw_rect(canvas, 1, 3, 27, 10, &rect_black_dsc);

#if CONFIG_NICE_VIEW_WIDGET_BATTERY_SHOW_PERCENTAGE
lv_draw_label_dsc_t label_dsc_battery;
init_label_dsc(&label_dsc_battery, LVGL_FOREGROUND, &lv_font_unscii_8, LV_TEXT_ALIGN_RIGHT);

char battery_text[6] = {};
snprintf(battery_text, sizeof(battery_text), "%d", state->battery);
lv_canvas_draw_text(canvas, 2, 4, 24, &label_dsc_battery, battery_text);
#else
lv_canvas_draw_rect(canvas, 2, 4, (state->battery + 2) / 4, 8, &rect_white_dsc);
#endif

lv_canvas_draw_rect(canvas, 30, 5, 3, 6, &rect_white_dsc);
lv_canvas_draw_rect(canvas, 31, 6, 1, 4, &rect_black_dsc);

Expand Down