mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
uart
This commit is contained in:
1
data/items/uart-button.txt
Normal file
1
data/items/uart-button.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0;button-out;id;toggle;Кнопки;Освещение;order;type[UART]
|
||||||
1
data/items/uart-widget.txt
Normal file
1
data/items/uart-widget.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0;inoutput;id;anydata;Вывод;Вывод#uart;order
|
||||||
4
data/presets/7.c.txt
Normal file
4
data/presets/7.c.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
0;inoutput;text;anydataAlarm;Сигнализация;Движение:;1
|
||||||
|
0;inoutput;time;anydataTime;Сигнализация;Время:;2
|
||||||
|
0;button-in;sensor;na;na;na;3;pin[0];db[20]
|
||||||
|
0;button-out;reset;toggle;Сигнализация;Сбросить;4
|
||||||
10
data/presets/7.s.txt
Normal file
10
data/presets/7.s.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
sensor = 1
|
||||||
|
text обнаружено
|
||||||
|
time %date%
|
||||||
|
telegram text обнаружено#движение 1
|
||||||
|
end
|
||||||
|
reset = 1
|
||||||
|
text не#обнаружено
|
||||||
|
time %date%
|
||||||
|
reset 0
|
||||||
|
end
|
||||||
4
data/presets/8.c.txt
Normal file
4
data/presets/8.c.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
0;button-in;sensor;na;na;na;1;pin[0];db[20]
|
||||||
|
0;button-out;light;toggle;Освещение;Освещение;2;pin[13]
|
||||||
|
0;count-down;count;anydata;Освещение;Обратный#отчет;3
|
||||||
|
0;inoutput;period;inputDigit;Освещение;Период#включения;4
|
||||||
7
data/presets/8.s.txt
Normal file
7
data/presets/8.s.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
sensor = 1
|
||||||
|
light 1
|
||||||
|
count period
|
||||||
|
end
|
||||||
|
count = 0
|
||||||
|
light 0
|
||||||
|
end
|
||||||
2
data/presets/9.c.txt
Normal file
2
data/presets/9.c.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
0;button-out;light;toggle;Кнопки;Освещение;1;pin[13]
|
||||||
|
0;button-in;switch;na;na;na;2;pin[0];db[20]
|
||||||
3
data/presets/9.s.txt
Normal file
3
data/presets/9.s.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
switch = 1
|
||||||
|
light change
|
||||||
|
end
|
||||||
@@ -93,6 +93,8 @@
|
|||||||
"/set?addItem=impuls-out": "20.Создать импульсы через заданный промежуток времени (управление шд)",
|
"/set?addItem=impuls-out": "20.Создать импульсы через заданный промежуток времени (управление шд)",
|
||||||
"/set?addItem=count-down": "21.Таймер обратного отчета",
|
"/set?addItem=count-down": "21.Таймер обратного отчета",
|
||||||
"/set?addItem=modbus": "22.Прочитать регистр modbus устройства",
|
"/set?addItem=modbus": "22.Прочитать регистр modbus устройства",
|
||||||
|
"/set?addItem=uart-button": "23.UART кнопка (шлет свое состояние в UART)",
|
||||||
|
"/set?addItem=uart-widget": "24.UART виджет (позволяет вывести полученные данные в любой виджет)",
|
||||||
"/set?addItem=logging": "a.Логгирование и вывод в график любой величины",
|
"/set?addItem=logging": "a.Логгирование и вывод в график любой величины",
|
||||||
"/set?addItem=uptime": "b.Отобразить время работы устройства"
|
"/set?addItem=uptime": "b.Отобразить время работы устройства"
|
||||||
}
|
}
|
||||||
@@ -111,7 +113,8 @@
|
|||||||
"/set?addPreset=5.c": "5.Выключить все (пример работы сценариев)",
|
"/set?addPreset=5.c": "5.Выключить все (пример работы сценариев)",
|
||||||
"/set?addPreset=6.c": "6.Включить кнопку на определенное время (пример работы таймера обратного отчета)",
|
"/set?addPreset=6.c": "6.Включить кнопку на определенное время (пример работы таймера обратного отчета)",
|
||||||
"/set?addPreset=7.c": "7.Охранный датчик движения",
|
"/set?addPreset=7.c": "7.Охранный датчик движения",
|
||||||
"/set?addPreset=8.c": "8.Датчик движения включающий свет"
|
"/set?addPreset=8.c": "8.Датчик движения включающий свет с настраиваемой задержкой",
|
||||||
|
"/set?addPreset=9.c": "9.Управление светом с помощью выключателя и приложения"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
6
data/widgets/anydataAlarm.json
Normal file
6
data/widgets/anydataAlarm.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"widget": "anydata",
|
||||||
|
"after": "",
|
||||||
|
"color":"red",
|
||||||
|
"icon": "walk"
|
||||||
|
}
|
||||||
@@ -2,5 +2,6 @@
|
|||||||
"widget" : "input",
|
"widget" : "input",
|
||||||
"color" : "green",
|
"color" : "green",
|
||||||
"type" : "number",
|
"type" : "number",
|
||||||
|
"size" : "small",
|
||||||
"icon": "thermometer"
|
"icon": "thermometer"
|
||||||
}
|
}
|
||||||
@@ -2,5 +2,6 @@
|
|||||||
"widget" : "input",
|
"widget" : "input",
|
||||||
"color" : "orange",
|
"color" : "orange",
|
||||||
"type" : "time",
|
"type" : "time",
|
||||||
|
"size" : "small",
|
||||||
"icon": "alarm-outline"
|
"icon": "alarm-outline"
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "SoftwareSerial.h"
|
#include "SoftwareSerial.h"
|
||||||
|
|
||||||
|
extern SoftwareSerial* myUART;
|
||||||
|
|
||||||
extern void uartInit();
|
extern void uartInit();
|
||||||
extern void uartHandle();
|
extern void uartHandle();
|
||||||
extern void parse(String& incStr);
|
extern void parse(String& incStr);
|
||||||
@@ -10,7 +10,7 @@ typedef std::vector<ButtonOut> MyButtonOutVector;
|
|||||||
class ButtonOut {
|
class ButtonOut {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ButtonOut(String pin, boolean inv, String key);
|
ButtonOut(String pin, boolean inv, String key, String type);
|
||||||
|
|
||||||
~ButtonOut();
|
~ButtonOut();
|
||||||
|
|
||||||
@@ -21,6 +21,7 @@ class ButtonOut {
|
|||||||
String _pin;
|
String _pin;
|
||||||
boolean _inv;
|
boolean _inv;
|
||||||
String _key;
|
String _key;
|
||||||
|
String _type;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ void uartInit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void uartHandle() {
|
void uartHandle() {
|
||||||
|
if (myUART != nullptr) {
|
||||||
if (!jsonReadBool(configSetupJson, "uart")) {
|
if (!jsonReadBool(configSetupJson, "uart")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -36,13 +37,14 @@ void uartHandle() {
|
|||||||
incStr = "";
|
incStr = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse(String& incStr) {
|
void parse(String& incStr) {
|
||||||
if (incStr.indexOf("set") != -1) {
|
|
||||||
incStr.replace("\r\n", "");
|
incStr.replace("\r\n", "");
|
||||||
incStr.replace("\r", "");
|
incStr.replace("\r", "");
|
||||||
incStr.replace("\n", "");
|
incStr.replace("\n", "");
|
||||||
|
if (incStr.indexOf("set") != -1) {
|
||||||
incStr = deleteBeforeDelimiter(incStr, " ");
|
incStr = deleteBeforeDelimiter(incStr, " ");
|
||||||
SerialPrint("I", "UART", incStr);
|
SerialPrint("I", "UART", incStr);
|
||||||
orderBuf += incStr;
|
orderBuf += incStr;
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ void web_init() {
|
|||||||
#ifndef FLASH_SIZE_1MB
|
#ifndef FLASH_SIZE_1MB
|
||||||
addPreset(request->getParam("addPreset")->value());
|
addPreset(request->getParam("addPreset")->value());
|
||||||
#endif
|
#endif
|
||||||
|
jsonWriteStr(configSetupJson, "warning1", F("<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #ffc7c7; padding: 10px;'>Требуется перезагрузка</p></font></div>"));
|
||||||
request->redirect("/?set.device");
|
request->redirect("/?set.device");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,15 @@
|
|||||||
#include "Class/LineParsing.h"
|
#include "Class/LineParsing.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "BufferExecute.h"
|
#include "BufferExecute.h"
|
||||||
|
#include "SoftUART.h"
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
//this class save data to flash
|
//this class save data to flash
|
||||||
ButtonOut::ButtonOut(String pin, boolean inv, String key) {
|
ButtonOut::ButtonOut(String pin, boolean inv, String key, String type) {
|
||||||
_pin = pin;
|
_pin = pin;
|
||||||
_inv = inv;
|
_inv = inv;
|
||||||
_key = key;
|
_key = key;
|
||||||
|
_type = type;
|
||||||
if (_pin != "") {
|
if (_pin != "") {
|
||||||
pinMode(_pin.toInt(), OUTPUT);
|
pinMode(_pin.toInt(), OUTPUT);
|
||||||
}
|
}
|
||||||
@@ -18,6 +20,13 @@ ButtonOut::ButtonOut(String pin, boolean inv, String key) {
|
|||||||
ButtonOut::~ButtonOut() {}
|
ButtonOut::~ButtonOut() {}
|
||||||
|
|
||||||
void ButtonOut::execute(String state) {
|
void ButtonOut::execute(String state) {
|
||||||
|
if (_type == "UART") {
|
||||||
|
if (jsonReadBool(configSetupJson, "uart")) {
|
||||||
|
if (myUART != nullptr) {
|
||||||
|
myUART->print(_key + " " + state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (state != "" && _pin != "") {
|
if (state != "" && _pin != "") {
|
||||||
if (state == "change") {
|
if (state == "change") {
|
||||||
state = String(!digitalRead(_pin.toInt()));
|
state = String(!digitalRead(_pin.toInt()));
|
||||||
@@ -45,6 +54,7 @@ void buttonOut() {
|
|||||||
String key = myLineParsing.gkey();
|
String key = myLineParsing.gkey();
|
||||||
String pin = myLineParsing.gpin();
|
String pin = myLineParsing.gpin();
|
||||||
String inv = myLineParsing.ginv();
|
String inv = myLineParsing.ginv();
|
||||||
|
String type = myLineParsing.gtype();
|
||||||
|
|
||||||
bool invb = false;
|
bool invb = false;
|
||||||
if (inv.toInt() == 1) invb = true;
|
if (inv.toInt() == 1) invb = true;
|
||||||
@@ -57,7 +67,7 @@ void buttonOut() {
|
|||||||
static bool firstTime = true;
|
static bool firstTime = true;
|
||||||
if (firstTime) myButtonOut = new MyButtonOutVector();
|
if (firstTime) myButtonOut = new MyButtonOutVector();
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
myButtonOut->push_back(ButtonOut(pin, invb, key));
|
myButtonOut->push_back(ButtonOut(pin, invb, key, type));
|
||||||
|
|
||||||
sCmd.addCommand(key.c_str(), buttonOutExecute);
|
sCmd.addCommand(key.c_str(), buttonOutExecute);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "items/vInOutput.h"
|
#include "items/vInOutput.h"
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "Class/LineParsing.h"
|
#include "Class/LineParsing.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "BufferExecute.h"
|
#include "BufferExecute.h"
|
||||||
|
#include "Clock.h"
|
||||||
|
|
||||||
//this class save date to flash
|
//this class save date to flash
|
||||||
InOutput::InOutput(String key, String widget) {
|
InOutput::InOutput(String key, String widget) {
|
||||||
_key = key;
|
_key = key;
|
||||||
@@ -12,7 +12,7 @@ InOutput::InOutput(String key, String widget) {
|
|||||||
|
|
||||||
if (value == "") {
|
if (value == "") {
|
||||||
if (widget.indexOf("Digit") != -1) {
|
if (widget.indexOf("Digit") != -1) {
|
||||||
value = "52";
|
value = "25";
|
||||||
}
|
}
|
||||||
if (widget.indexOf("Time") != -1) {
|
if (widget.indexOf("Time") != -1) {
|
||||||
value = "12:00";
|
value = "12:00";
|
||||||
@@ -52,13 +52,18 @@ void inOutput() {
|
|||||||
void inOutputExecute() {
|
void inOutputExecute() {
|
||||||
String key = sCmd.order();
|
String key = sCmd.order();
|
||||||
String value = sCmd.next();
|
String value = sCmd.next();
|
||||||
|
//String type = sCmd.next();
|
||||||
|
|
||||||
|
|
||||||
if (!isDigitStr(value)) { //если значение - текст
|
if (!isDigitStr(value)) { //если значение - текст
|
||||||
if (value.indexOf(":") == -1) { //если этот текст не время
|
if (value.indexOf(":") == -1) { //если этот текст не время
|
||||||
String tmp = getValue(value);
|
String valueJson = getValue(value);
|
||||||
if(tmp != "no value") {
|
if (valueJson != "no value") { //если это ключ переменной
|
||||||
value = tmp;
|
value = valueJson;
|
||||||
value.replace("#"," ");
|
}
|
||||||
|
else { //если это просто текст
|
||||||
|
value.replace("#", " ");
|
||||||
|
value.replace("%date%", timeNow->getDateTimeDotFormated());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,9 @@ void setup() {
|
|||||||
fileSystemInit();
|
fileSystemInit();
|
||||||
SerialPrint("I", F("FS"), F("FS Init"));
|
SerialPrint("I", F("FS"), F("FS Init"));
|
||||||
|
|
||||||
|
SerialPrint("I", F("UART"), F("UART Init"));
|
||||||
|
uartInit();
|
||||||
|
|
||||||
loadConfig();
|
loadConfig();
|
||||||
SerialPrint("I", F("Conf"), F("Config Init"));
|
SerialPrint("I", F("Conf"), F("Config Init"));
|
||||||
|
|
||||||
@@ -92,8 +95,7 @@ void setup() {
|
|||||||
SerialPrint("I", F("Bus"), F("Bus Init"));
|
SerialPrint("I", F("Bus"), F("Bus Init"));
|
||||||
busInit();
|
busInit();
|
||||||
|
|
||||||
SerialPrint("I", F("UART"), F("UART Init"));
|
|
||||||
uartInit();
|
|
||||||
|
|
||||||
#ifdef SSDP_ENABLED
|
#ifdef SSDP_ENABLED
|
||||||
SerialPrint("I", F("SSDP"), F("Ssdp Init"));
|
SerialPrint("I", F("SSDP"), F("Ssdp Init"));
|
||||||
|
|||||||
Reference in New Issue
Block a user