mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-28 15:12:19 +03:00
Working version
This commit is contained in:
@@ -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);
|
||||
//}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user