mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
Working version
This commit is contained in:
@@ -45,12 +45,9 @@ void csvCmdExecute(String& cmdStr) {
|
||||
else if (order == F("button-in")) {
|
||||
sCmd.addCommand(order.c_str(), buttonIn);
|
||||
}
|
||||
else if (order == F("input-digit")) {
|
||||
else if (order == F("input")) {
|
||||
sCmd.addCommand(order.c_str(), input);
|
||||
}
|
||||
else if (order == F("input-time")) {
|
||||
//sCmd.addCommand(order.c_str(), inputTime);
|
||||
}
|
||||
else if (order == F("output-text")) {
|
||||
sCmd.addCommand(order.c_str(), textOut);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,8 @@ void addPreset(String name) {
|
||||
void delAllItems() {
|
||||
removeFile(DEVICE_CONFIG_FILE);
|
||||
addFile(DEVICE_CONFIG_FILE, String(firstLine));
|
||||
removeFile(DEVICE_SCENARIO_FILE);
|
||||
addFile(DEVICE_SCENARIO_FILE, "//");
|
||||
removeFile("id.txt");
|
||||
removeFile("order.txt");
|
||||
removeFile("pins.txt");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "Utils/TimeUtils.h"
|
||||
|
||||
#include "Global.h"
|
||||
#include "Utils/StringUtils.h"
|
||||
|
||||
static const uint8_t days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
@@ -211,3 +211,17 @@ void breakEpochToTime(unsigned long epoch, Time_t& tm) {
|
||||
tm.day_of_month = time + 1; // day of month
|
||||
tm.valid = (epoch > MIN_DATETIME);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ void web_init() {
|
||||
|
||||
#ifdef LOGGING_ENABLED
|
||||
if (request->hasArg("cleanlog")) {
|
||||
clean_log_date();
|
||||
cleanLogAndData();
|
||||
request->send(200);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -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