This commit is contained in:
Dmitry Borisenko
2020-07-29 21:38:39 +02:00
parent 832e6a36f1
commit 9fa3ec05c2
3 changed files with 42 additions and 2 deletions

34
include/Class/button.h Normal file
View File

@@ -0,0 +1,34 @@
#pragma once
#include <Arduino.h>
#include "Class/Item.h"
#include "Global.h"
class Button : public Item {
public:
void pinModeSet(int pinf) {
if (pin != "") {
pinMode(pinf, OUTPUT);
}
}
void pinStateSet(int pinf, int statef) {
if (state != "") {
digitalWrite(pinf, statef);
jsonWriteInt(configLiveJson, key, statef);
MqttClient::publishStatus(key, String(statef));
}
}
void pinStateSetInv(int pinf, int statef) {
if (inv != "" && state != "") {
digitalWrite(pinf, !statef);
jsonWriteInt(configLiveJson, key, !statef);
MqttClient::publishStatus(key, String(!statef));
}
}
};
extern Button* myButton;