mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-27 06:32:19 +03:00
Gisteresis termostat
This commit is contained in:
@@ -18,36 +18,56 @@ void itemsListInit() {
|
||||
delChoosingItems();
|
||||
},
|
||||
nullptr);
|
||||
#ifdef FLASH_SIZE_1MB
|
||||
myNotAsyncActions->add(
|
||||
do_addItem, [&](void*) {
|
||||
addItem(itemName);
|
||||
itemName = "";
|
||||
},
|
||||
nullptr);
|
||||
|
||||
myNotAsyncActions->add(
|
||||
do_addPreset, [&](void*) {
|
||||
addPreset(presetName);
|
||||
presetName = "";
|
||||
},
|
||||
nullptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
void addItem(String name) {
|
||||
#ifdef FLASH_SIZE_1MB
|
||||
String url = serverIP + F("/projects/iotmanager/config/items/") + name + ".txt";
|
||||
String item = getURL(url);
|
||||
Serial.println(url);
|
||||
Serial.println(item);
|
||||
if (item == "error") return;
|
||||
#endif
|
||||
#ifndef FLASH_SIZE_1MB
|
||||
String item = readFile("items/" + name + ".txt", 1024);
|
||||
#endif
|
||||
|
||||
name = selectToMarker(name, "-");
|
||||
|
||||
randomSeed(micros());
|
||||
unsigned int num = random(0, 1000);
|
||||
|
||||
item.replace("id", name + String(num)); // "-" + String(getNewElementNumber("id.txt")));
|
||||
item.replace("id", name + String(num));
|
||||
item.replace("order", String(getNewElementNumber("order.txt")));
|
||||
|
||||
if (item.indexOf("pin") != -1) { //all cases (random pins from available)
|
||||
item.replace("pin", "pin[" + String(getFreePinAll()) + "]");
|
||||
} else
|
||||
|
||||
if (item.indexOf("gol") != -1) { //analog
|
||||
}
|
||||
else if (item.indexOf("gol") != -1) { //analog
|
||||
item.replace("gol", "pin[" + String(getFreePinAnalog()) + "]");
|
||||
} else
|
||||
|
||||
if (item.indexOf("cin") != -1) { //ultrasonic
|
||||
}
|
||||
else if (item.indexOf("cin") != -1) { //ultrasonic
|
||||
item.replace("cin", "pin[" + String(getFreePinAll()) + "," + String(getFreePinAll()) + "]");
|
||||
} else
|
||||
|
||||
if (item.indexOf("sal") != -1) { //dallas
|
||||
}
|
||||
else if (item.indexOf("sal") != -1) { //dallas
|
||||
item.replace("sal", "pin[2]");
|
||||
} else
|
||||
|
||||
if (item.indexOf("thd") != -1) { //dht11/22
|
||||
}
|
||||
else if (item.indexOf("thd") != -1) { //dht11/22
|
||||
item.replace("thd", "pin[2]");
|
||||
}
|
||||
|
||||
@@ -58,12 +78,32 @@ void addItem(String name) {
|
||||
}
|
||||
|
||||
void addPreset(String name) {
|
||||
#ifdef FLASH_SIZE_1MB
|
||||
String url2 = serverIP + F("/projects/iotmanager/config/presets/") + name + ".txt";
|
||||
String preset = getURL(url2);
|
||||
Serial.println(url2);
|
||||
Serial.println(preset);
|
||||
if (preset == "error") return;
|
||||
#endif
|
||||
#ifndef FLASH_SIZE_1MB
|
||||
String preset = readFile("presets/" + name + ".txt", 4048);
|
||||
#endif
|
||||
|
||||
addFile(DEVICE_CONFIG_FILE, "\n" + preset);
|
||||
|
||||
name.replace(".c",".s");
|
||||
name.replace(".c", ".s");
|
||||
|
||||
#ifdef FLASH_SIZE_1MB
|
||||
String url = serverIP + F("/projects/iotmanager/config/presets/") + name + ".txt";
|
||||
String scenario = getURL(url);
|
||||
Serial.println(url);
|
||||
Serial.println(scenario);
|
||||
if (scenario == "error") return;
|
||||
#endif
|
||||
#ifndef FLASH_SIZE_1MB
|
||||
String scenario = readFile("presets/" + name + ".txt", 4048);
|
||||
#endif
|
||||
|
||||
removeFile(DEVICE_SCENARIO_FILE);
|
||||
addFile(DEVICE_SCENARIO_FILE, scenario);
|
||||
loadScenario();
|
||||
@@ -89,16 +129,17 @@ uint8_t getNewElementNumber(String file) {
|
||||
|
||||
uint8_t getFreePinAll() {
|
||||
#ifdef ESP8266
|
||||
uint8_t pins[] = {0, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5};
|
||||
uint8_t pins[] = { 0, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5 };
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
uint8_t pins[] = {0, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5};
|
||||
uint8_t pins[] = { 0, 12, 13, 14, 15, 16, 1, 2, 3, 4, 5 };
|
||||
#endif
|
||||
uint8_t array_sz = sizeof(pins) / sizeof(pins[0]);
|
||||
uint8_t i = getNewElementNumber("pins.txt");
|
||||
if (i < array_sz) {
|
||||
return pins[i];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -121,7 +162,8 @@ void delChoosingItems() {
|
||||
String item = configFile.readStringUntil('\n');
|
||||
if (firstLine) {
|
||||
finalConf += item;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
int checkbox = selectToMarker(item, ";").toInt();
|
||||
if (checkbox == 0) {
|
||||
finalConf += "\n" + item;
|
||||
|
||||
Reference in New Issue
Block a user