From d93b50205a43436b95098e8579e2bae927e87d07 Mon Sep 17 00:00:00 2001 From: "Such Meme, Many Skill" Date: Tue, 3 Mar 2020 15:19:42 +0100 Subject: [PATCH] Add battery indicator --- source/tegraexplorer/gfx.c | 15 ++++++++++++++- source/tegraexplorer/gfx.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/source/tegraexplorer/gfx.c b/source/tegraexplorer/gfx.c index 0f6394c..a3272a2 100644 --- a/source/tegraexplorer/gfx.c +++ b/source/tegraexplorer/gfx.c @@ -8,6 +8,7 @@ #include "gfx.h" #include "fs.h" #include "../mem/minerva.h" +#include "../power/max17050.h" #include const char fixedoptions[3][50] = { @@ -24,10 +25,22 @@ const char sizevalues[4][3] = { }; void clearscreen(){ + int battery = 0; + max17050_get_property(MAX17050_RepSOC, &battery); + gfx_clear_grey(0x1B); + SWAPCOLOR(COLOR_DEFAULT); + SWAPBGCOLOR(COLOR_WHITE); + + gfx_box(0, 1263, 719, 1279, COLOR_WHITE); + gfx_con_setpos(0, 1263); + gfx_printf("Move: Vol+/- | Select: Pow | Battery: %3d%%", battery >> 8); + gfx_box(0, 0, 719, 15, COLOR_WHITE); gfx_con_setpos(0, 0); - gfx_printf("%k%KTegraexplorer v1.3.1%k%K\n", COLOR_DEFAULT, COLOR_WHITE, COLOR_WHITE, COLOR_DEFAULT); + gfx_printf("Tegraexplorer v1.3.1\n"); + + RESETCOLOR; } int message(u32 color, const char* message, ...){ diff --git a/source/tegraexplorer/gfx.h b/source/tegraexplorer/gfx.h index 1692323..c2e6ff7 100644 --- a/source/tegraexplorer/gfx.h +++ b/source/tegraexplorer/gfx.h @@ -3,6 +3,7 @@ #include "fs.h" #define SWAPCOLOR(color) gfx_printf("%k", color) +#define SWAPBGCOLOR(color) gfx_printf("%K", color) #define RESETCOLOR gfx_printf("%k%K", COLOR_WHITE, COLOR_DEFAULT) int makemenu(menu_item menu[], int menuamount);