mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
callback
This commit is contained in:
@@ -4,7 +4,7 @@ static const char* firstLine PROGMEM = "Тип элемента;Id;Виджет;
|
||||
|
||||
void addElement(String name) {
|
||||
String item = readFile("items/" + name + ".txt", 1024);
|
||||
|
||||
|
||||
item.replace("id", "id" + String(getNewElementNumber("id.txt")));
|
||||
item.replace("order", String(getNewElementNumber("order.txt")));
|
||||
|
||||
@@ -21,7 +21,6 @@ void delAllElement() {
|
||||
removeFile("order.txt");
|
||||
}
|
||||
|
||||
|
||||
int getNewElementNumber(String file) {
|
||||
int number = readFile(file, 100).toInt();
|
||||
number++;
|
||||
@@ -30,7 +29,37 @@ int getNewElementNumber(String file) {
|
||||
return number;
|
||||
}
|
||||
|
||||
void do_getJsonListFromCsv() {
|
||||
if (getJsonListFromCsvFlag) {
|
||||
getJsonListFromCsvFlag = false;
|
||||
removeFile("items/elements.json");
|
||||
addFile("items/elements.json", getJsonListFromCsv("conf.csv", 1));
|
||||
}
|
||||
}
|
||||
|
||||
String getJsonListFromCsv(String csvFile, int colum) {
|
||||
File configFile = LittleFS.open("/" + csvFile, "r");
|
||||
if (!configFile) {
|
||||
return "error";
|
||||
}
|
||||
configFile.seek(0, SeekSet);
|
||||
|
||||
String outJson = "{}";
|
||||
|
||||
int count = -1;
|
||||
|
||||
while (configFile.position() != configFile.size()) {
|
||||
count++;
|
||||
String item = configFile.readStringUntil('\n');
|
||||
if (count > 0) {
|
||||
String line = selectFromMarkerToMarker(item, ";", colum);
|
||||
jsonWriteStr(outJson, line, line);
|
||||
}
|
||||
}
|
||||
configFile.close();
|
||||
csvFile = "";
|
||||
return outJson;
|
||||
}
|
||||
|
||||
void do_delElement() {
|
||||
if (delElementFlag) {
|
||||
|
||||
Reference in New Issue
Block a user