From f6681d54de5f0b9c67bf10da4df2aed533344607 Mon Sep 17 00:00:00 2001 From: jedi Date: Sun, 12 Sep 2021 04:32:05 +0200 Subject: [PATCH] stash --- firmware/lux.cpp | 25 +++++++++++++------------ firmware/web.cpp | 12 ++++++++++++ firmware/webdir/index.html | 11 +++++++++++ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/firmware/lux.cpp b/firmware/lux.cpp index d5d8e3c..e5dadc6 100644 --- a/firmware/lux.cpp +++ b/firmware/lux.cpp @@ -26,13 +26,10 @@ struct apa10xx_pixel_t { static ws2812_pixel_t next_colour(int i) { ws2812_pixel_t colour = {{0, 0, 0, 0}}; - if(i == 8) { - colour.white = 32; - } else { - colour.red = i & 1 ? 32 : 0; - colour.green = i & 2 ? 32 : 0; - colour.blue = i & 4 ? 32 : 0; - } + colour.red = 0; + colour.green = 0; + colour.blue = 0; + colour.white = 8; return colour; } @@ -40,9 +37,9 @@ static ws2812_pixel_t next_colour(int i) { static apa10xx_pixel_t next_color(int i) { apa10xx_pixel_t colour; colour.global.mod = 8; - colour.r = i & 1 ? 32 : 0; - colour.g = i & 2 ? 32 : 0; - colour.b = i & 4 ? 32 : 0; + colour.r = 16; + colour.g = 16; + colour.b = 16; return colour; } @@ -229,16 +226,20 @@ extern "C" void signal_led(bool state) { fiatlux::signal::write_data(state); } +extern "C" void white_led(bool state) { + gpio_write(signal_led_pin, !state); +} + /* This task uses the high level GPIO API (esp_gpio.h) to blink an LED. * */ extern "C" [[noreturn]] void lux_task(void *pvParameters) { - int32_t lux_ws2812_number = 8; + int32_t lux_ws2812_number = 40; auto ret = sysparam_get_int32("lux_ws2812_number", &lux_ws2812_number); if(ret != SYSPARAM_OK) - lux_ws2812_number = 8; + lux_ws2812_number = 40; int32_t lux_apa10xx_number = 40; ret = sysparam_get_int32("lux_apa10xx_number", &lux_apa10xx_number); diff --git a/firmware/web.cpp b/firmware/web.cpp index 1e182d0..0e3c7fd 100644 --- a/firmware/web.cpp +++ b/firmware/web.cpp @@ -291,6 +291,18 @@ void websocket_cb(struct tcp_pcb *pcb, char *data, u16_t data_len, ret = OK; val = 0; break; + case 'd': // Disable LED + signal_led(false); + cmd = 'G'; + ret = OK; + val = 1; + break; + case 'e': // Enable LED + signal_led(true); + cmd = 'G'; + ret = OK; + val = 0; + break; case 'F': togl = !togl; signal_led(togl); diff --git a/firmware/webdir/index.html b/firmware/webdir/index.html index 0b4bac1..41d3897 100644 --- a/firmware/webdir/index.html +++ b/firmware/webdir/index.html @@ -301,6 +301,10 @@ toggle signal led + @@ -446,6 +450,13 @@ wsWrite('D'); } + function leds() { + if (document.getElementById('white-switch').checked) + wsWrite('e'); + else + wsWrite('d'); + } + window.onload = function () { wsOpen(); startPolling();