Progress of renew of class

This commit is contained in:
Dmitry Borisenko
2020-11-17 01:01:42 +03:00
parent a20c2b8564
commit 06df1f17b6
33 changed files with 266 additions and 259 deletions

64
src/items/vInOutput.cpp Normal file
View 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);
}
}
}