mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-28 07:02:17 +03:00
ButtonOut changed (not working version)
This commit is contained in:
32
include/items/ButtonOut.h
Normal file
32
include/items/ButtonOut.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
class ButtonOut;
|
||||
|
||||
typedef std::vector<ButtonOut> MyButtonOutVector;
|
||||
|
||||
class ButtonOut {
|
||||
public:
|
||||
|
||||
ButtonOut(unsigned int pin, boolean inv, String key);
|
||||
|
||||
~ButtonOut();
|
||||
|
||||
void init();
|
||||
void execute(String state);
|
||||
|
||||
private:
|
||||
|
||||
unsigned int _pin;
|
||||
boolean _inv;
|
||||
String _key;
|
||||
|
||||
void addNewDelOldData(const String filename, size_t maxPoints, String payload);
|
||||
};
|
||||
|
||||
extern MyButtonOutVector* myButtonOut;
|
||||
|
||||
extern void buttonOut();
|
||||
extern void buttonOutExecute();
|
||||
@@ -1,41 +1,41 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
|
||||
class ButtonOutClass : public LineParsing {
|
||||
public:
|
||||
ButtonOutClass() : LineParsing() {};
|
||||
|
||||
void init() {
|
||||
if (_pin != "") {
|
||||
pinMode(_pin.toInt(), OUTPUT);
|
||||
}
|
||||
jsonWriteStr(configOptionJson, _key + "_pin", _pin);
|
||||
jsonWriteStr(configOptionJson, _key + "_inv", _inv);
|
||||
}
|
||||
|
||||
void pinStateSetDefault() {
|
||||
pinChange(_key, _state);
|
||||
}
|
||||
|
||||
|
||||
void pinChange(String key, String state) {
|
||||
String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||
String inv = jsonReadStr(configOptionJson, key + "_inv");
|
||||
int pinInt = pin.toInt();
|
||||
|
||||
if (inv == "") {
|
||||
digitalWrite(pinInt, state.toInt());
|
||||
}
|
||||
else {
|
||||
digitalWrite(pinInt, !state.toInt());
|
||||
}
|
||||
eventGen2(key, state);
|
||||
jsonWriteInt(configLiveJson, key, state.toInt());
|
||||
publishStatus(key, state);
|
||||
}
|
||||
};
|
||||
|
||||
extern ButtonOutClass myButtonOut;
|
||||
//#pragma once
|
||||
//#include <Arduino.h>
|
||||
//
|
||||
//#include "Class/LineParsing.h"
|
||||
//#include "Global.h"
|
||||
//
|
||||
//class ButtonOutClass : public LineParsing {
|
||||
//public:
|
||||
// ButtonOutClass() : LineParsing() {};
|
||||
//
|
||||
// void init() {
|
||||
// if (_pin != "") {
|
||||
// pinMode(_pin.toInt(), OUTPUT);
|
||||
// }
|
||||
// jsonWriteStr(configOptionJson, _key + "_pin", _pin);
|
||||
// jsonWriteStr(configOptionJson, _key + "_inv", _inv);
|
||||
// }
|
||||
//
|
||||
// void pinStateSetDefault() {
|
||||
// pinChange(_key, _state);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// void pinChange(String key, String state) {
|
||||
// String pin = jsonReadStr(configOptionJson, key + "_pin");
|
||||
// String inv = jsonReadStr(configOptionJson, key + "_inv");
|
||||
// int pinInt = pin.toInt();
|
||||
//
|
||||
// if (inv == "") {
|
||||
// digitalWrite(pinInt, state.toInt());
|
||||
// }
|
||||
// else {
|
||||
// digitalWrite(pinInt, !state.toInt());
|
||||
// }
|
||||
// eventGen2(key, state);
|
||||
// jsonWriteInt(configLiveJson, key, state.toInt());
|
||||
// publishStatus(key, state);
|
||||
// }
|
||||
//};
|
||||
//
|
||||
//extern ButtonOutClass myButtonOut;
|
||||
Reference in New Issue
Block a user