From 2e5c79791d7cb2744e28aa1a01457104237d2fd9 Mon Sep 17 00:00:00 2001 From: carstenpi Date: Mon, 23 Oct 2017 17:11:47 +0200 Subject: [PATCH] Added Get/Set Delay to Rest Api --- Arduino/McLighting/McLighting.ino | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Arduino/McLighting/McLighting.ino b/Arduino/McLighting/McLighting.ino index 941c967..d09b8c0 100644 --- a/Arduino/McLighting/McLighting.ino +++ b/Arduino/McLighting/McLighting.ino @@ -445,6 +445,28 @@ void setup() { DBG_OUTPUT_PORT.print("/get_brightness: "); DBG_OUTPUT_PORT.println(str_brightness); }); + + server.on("/set_delay", []() { + if (server.arg("d").toInt() >= 0) { + ws2812fx_speed = server.arg("d").toInt(); + } + 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_switch", []() { server.send(200, "text/plain", (mode == OFF) ? "0" : "1" );