From 8c775e970561f6eb55a4165e22eb2576778ac105 Mon Sep 17 00:00:00 2001 From: jedi Date: Mon, 19 Jul 2021 23:31:20 +0200 Subject: [PATCH] add toogle button for signal led in http frontend --- firmware/fsdata/fs/index.html | 13 +++++++++++++ firmware/lux.cpp | 2 +- firmware/web.cpp | 10 ++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/firmware/fsdata/fs/index.html b/firmware/fsdata/fs/index.html index ad6aff1..286aeff 100644 --- a/firmware/fsdata/fs/index.html +++ b/firmware/fsdata/fs/index.html @@ -109,6 +109,19 @@ +
+
+
+

I/O

+
+ +
+
diff --git a/firmware/lux.cpp b/firmware/lux.cpp index cd8408f..8b775c4 100644 --- a/firmware/lux.cpp +++ b/firmware/lux.cpp @@ -17,7 +17,7 @@ const int gpio4 = 4; const int gpio5 = 5; extern "C" void signal_led(bool state) { - gpio_write(signal_led_pin, state); + gpio_write(signal_led_pin, !state); } extern "C" void lux_task(void *pvParameters) { diff --git a/firmware/web.cpp b/firmware/web.cpp index c5bcaa8..c900018 100644 --- a/firmware/web.cpp +++ b/firmware/web.cpp @@ -226,6 +226,16 @@ void websocket_cb(struct tcp_pcb *pcb, char *data, u16_t data_len, uint8_t mode) char cmd = '0'; switch (data[0]) { + case 'D': // Disable LED + signal_led(false); + val = 1; + cmd = 'G'; + break; + case 'E': // Enable LED + signal_led(true); + val = 0; + cmd = 'G'; + break; default: printf("[websocket_callback]:\n%.*s\n", (int) data_len, (char *) data); printf("Unknown command\n");