stash
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
j3d1 2021-09-12 04:32:05 +02:00
parent d96504d3eb
commit f6681d54de
3 changed files with 36 additions and 12 deletions

View file

@ -26,13 +26,10 @@ struct apa10xx_pixel_t {
static ws2812_pixel_t next_colour(int i) { static ws2812_pixel_t next_colour(int i) {
ws2812_pixel_t colour = {{0, 0, 0, 0}}; ws2812_pixel_t colour = {{0, 0, 0, 0}};
if(i == 8) { colour.red = 0;
colour.white = 32; colour.green = 0;
} else { colour.blue = 0;
colour.red = i & 1 ? 32 : 0; colour.white = 8;
colour.green = i & 2 ? 32 : 0;
colour.blue = i & 4 ? 32 : 0;
}
return colour; return colour;
} }
@ -40,9 +37,9 @@ static ws2812_pixel_t next_colour(int i) {
static apa10xx_pixel_t next_color(int i) { static apa10xx_pixel_t next_color(int i) {
apa10xx_pixel_t colour; apa10xx_pixel_t colour;
colour.global.mod = 8; colour.global.mod = 8;
colour.r = i & 1 ? 32 : 0; colour.r = 16;
colour.g = i & 2 ? 32 : 0; colour.g = 16;
colour.b = i & 4 ? 32 : 0; colour.b = 16;
return colour; return colour;
} }
@ -229,16 +226,20 @@ extern "C" void signal_led(bool state) {
fiatlux::signal::write_data(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. /* This task uses the high level GPIO API (esp_gpio.h) to blink an LED.
* *
*/ */
extern "C" [[noreturn]] void lux_task(void *pvParameters) { 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); auto ret = sysparam_get_int32("lux_ws2812_number", &lux_ws2812_number);
if(ret != SYSPARAM_OK) if(ret != SYSPARAM_OK)
lux_ws2812_number = 8; lux_ws2812_number = 40;
int32_t lux_apa10xx_number = 40; int32_t lux_apa10xx_number = 40;
ret = sysparam_get_int32("lux_apa10xx_number", &lux_apa10xx_number); ret = sysparam_get_int32("lux_apa10xx_number", &lux_apa10xx_number);

View file

@ -291,6 +291,18 @@ void websocket_cb(struct tcp_pcb *pcb, char *data, u16_t data_len,
ret = OK; ret = OK;
val = 0; val = 0;
break; 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': case 'F':
togl = !togl; togl = !togl;
signal_led(togl); signal_led(togl);

View file

@ -301,6 +301,10 @@
<input type="checkbox" name="onoffswitch" id="led-switch" onclick="gpio()"> <input type="checkbox" name="onoffswitch" id="led-switch" onclick="gpio()">
<span class="toggle button">toggle signal led</span> <span class="toggle button">toggle signal led</span>
</label> </label>
<label>
<input type="checkbox" name="whiteswitch" id="white-switch" onclick="leds()">
<span class="toggle button">toggle white leds</span>
</label>
</footer> </footer>
</article> </article>
</div> </div>
@ -446,6 +450,13 @@
wsWrite('D'); wsWrite('D');
} }
function leds() {
if (document.getElementById('white-switch').checked)
wsWrite('e');
else
wsWrite('d');
}
window.onload = function () { window.onload = function () {
wsOpen(); wsOpen();
startPolling(); startPolling();