From 981e5435eaa0b5a8fc4c1b4ff8b54332b08d447e Mon Sep 17 00:00:00 2001 From: suchmememanyskill Date: Fri, 8 Jan 2021 19:32:06 +0100 Subject: [PATCH] Add charging icon --- source/gfx/gfx.c | 5 +++-- source/gfx/gfxutils.c | 20 ++++++++++++++------ source/gfx/gfxutils.h | 3 ++- source/gfx/menu.c | 4 +++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/source/gfx/gfx.c b/source/gfx/gfx.c index d7a1ef7..a6bce34 100644 --- a/source/gfx/gfx.c +++ b/source/gfx/gfx.c @@ -121,6 +121,7 @@ static const u8 _gfx_font[] = { 0x00, 0x00, 0x00, 0x4C, 0x32, 0x00, 0x00, 0x00, // Char 126 (~) 0x00, 0x0C, 0x12, 0x7E, 0x42, 0x42, 0x7E, 0x00, // Char 127 (folder) 0x00, 0x0E, 0x12, 0x22, 0x22, 0x22, 0x3E, 0x00, // Char 128 (file) + 0x00, 0x08, 0x0C, 0x0E, 0x7E, 0x70, 0x30, 0x10, // Char 129 (Charging) }; u32 YLeftConfig = YLEFT; @@ -188,7 +189,7 @@ void gfx_putc(char c) switch (gfx_con.fntsz) { case 16: - if (c >= 32 && c <= 128) + if (c >= 32 && c <= 129) { u8 *cbuf = (u8 *)&_gfx_font[8 * (c - 32)]; u32 *fb = gfx_ctxt.fb + gfx_con.x + gfx_con.y * gfx_ctxt.stride; @@ -265,7 +266,7 @@ void gfx_putc(char c) break; case 8: default: - if (c >= 30 && c <= 126) + if (c >= 30 && c <= 129) { u8 *cbuf = (u8 *)&_gfx_font[8 * (c - 32)]; u32 *fb = gfx_ctxt.fb + gfx_con.x + gfx_con.y * gfx_ctxt.stride; diff --git a/source/gfx/gfxutils.c b/source/gfx/gfxutils.c index ed5fdeb..413ce63 100644 --- a/source/gfx/gfxutils.c +++ b/source/gfx/gfxutils.c @@ -1,22 +1,30 @@ #include "gfx.h" #include "gfxutils.h" #include +#include +#include #include "../hid/hid.h" -void gfx_clearscreen(){ +void gfx_printTopInfo() { int battery = 0; max17050_get_property(MAX17050_RepSOC, &battery); - //gfx_clear_grey(0x1B); - gfx_boxGrey(0, 16, 1279, 703, 0x1b); + int current_charge_status = 0; + bq24193_get_property(BQ24193_ChargeStatus, ¤t_charge_status); SETCOLOR(COLOR_DEFAULT, COLOR_WHITE); + gfx_con_setpos(0, 0); + gfx_printf("Tegraexplorer %d.%d.%d | Battery: %d%% %c\n", LP_VER_MJ, LP_VER_MN, LP_VER_BF, battery >> 8, ((current_charge_status) ? 129 : 32)); + RESETCOLOR; +} + +void gfx_clearscreen(){ + gfx_boxGrey(0, 16, 1279, 703, 0x1b); gfx_boxGrey(0, 703, 1279, 719, 0xFF); gfx_boxGrey(0, 0, 1279, 15, 0xFF); - gfx_con_setpos(0, 0); - gfx_printf("Tegraexplorer %d.%d.%d | Battery: %3d%%\n", LP_VER_MJ, LP_VER_MN, LP_VER_BF, battery >> 8); - RESETCOLOR; + + gfx_printTopInfo(); } MenuEntry_t YesNoEntries[] = { diff --git a/source/gfx/gfxutils.h b/source/gfx/gfxutils.h index 6ed4ed8..20001f3 100644 --- a/source/gfx/gfxutils.h +++ b/source/gfx/gfxutils.h @@ -15,4 +15,5 @@ void gfx_clearscreen(); int MakeHorizontalMenu(MenuEntry_t *entries, int len, int spacesBetween, u32 bg, int startPos); -int MakeYesNoHorzMenu(int spacesBetween, u32 bg); \ No newline at end of file +int MakeYesNoHorzMenu(int spacesBetween, u32 bg); +void gfx_printTopInfo(); \ No newline at end of file diff --git a/source/gfx/menu.c b/source/gfx/menu.c index 83d5a2c..4514cea 100644 --- a/source/gfx/menu.c +++ b/source/gfx/menu.c @@ -160,8 +160,10 @@ int newMenu(Vector_t* vec, int startIndex, int screenLenX, int screenLenY, u8 op break; } } - else + else { holdTimer = 300; + gfx_printTopInfo(); + } } lastPress = get_tmr_ms();