mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 03:49:13 +03:00
wrong pin error warning added
This commit is contained in:
Binary file not shown.
@@ -60,6 +60,10 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"title": "{{warning2}}"
|
"title": "{{warning2}}"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"title": "{{warning3}}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "hr"
|
"type": "hr"
|
||||||
},
|
},
|
||||||
|
|||||||
Binary file not shown.
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include "ItemsList.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include "Utils/JsonUtils.h"
|
#include "Utils/JsonUtils.h"
|
||||||
|
|
||||||
@@ -26,6 +26,8 @@ class LineParsing {
|
|||||||
String _val;
|
String _val;
|
||||||
String _index;
|
String _index;
|
||||||
|
|
||||||
|
int pinErrors;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LineParsing() :
|
LineParsing() :
|
||||||
|
|
||||||
@@ -46,7 +48,9 @@ class LineParsing {
|
|||||||
_int{ "" },
|
_int{ "" },
|
||||||
_cnt{ "" },
|
_cnt{ "" },
|
||||||
_val{ "" },
|
_val{ "" },
|
||||||
_index{""}
|
_index{ "" },
|
||||||
|
|
||||||
|
pinErrors{ 0 }
|
||||||
|
|
||||||
{};
|
{};
|
||||||
|
|
||||||
@@ -106,17 +110,19 @@ class LineParsing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isPinExist(_pin.toInt()) || !isDigitStr(_pin)) {
|
||||||
|
pinErrors++;
|
||||||
|
_pin = "";
|
||||||
|
}
|
||||||
|
|
||||||
_page.replace("#", " ");
|
_page.replace("#", " ");
|
||||||
|
|
||||||
_descr.replace("#", " ");
|
_descr.replace("#", " ");
|
||||||
|
|
||||||
_descr.replace("%ver%", String(FIRMWARE_VERSION));
|
_descr.replace("%ver%", String(FIRMWARE_VERSION));
|
||||||
_descr.replace("%name%", jsonReadStr(configSetupJson, F("name")));
|
_descr.replace("%name%", jsonReadStr(configSetupJson, F("name")));
|
||||||
|
|
||||||
createWidget(_descr, _page, _order, _file, _key);
|
createWidget(_descr, _page, _order, _file, _key);
|
||||||
}
|
}
|
||||||
|
|
||||||
//jsonWriteStr(configOptionJson, _key + "_pin", _pin);
|
|
||||||
|
|
||||||
String gkey() {
|
String gkey() {
|
||||||
return _key;
|
return _key;
|
||||||
@@ -171,6 +177,15 @@ class LineParsing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int getPinErrors() {
|
||||||
|
return pinErrors;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearErrors() {
|
||||||
|
pinErrors = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
_key = "";
|
_key = "";
|
||||||
_file = "";
|
_file = "";
|
||||||
|
|||||||
@@ -12,4 +12,5 @@ extern void delChoosingItems();
|
|||||||
extern void delAllItems();
|
extern void delAllItems();
|
||||||
extern uint8_t getNewElementNumber(String file);
|
extern uint8_t getNewElementNumber(String file);
|
||||||
extern uint8_t getFreePinAll();
|
extern uint8_t getFreePinAll();
|
||||||
|
extern bool isPinExist(unsigned int num);
|
||||||
extern uint8_t getFreePinAnalog();
|
extern uint8_t getFreePinAnalog();
|
||||||
|
|||||||
14
src/Init.cpp
14
src/Init.cpp
@@ -2,6 +2,7 @@
|
|||||||
#include "BufferExecute.h"
|
#include "BufferExecute.h"
|
||||||
#include "Cmd.h"
|
#include "Cmd.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "Class/LineParsing.h"
|
||||||
#include "items/vLogging.h"
|
#include "items/vLogging.h"
|
||||||
#include "items/vImpulsOut.h"
|
#include "items/vImpulsOut.h"
|
||||||
#include "items/vButtonOut.h"
|
#include "items/vButtonOut.h"
|
||||||
@@ -20,6 +21,7 @@ void loadConfig() {
|
|||||||
|
|
||||||
jsonWriteStr(configSetupJson, "warning1", "");
|
jsonWriteStr(configSetupJson, "warning1", "");
|
||||||
jsonWriteStr(configSetupJson, "warning2", "");
|
jsonWriteStr(configSetupJson, "warning2", "");
|
||||||
|
jsonWriteStr(configSetupJson, "warning3", "");
|
||||||
|
|
||||||
jsonWriteStr(configSetupJson, "chipID", chipId);
|
jsonWriteStr(configSetupJson, "chipID", chipId);
|
||||||
jsonWriteInt(configSetupJson, "firmware_version", FIRMWARE_VERSION);
|
jsonWriteInt(configSetupJson, "firmware_version", FIRMWARE_VERSION);
|
||||||
@@ -98,7 +100,19 @@ void deviceInit() {
|
|||||||
removeFile(String("layout.txt"));
|
removeFile(String("layout.txt"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
myLineParsing.clearErrors();
|
||||||
|
|
||||||
fileCmdExecute(String(DEVICE_CONFIG_FILE));
|
fileCmdExecute(String(DEVICE_CONFIG_FILE));
|
||||||
|
|
||||||
|
int errors = myLineParsing.getPinErrors();
|
||||||
|
|
||||||
|
if (errors != 0) {
|
||||||
|
jsonWriteStr(configSetupJson, F("warning3"), 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>"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
jsonWriteStr(configSetupJson, F("warning3"), "");
|
||||||
|
}
|
||||||
|
|
||||||
//outcoming_date();
|
//outcoming_date();
|
||||||
}
|
}
|
||||||
//-------------------------------сценарии-----------------------------------------------------
|
//-------------------------------сценарии-----------------------------------------------------
|
||||||
|
|||||||
@@ -143,6 +143,16 @@ uint8_t getFreePinAll() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isPinExist(unsigned int num) {
|
||||||
|
bool ret = false;
|
||||||
|
unsigned int pins[] = { 0, 1, 2, 3, 4, 5, 9, 10, 12, 13, 14, 15, 16 };
|
||||||
|
uint8_t array_sz = sizeof(pins) / sizeof(pins[0]);
|
||||||
|
for (uint8_t i = 0; i < array_sz; i++) {
|
||||||
|
if (pins[i] == num) ret = true;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t getFreePinAnalog() {
|
uint8_t getFreePinAnalog() {
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user