From 21bf526897dd58b03e48b6f17b2aaab4bb977e52 Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Tue, 30 Apr 2019 21:03:00 +0200 Subject: [PATCH] display: add toggle mode this is used in memetic stringy light control switch --- display/app/application.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/display/app/application.cpp b/display/app/application.cpp index 39db205..a33899f 100644 --- a/display/app/application.cpp +++ b/display/app/application.cpp @@ -1,7 +1,7 @@ #include -SpejsNode node("control-panel"); -DriverPWM pwm; +SpejsNode node("string-controller"); +//DriverPWM pwm; #define SLAVES_COUNT 1 @@ -14,6 +14,7 @@ public: bool state = false; uint32_t lastTrigger = 0; bool lastButton = false; + bool toggle = false; Timer breatheTimer; @@ -36,12 +37,12 @@ public: //pwm.analogWrite(ledPin, (millis()/10) % 50 + 20); } - SlaveEndpoint(String _topic, int _ledPin = -1, int _btnPin = -1) : - topic(_topic), ledPin(_ledPin), btnPin(_btnPin) {} + SlaveEndpoint(String _topic, int _ledPin = -1, int _btnPin = -1, bool _toggle = false) : + topic(_topic), ledPin(_ledPin), btnPin(_btnPin), toggle(_toggle) {} }; SlaveEndpoint slaves[] = { - {"iot/b4a90f/relay/on", 2, 0}, // Exhaust + {"iot/077521/relay/on", 2, 4, true}, // Exhaust }; class StatusEndpoint : public Endpoint { @@ -99,7 +100,7 @@ public: if(s != slaves[i].lastButton) { slaves[i].lastButton = s; - if (!s) { + if (!s || slaves[i].toggle) { Serial.println("INTERRUPT"); parent->mqtt.publish(slaves[i].topic + "/set", slaves[i].state ? "false" : "true", true); }