parent
1a0de982d3
commit
21bf526897
|
@ -1,7 +1,7 @@
|
|||
#include <SpejsNode.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue