Working version

This commit is contained in:
Dmitry Borisenko
2020-11-15 02:46:27 +03:00
parent d6aab0cf94
commit 94d93d3be6
14 changed files with 58 additions and 111 deletions

View File

@@ -1,19 +0,0 @@
//#include "BufferExecute.h"
//#include "items/InputClass.h"
////==========================================Модуль ввода цифровых значений==================================
////input-digit digit1 inputDigit Ввод Введите.цифру 4 st[60]
////==========================================================================================================
//InputClass myInputDigit;
//void inputDigit() {
// myInputDigit.update();
// String key = myInputDigit.gkey();
// sCmd.addCommand(key.c_str(), inputDigitSet);
// myInputDigit.inputSetDefaultFloat();
// myInputDigit.clear();
//}
//
//void inputDigitSet() {
// String key = sCmd.order();
// String state = sCmd.next();
// myInputDigit.inputSetFloat(key, state);
//}

View File

@@ -1,32 +0,0 @@
#include "BufferExecute.h"
#include "items/InputClass.h"
//==========================================Модуль ввода времени============================================
//==========================================================================================================
//InputClass myInputTime;
//void inputTime() {
// myInputTime.update();
// String key = myInputTime.gkey();
// sCmd.addCommand(key.c_str(), inputTimeSet);
// myInputTime.inputSetDefaultStr();
// myInputTime.clear();
//}
//
//void inputTimeSet() {
// String key = sCmd.order();
// String state = sCmd.next();
// myInputTime.inputSetStr(key, state);
//}
void handle_time_init() {
ts.add(
TIME, 1000, [&](void*) {
String timenow = timeNow->getTimeWOsec();
static String prevTime;
if (prevTime != timenow) {
prevTime = timenow;
jsonWriteStr(configLiveJson, "timenow", timenow);
eventGen2("timenow", timenow);
}
},
nullptr, true);
}

View File

@@ -6,24 +6,35 @@
#include "Global.h"
#include "BufferExecute.h"
Input::Input(String key) {
Input::Input(String key, String widget) {
_key = key;
String value = jsonReadStr(configLiveJson, key);
if (value == "") {
if (widget.indexOf("Digit") != -1) {
value = "52";
}
if (widget.indexOf("Time") != -1) {
value = "12:00";
}
}
this->execute(value);
}
Input::~Input() {}
void Input::execute(String state) {
eventGen2(_key, state);
jsonWriteInt(configLiveJson, _key, state.toInt());
void Input::execute(String value) {
eventGen2(_key, value);
jsonWriteStr(configLiveJson, _key, value);
saveLive();
publishStatus(_key, state);
publishStatus(_key, value);
}
MyInputVector* myInput = nullptr;
void input() {
myLineParsing.update();
String widget = myLineParsing.gfile();
String key = myLineParsing.gkey();
myLineParsing.clear();
@@ -33,20 +44,20 @@ void input() {
static bool firstTime = true;
if (firstTime) myInput = new MyInputVector();
firstTime = false;
myInput->push_back(Input(key));
myInput->push_back(Input(key, widget));
sCmd.addCommand(key.c_str(), inputExecute);
}
void inputExecute() {
String key = sCmd.order();
String state = sCmd.next();
String value = sCmd.next();
int number = getKeyNum(key, input_KeyList);
if (myInput != nullptr) {
if (number != -1) {
myInput->at(number).execute(state);
myInput->at(number).execute(value);
}
}
}

View File

@@ -112,7 +112,7 @@ void sendLogData(String file, String topic) {
}
}
void clean_log_date() {
void cleanLogAndData() {
#ifdef ESP8266
auto dir = LittleFS.openDir("logs");
while (dir.next()) {
@@ -121,5 +121,6 @@ void clean_log_date() {
removeFile("logs/" + fname);
}
removeFile("live.json");
configLiveJson = "";
#endif
}