From a2b2f56daf4ef4eebf73d799923fc5b099339142 Mon Sep 17 00:00:00 2001 From: starcalc Date: Sun, 17 Mar 2019 18:20:19 +0100 Subject: [PATCH] Geschwindigkeit einstellbar --- esp-wemos-schild/esp-wemos-schild.ino | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/esp-wemos-schild/esp-wemos-schild.ino b/esp-wemos-schild/esp-wemos-schild.ino index 5c40d50..0c463bb 100644 --- a/esp-wemos-schild/esp-wemos-schild.ino +++ b/esp-wemos-schild/esp-wemos-schild.ino @@ -10,7 +10,7 @@ #define NUMPIXELS 30 #define FW_NAME "esp-schild" -#define FW_VERSION "1.0.3" +#define FW_VERSION "1.0.4" HomieNode homieNode("strip", "strip"); @@ -65,6 +65,17 @@ bool onSetBrightness(const HomieRange& range, const String& value) { homieNode.setProperty("brightness").send(value); } + +bool onSetSpeed(const HomieRange& range, const String& value) { + long speed = value.toInt(); + if (speed < 0 || speed > 255) { + return false; + } + strip.setInterval(speed); + strip.show(); + homieNode.setProperty("speed").send(value); +} + bool onSetEffect(const HomieRange& range, const String& value) { String effect = value; effect.toLowerCase(); @@ -181,6 +192,7 @@ void setup() { homieNode.advertiseRange("pixel", 0, NUMPIXELS - 1).settable(onSetPixel); homieNode.advertiseRange("color", 0, 1).settable(onSetColor); homieNode.advertise("brightness").settable(onSetBrightness); + homieNode.advertise("speed").settable(onSetSpeed); homieNode.advertise("effect").settable(onSetEffect); homieNode.advertise("clear").settable(onSetClear); homieNode.advertise("length").settable(onSetLength);