feat(nice_view): Show big battery percentage instead of WPM widget
This commit is contained in:
parent
300e1d2630
commit
3987236c09
4 changed files with 18 additions and 0 deletions
|
@ -36,6 +36,10 @@ config NICE_VIEW_WIDGET_STATUS
|
|||
config NICE_VIEW_BATTERY_SHOW_PERCENTAGE
|
||||
bool "Show battery percentage instead of icon"
|
||||
|
||||
config NICE_VIEW_BATTERY_SHOW_BIG_PERCENTAGE
|
||||
bool "Show battery percentage instead of WPM widget"
|
||||
select LV_FONT_MONTSERRAT_26
|
||||
|
||||
config NICE_VIEW_WIDGET_INVERTED
|
||||
bool "Invert custom status widget colors"
|
||||
|
||||
|
|
|
@ -116,7 +116,11 @@ int zmk_widget_status_init(struct zmk_widget_status *widget, lv_obj_t *parent) {
|
|||
lv_obj_t *art = lv_img_create(widget->obj);
|
||||
bool random = sys_rand32_get() & 1;
|
||||
lv_img_set_src(art, random ? &balloon : &mountain);
|
||||
#if IS_ENABLED(CONFIG_NICE_VIEW_BATTERY_SHOW_BIG_PERCENTAGE)
|
||||
lv_obj_align(art, LV_ALIGN_TOP_LEFT, -48, 0);
|
||||
#else
|
||||
lv_obj_align(art, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||
#endif
|
||||
|
||||
sys_slist_append(&widgets, &widget->node);
|
||||
widget_battery_status_init();
|
||||
|
|
|
@ -86,6 +86,7 @@ static void draw_top(lv_obj_t *widget, lv_color_t cbuf[], const struct status_st
|
|||
|
||||
lv_canvas_draw_text(canvas, 0, 0, CANVAS_SIZE, &label_dsc, output_text);
|
||||
|
||||
#if !IS_ENABLED(CONFIG_NICE_VIEW_BATTERY_SHOW_BIG_PERCENTAGE)
|
||||
// Draw WPM
|
||||
lv_canvas_draw_rect(canvas, 0, 21, 68, 42, &rect_white_dsc);
|
||||
lv_canvas_draw_rect(canvas, 1, 22, 66, 40, &rect_black_dsc);
|
||||
|
@ -117,6 +118,7 @@ static void draw_top(lv_obj_t *widget, lv_color_t cbuf[], const struct status_st
|
|||
points[i].y = 60 - (state->wpm[i] - min) * 36 / range;
|
||||
}
|
||||
lv_canvas_draw_line(canvas, points, 10, &line_dsc);
|
||||
#endif
|
||||
|
||||
// Rotate canvas
|
||||
rotate_canvas(canvas, cbuf);
|
||||
|
|
|
@ -30,6 +30,14 @@ void draw_battery(lv_obj_t *canvas, const struct status_state *state) {
|
|||
lv_draw_rect_dsc_t rect_white_dsc;
|
||||
init_rect_dsc(&rect_white_dsc, LVGL_FOREGROUND);
|
||||
|
||||
#if IS_ENABLED(CONFIG_NICE_VIEW_BATTERY_SHOW_BIG_PERCENTAGE)
|
||||
char big_text[4] = {};
|
||||
sprintf(big_text, "%i%%", state->battery);
|
||||
lv_draw_label_dsc_t big_label_dsc;
|
||||
init_label_dsc(&big_label_dsc, LVGL_FOREGROUND, &lv_font_montserrat_26, LV_TEXT_ALIGN_CENTER);
|
||||
lv_canvas_draw_text(canvas, 0, 25, 68, &big_label_dsc, big_text);
|
||||
#endif
|
||||
|
||||
#if IS_ENABLED(CONFIG_NICE_VIEW_BATTERY_SHOW_PERCENTAGE)
|
||||
char text[4] = {};
|
||||
sprintf(text, "%i%%", state->battery);
|
||||
|
|
Loading…
Add table
Reference in a new issue