mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
Progress of renew of class
This commit is contained in:
64
src/items/vInOutput.cpp
Normal file
64
src/items/vInOutput.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "items/vInOutput.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Class/LineParsing.h"
|
||||
#include "Global.h"
|
||||
#include "BufferExecute.h"
|
||||
//this class save date to flash
|
||||
InOutput::InOutput(String key, String widget) {
|
||||
_key = key;
|
||||
String value = jsonReadStr(configStoreJson, key);
|
||||
|
||||
if (value == "") {
|
||||
if (widget.indexOf("Digit") != -1) {
|
||||
value = "52";
|
||||
}
|
||||
if (widget.indexOf("Time") != -1) {
|
||||
value = "12:00";
|
||||
}
|
||||
}
|
||||
|
||||
this->execute(value);
|
||||
}
|
||||
InOutput::~InOutput() {}
|
||||
|
||||
void InOutput::execute(String value) {
|
||||
eventGen2(_key, value);
|
||||
jsonWriteStr(configStoreJson, _key, value);
|
||||
saveStore();
|
||||
publishStatus(_key, value);
|
||||
}
|
||||
|
||||
MyInOutputVector* myInOutput = nullptr;
|
||||
|
||||
void inOutput() {
|
||||
myLineParsing.update();
|
||||
String widget = myLineParsing.gfile();
|
||||
String key = myLineParsing.gkey();
|
||||
myLineParsing.clear();
|
||||
|
||||
inOutput_EnterCounter++;
|
||||
addKey(key, inOutput_KeyList, inOutput_EnterCounter);
|
||||
|
||||
static bool firstTime = true;
|
||||
if (firstTime) myInOutput = new MyInOutputVector();
|
||||
firstTime = false;
|
||||
myInOutput->push_back(InOutput(key, widget));
|
||||
|
||||
sCmd.addCommand(key.c_str(), inOutputExecute);
|
||||
}
|
||||
|
||||
void inOutputExecute() {
|
||||
String key = sCmd.order();
|
||||
String value = sCmd.next();
|
||||
|
||||
int number = getKeyNum(key, inOutput_KeyList);
|
||||
|
||||
if (myInOutput != nullptr) {
|
||||
if (number != -1) {
|
||||
myInOutput->at(number).execute(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user