From 7bc5e3caca511fd5b095c80a0b947fdb14458cf8 Mon Sep 17 00:00:00 2001 From: Rory Hayes Date: Wed, 11 Jul 2018 23:15:45 -0700 Subject: [PATCH 1/4] fix brief flash during keylock --- main/gui.c | 4 ++++ main/gui.h | 1 + main/main.c | 1 + 3 files changed, 6 insertions(+) diff --git a/main/gui.c b/main/gui.c index 744fdaa..7f996f7 100644 --- a/main/gui.c +++ b/main/gui.c @@ -63,6 +63,10 @@ void guiBatEmpty() { void guiInit() { kcugui_init(); + kcugui_flush(); +} + +void guiSplash() { uint8_t wifi_en=1; nvs_handle nvsHandle=NULL; esp_err_t r=nvs_open("8bkc", NVS_READONLY, &nvsHandle); diff --git a/main/gui.h b/main/gui.h index 49debd2..0359d95 100644 --- a/main/gui.h +++ b/main/gui.h @@ -7,6 +7,7 @@ void guiFull(); void guiBatEmpty(); void guiInit(); +void guiSplash(); void guiMenu(); diff --git a/main/main.c b/main/main.c index 00c62e1..38bf86e 100644 --- a/main/main.c +++ b/main/main.c @@ -291,6 +291,7 @@ int app_main(void) httpdInit(builtInUrls, 80); guiInit(); + guiSplash(); printf("\nReady\n"); From 84aa530b2d617fe7887c33111ecdbb1eb64ea2e2 Mon Sep 17 00:00:00 2001 From: Rory Hayes Date: Sat, 14 Jul 2018 00:10:32 -0700 Subject: [PATCH 2/4] first attempt at bat SOC display --- main/gui.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/main/gui.c b/main/gui.c index 684cc05..1c550a3 100644 --- a/main/gui.c +++ b/main/gui.c @@ -76,27 +76,40 @@ void guiSplash() { nvs_close(nvsHandle); UG_FontSelect(&FONT_6X8); + + char buf[32]; + int b = kchal_get_bat_pct(); + //int b = 100; + sprintf(buf, "%i", b); + + if (b < 20) UG_SetForecolor(C_RED); + else if (b < 50) UG_SetForecolor(C_GOLD); + else UG_SetForecolor(C_LAWN_GREEN); + + UG_PutString(KC_SCREEN_W-4-(7*strlen(buf)), 1, buf); + + UG_DrawFrame(KC_SCREEN_W-27, 0, KC_SCREEN_W-3, 8, C_WHITE); + UG_DrawFrame(KC_SCREEN_W-2, 2, KC_SCREEN_W-1, 6, C_WHITE); + if (wifi_en) { UG_SetForecolor(C_WHITE); - UG_PutString(0, 0, "WIFI AP"); + UG_PutString(0, 8, "WIFI AP"); UG_SetForecolor(C_YELLOW); - UG_PutString(0, 8, " pkspr"); + UG_PutString(0, 16, " pkspr"); UG_SetForecolor(C_WHITE); - UG_PutString(0, 16, "GO TO:"); + UG_PutString(0, 24, "GO TO:"); UG_SetForecolor(C_YELLOW); - UG_PutString(0, 24, "HTTP://192.168.4.1/"); + UG_PutString(0, 32, "HTTP://192.168.4.1/"); } else { UG_SetForecolor(C_WHITE); - UG_PutString(0, 0, " NOTE:"); + UG_PutString(0, 8, "NOTE: "); UG_SetForecolor(C_YELLOW); - UG_PutString(0, 8, "WiFi is off"); - UG_PutString(0, 16, "and can be "); - UG_PutString(0, 24, "enabled in "); - UG_PutString(0, 32, "the options"); - UG_PutString(0, 40, "menu. "); + UG_PutString(0, 16, "WiFi is off"); + UG_PutString(0, 24, "and can be "); + UG_PutString(0, 32, "enabled in "); + UG_PutString(0, 40, "the options"); + UG_PutString(0, 48, "menu. "); } - UG_SetForecolor(C_RED); - UG_PutString(30, 56, "MENU"); UG_SetBackcolor(C_BLACK); kcugui_flush(); From 13dfcc38660778884e8dd666620ce288c3346904 Mon Sep 17 00:00:00 2001 From: Rory Hayes Date: Sat, 14 Jul 2018 00:43:18 -0700 Subject: [PATCH 3/4] reduce battery SOC to an icon --- main/gui.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/main/gui.c b/main/gui.c index 1c550a3..3bf99d3 100644 --- a/main/gui.c +++ b/main/gui.c @@ -38,6 +38,24 @@ void drawIcon(int px, int py, int o) { } } +void drawBatterySOC() { + // draw outer battery frame + UG_DrawFrame(KC_SCREEN_W-21, 0, KC_SCREEN_W-3, 7, C_WHITE); + UG_DrawFrame(KC_SCREEN_W-2, 2, KC_SCREEN_W-1, 5, C_WHITE); + + // collect battery info + int b = kchal_get_bat_pct(); + + // select appropriate filler color + UG_COLOR batColor; + if (b < 20) batColor = C_RED; + else if (b < 50) batColor = C_GOLD; + else batColor = C_LIME; + + // fill in battery, relative to battery SOC + UG_FillFrame(KC_SCREEN_W-20, 1, KC_SCREEN_W-4-(((100-b)*16)/100), 6, batColor); +} + void guiCharging(int almostFull) { kcugui_cls(); @@ -77,19 +95,7 @@ void guiSplash() { UG_FontSelect(&FONT_6X8); - char buf[32]; - int b = kchal_get_bat_pct(); - //int b = 100; - sprintf(buf, "%i", b); - - if (b < 20) UG_SetForecolor(C_RED); - else if (b < 50) UG_SetForecolor(C_GOLD); - else UG_SetForecolor(C_LAWN_GREEN); - - UG_PutString(KC_SCREEN_W-4-(7*strlen(buf)), 1, buf); - - UG_DrawFrame(KC_SCREEN_W-27, 0, KC_SCREEN_W-3, 8, C_WHITE); - UG_DrawFrame(KC_SCREEN_W-2, 2, KC_SCREEN_W-1, 6, C_WHITE); + drawBatterySOC(); if (wifi_en) { UG_SetForecolor(C_WHITE); @@ -102,7 +108,7 @@ void guiSplash() { UG_PutString(0, 32, "HTTP://192.168.4.1/"); } else { UG_SetForecolor(C_WHITE); - UG_PutString(0, 8, "NOTE: "); + UG_PutString(0, 8, " NOTE:"); UG_SetForecolor(C_YELLOW); UG_PutString(0, 16, "WiFi is off"); UG_PutString(0, 24, "and can be "); @@ -110,6 +116,8 @@ void guiSplash() { UG_PutString(0, 40, "the options"); UG_PutString(0, 48, "menu. "); } + UG_SetForecolor(C_RED); + UG_PutString(30, 56, "MENU"); UG_SetBackcolor(C_BLACK); kcugui_flush(); From 2f0518354ab1f23e6220873356767aac4f8656b4 Mon Sep 17 00:00:00 2001 From: Rory Hayes Date: Sat, 14 Jul 2018 00:51:47 -0700 Subject: [PATCH 4/4] adjust battery icon size --- main/gui.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/main/gui.c b/main/gui.c index 3bf99d3..051809e 100644 --- a/main/gui.c +++ b/main/gui.c @@ -40,8 +40,8 @@ void drawIcon(int px, int py, int o) { void drawBatterySOC() { // draw outer battery frame - UG_DrawFrame(KC_SCREEN_W-21, 0, KC_SCREEN_W-3, 7, C_WHITE); - UG_DrawFrame(KC_SCREEN_W-2, 2, KC_SCREEN_W-1, 5, C_WHITE); + UG_DrawFrame(KC_SCREEN_W-17, 0, KC_SCREEN_W-3, 6, C_WHITE); + UG_DrawFrame(KC_SCREEN_W-2, 2, KC_SCREEN_W-1, 4, C_WHITE); // collect battery info int b = kchal_get_bat_pct(); @@ -53,7 +53,7 @@ void drawBatterySOC() { else batColor = C_LIME; // fill in battery, relative to battery SOC - UG_FillFrame(KC_SCREEN_W-20, 1, KC_SCREEN_W-4-(((100-b)*16)/100), 6, batColor); + UG_FillFrame(KC_SCREEN_W-16, 1, KC_SCREEN_W-4-(((100-b)*12)/100), 5, batColor); } @@ -93,28 +93,27 @@ void guiSplash() { } nvs_close(nvsHandle); - UG_FontSelect(&FONT_6X8); - drawBatterySOC(); + UG_FontSelect(&FONT_6X8); if (wifi_en) { UG_SetForecolor(C_WHITE); - UG_PutString(0, 8, "WIFI AP"); + UG_PutString(0, 0, "WIFI AP"); UG_SetForecolor(C_YELLOW); - UG_PutString(0, 16, " pkspr"); + UG_PutString(0, 8, " pkspr"); UG_SetForecolor(C_WHITE); - UG_PutString(0, 24, "GO TO:"); + UG_PutString(0, 16, "GO TO:"); UG_SetForecolor(C_YELLOW); - UG_PutString(0, 32, "HTTP://192.168.4.1/"); + UG_PutString(0, 24, "HTTP://192.168.4.1/"); } else { UG_SetForecolor(C_WHITE); - UG_PutString(0, 8, " NOTE:"); + UG_PutString(0, 0, " NOTE:"); UG_SetForecolor(C_YELLOW); - UG_PutString(0, 16, "WiFi is off"); - UG_PutString(0, 24, "and can be "); - UG_PutString(0, 32, "enabled in "); - UG_PutString(0, 40, "the options"); - UG_PutString(0, 48, "menu. "); + UG_PutString(0, 8, "WiFi is off"); + UG_PutString(0, 16, "and can be "); + UG_PutString(0, 24, "enabled in "); + UG_PutString(0, 32, "the options"); + UG_PutString(0, 40, "menu. "); } UG_SetForecolor(C_RED); UG_PutString(30, 56, "MENU");