Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add battery icon to powerbutton menu #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion components/smsplus-esp32/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ COMPONENTS_EXTRA_CLEAN := graphics.inc graphics.rgba
menu.o: graphics.inc

graphics.inc: $(COMPONENT_PATH)/graphics.xcf
convert $^ -background none -layers flatten -crop 80x316+0+0 graphics.rgba
convert $^ -background none -layers flatten -crop 80x324+0+0 graphics.rgba
cat graphics.rgba | xxd -i > graphics.inc
Binary file modified components/smsplus-esp32/graphics.xcf
Binary file not shown.
14 changes: 14 additions & 0 deletions components/smsplus-esp32/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,20 @@ int menuShow() {
if (v>255) v=255;
renderGfx(overlay, 14, 25+16, 14, 193, (v*60)/256, 4);
}

// draw empty battery cell
renderGfx(overlay, KC_SCREEN_W-16, 0, 0, 316, 16, 7);

// fill in the battery with appropriate color
int batPct = kchal_get_bat_pct();
if (batPct < 20) renderGfx(overlay, KC_SCREEN_W-15, 1, 17, 317, (batPct*12)/100, 5);
else if (batPct < 50) renderGfx(overlay, KC_SCREEN_W-15, 1, 33, 317, (batPct*12)/100, 5);
else renderGfx(overlay, KC_SCREEN_W-15, 1, 49, 317, (batPct*12)/100, 5);

// add lightning bolt icon if applicable
if (kchal_get_chg_status() > 0) {
renderGfx(overlay, KC_SCREEN_W-11, 0, 64, 316, 6, 8);
}

if (doRefresh) {
vidRenderOverlay();
Expand Down