presets added

This commit is contained in:
Dmitry Borisenko
2020-11-03 00:04:07 +03:00
parent 777a04b901
commit 0efae6949d
12 changed files with 47 additions and 7 deletions

View File

@@ -3,8 +3,8 @@
"chipID": "",
"apssid": "IoTmanager",
"appass": "",
"routerssid": "VOLODYA",
"routerpass": "BELCHENKO",
"routerssid": "rise",
"routerpass": "hostel3333",
"timezone": 2,
"ntp": "pool.ntp.org",
"mqttServer": "91.204.228.124",
@@ -17,7 +17,7 @@
"weblogin": "admin",
"webpass": "admin",
"udponoff": "1",
"blink": "0",
"blink": "1",
"oneWirePin": "2",
"serverip": "http://206.189.49.244"
}

View File

@@ -0,0 +1,5 @@
0;dht-hum;hum;anydataHum;Теплица;Влажность;1;pin[2];type[dht11];c[1]
0;logging;log;chart;Теплица;Влажность;2;val[hum];int[60];cnt[100]
0;input-digit;inputU;inputDigit;Теплица;Верхний#порог;3;st[45]
0;input-digit;inputL;inputDigit;Теплица;Нижний#порог;4;st[35]
0;button-out;button;toggle;Теплица;Полив;5;pin[12];st[0]

View File

@@ -0,0 +1,6 @@
hum > inputU
button 0
end
hum < inputL
button 1
end

View File

View File

View File

@@ -50,7 +50,7 @@
},
{
"type": "dropdown",
"name": "help-url",
"name": "help-url1",
"class": "btn btn-default",
"style": "display:inline",
"title": {
@@ -80,7 +80,17 @@
"/set?addItem=uptime": "b.Отобразить время работы устройства"
}
},
{
"type": "dropdown",
"name": "help-url2",
"class": "btn btn-default",
"style": "display:inline",
"title": {
"#": "Выберите пресет из списка<span class=\"caret\"></span>",
"/set?addPreset=termostat.c": "1.Термостат на основе ds18b20 (устройство держит заданный уровень температуры)",
"/set?addPreset=humstat.c": "2.Контроль влажности на основе DHT (устройство держит заданный уровень влажности)"
}
},
{
"type": "hr"
},

View File

@@ -40,8 +40,7 @@ extern WiFiClient espClient;
extern PubSubClient mqtt;
extern StringCommand sCmd;
extern AsyncWebServer server;
extern DallasTemperature sensors;
extern OneWire* oneWire;
extern boolean but[NUM_BUTTONS];
extern Bounce* buttons;

View File

@@ -5,6 +5,7 @@
extern void itemsListInit();
extern void addItem(String name);
extern void addPreset(String name);
extern void delChoosingItems();
extern void delAllItems();
extern uint8_t getNewElementNumber(String file);

View File

@@ -4,6 +4,8 @@
#include "Global.h"
#include "items/SensorConvertingClass.h"
extern DallasTemperature sensors;
extern OneWire* oneWire;
class SensorDallasClass : public SensorConvertingClass {
public:
SensorDallasClass() : SensorConvertingClass() {};

View File

View File

@@ -54,6 +54,17 @@ void addItem(String name) {
addFile(DEVICE_CONFIG_FILE, "\n" + item);
}
void addPreset(String name) {
String preset = readFile("presets/" + name + ".txt", 2024);
addFile(DEVICE_CONFIG_FILE, "\n" + preset);
name.replace(".c",".s");
String scenario = readFile("presets/" + name + ".txt", 2024);
removeFile(DEVICE_SCENARIO_FILE);
addFile(DEVICE_SCENARIO_FILE, scenario);
}
void delAllItems() {
removeFile(DEVICE_CONFIG_FILE);
addFile(DEVICE_CONFIG_FILE, String(firstLine));

View File

@@ -23,6 +23,12 @@ void web_init() {
request->redirect("/?set.device");
}
if (request->hasArg("addPreset")) {
String name = request->getParam("addPreset")->value();
addPreset(name);
request->redirect("/?set.device");
}
if (request->hasArg("delChoosingItems")) {
myNotAsyncActions->make(do_delChoosingItems);
request->send(200);