From 3ba9f1b95046f0e59ab758a046d124ed5fb0491a Mon Sep 17 00:00:00 2001 From: Tobias Blum Date: Sat, 28 Oct 2017 22:07:07 +0200 Subject: [PATCH] Add /get_speed and /set_speed endpoints Like proposed in https://github.com/toblum/McLighting/pull/49 --- Arduino/McLighting/McLighting.ino | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Arduino/McLighting/McLighting.ino b/Arduino/McLighting/McLighting.ino index d04dcd6..6d9deb1 100644 --- a/Arduino/McLighting/McLighting.ino +++ b/Arduino/McLighting/McLighting.ino @@ -446,26 +446,21 @@ void setup() { DBG_OUTPUT_PORT.println(str_brightness); }); - server.on("/set_delay", []() { + server.on("/set_speed", []() { if (server.arg("d").toInt() >= 0) { ws2812fx_speed = server.arg("d").toInt(); + ws2812fx_speed = constrain(ws2812fx_speed, 0, 255); + strip.setSpeed(ws2812fx_speed); } - if (ws2812fx_speed > 255) { - ws2812fx_speed = 255; - } - if (ws2812fx_speed < 0) { - ws2812fx_speed = 0; - } - strip.setSpeed(ws2812fx_speed); getStatusJSON(); }); - server.on("/get_delay", []() { - String str_delay = String(ws2812fx_speed); - server.send(200, "text/plain", str_delay ); - DBG_OUTPUT_PORT.print("/get_delay: "); - DBG_OUTPUT_PORT.println(str_delay); + server.on("/get_speed", []() { + String str_speed = String(ws2812fx_speed); + server.send(200, "text/plain", str_speed ); + DBG_OUTPUT_PORT.print("/get_speed: "); + DBG_OUTPUT_PORT.println(str_speed); }); server.on("/get_switch", []() {