summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2025-08-03 16:46:10 +0200
committerJan200101 <sentrycraft123@gmail.com>2025-08-03 16:46:10 +0200
commit64b0c11e5ae8dd4cc0f15d40bbd7ff9faaebca45 (patch)
treea26ae87cb8a94aa13c23bce1462c041dbab15286 /src
parent65acb5c9880df4b4417ff759f1453a666563a1ce (diff)
downloadpico-relay-64b0c11e5ae8dd4cc0f15d40bbd7ff9faaebca45.tar.gz
pico-relay-64b0c11e5ae8dd4cc0f15d40bbd7ff9faaebca45.zip
add status label to GUI
Diffstat (limited to 'src')
-rw-r--r--src/gui.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/gui.c b/src/gui.c
index 91523df..8472402 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -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);
}