diff options
| author | Jan200101 <sentrycraft123@gmail.com> | 2025-08-03 16:46:10 +0200 |
|---|---|---|
| committer | Jan200101 <sentrycraft123@gmail.com> | 2025-08-03 16:46:10 +0200 |
| commit | 64b0c11e5ae8dd4cc0f15d40bbd7ff9faaebca45 (patch) | |
| tree | a26ae87cb8a94aa13c23bce1462c041dbab15286 /src | |
| parent | 65acb5c9880df4b4417ff759f1453a666563a1ce (diff) | |
| download | pico-relay-64b0c11e5ae8dd4cc0f15d40bbd7ff9faaebca45.tar.gz pico-relay-64b0c11e5ae8dd4cc0f15d40bbd7ff9faaebca45.zip | |
add status label to GUI
Diffstat (limited to 'src')
| -rw-r--r-- | src/gui.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -4,6 +4,7 @@ #include "gui.h" #include "paint.h" #include "display.h" +#include "relay.h" #include "logging.h" #define BATTERY_PADDING (10) @@ -11,6 +12,8 @@ #define BATTERY_INNER_PADDING (8) +#define LABEL1_Y (BATTERY_HEIGHT + BATTERY_PADDING) + static uint8_t* image = NULL; extern double battery_percentage; @@ -36,10 +39,7 @@ void gui_draw(void) if (!image) return; - battery_percentage += 1; - if (battery_percentage >= 100) - battery_percentage = 0; - + // battery outline Paint_DrawRectangle( BATTERY_PADDING, BATTERY_PADDING, display.width - BATTERY_PADDING, @@ -49,6 +49,7 @@ void gui_draw(void) DRAW_FILL_EMPTY ); + // battery bar { vFONT* font = &FontTerminusTTF22v; @@ -79,5 +80,18 @@ void gui_draw(void) ); } + // state label + { + vFONT* font = &FontTerminusTTF22v; + + char buf[12]; // "STATE: OFF" + sprintf(buf, "STATE: %s", get_relay() ? "ON" : "OFF"); + Paint_DrawString_Align( + BATTERY_PADDING, LABEL1_Y, + buf, font, + WHITE, BLACK, ALIGN_LEFT + ); + } + display.draw(image); } |
