Geschwindigkeit einstellbar

This commit is contained in:
starcalc 2019-03-17 18:20:19 +01:00
parent d56ed90020
commit a2b2f56daf
1 changed files with 13 additions and 1 deletions

View File

@ -10,7 +10,7 @@
#define NUMPIXELS 30 #define NUMPIXELS 30
#define FW_NAME "esp-schild" #define FW_NAME "esp-schild"
#define FW_VERSION "1.0.3" #define FW_VERSION "1.0.4"
HomieNode homieNode("strip", "strip"); HomieNode homieNode("strip", "strip");
@ -65,6 +65,17 @@ bool onSetBrightness(const HomieRange& range, const String& value) {
homieNode.setProperty("brightness").send(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) { bool onSetEffect(const HomieRange& range, const String& value) {
String effect = value; String effect = value;
effect.toLowerCase(); effect.toLowerCase();
@ -181,6 +192,7 @@ void setup() {
homieNode.advertiseRange("pixel", 0, NUMPIXELS - 1).settable(onSetPixel); homieNode.advertiseRange("pixel", 0, NUMPIXELS - 1).settable(onSetPixel);
homieNode.advertiseRange("color", 0, 1).settable(onSetColor); homieNode.advertiseRange("color", 0, 1).settable(onSetColor);
homieNode.advertise("brightness").settable(onSetBrightness); homieNode.advertise("brightness").settable(onSetBrightness);
homieNode.advertise("speed").settable(onSetSpeed);
homieNode.advertise("effect").settable(onSetEffect); homieNode.advertise("effect").settable(onSetEffect);
homieNode.advertise("clear").settable(onSetClear); homieNode.advertise("clear").settable(onSetClear);
homieNode.advertise("length").settable(onSetLength); homieNode.advertise("length").settable(onSetLength);