diff --git a/data/set.device.json.gz b/data/set.device.json.gz index c0686cbf..0d278d22 100644 Binary files a/data/set.device.json.gz and b/data/set.device.json.gz differ diff --git a/data_ungzip/set.device.json b/data_ungzip/set.device.json index 175ff26b..ee17e69b 100644 --- a/data_ungzip/set.device.json +++ b/data_ungzip/set.device.json @@ -60,6 +60,10 @@ "type": "text", "title": "{{warning2}}" }, + { + "type": "text", + "title": "{{warning3}}" + }, { "type": "hr" }, diff --git a/doc/calculator.xlsx b/doc/calculator.xlsx index 6fd98cf2..edff5c8e 100644 Binary files a/doc/calculator.xlsx and b/doc/calculator.xlsx differ diff --git a/include/Class/LineParsing.h b/include/Class/LineParsing.h index 99a807f1..3edad798 100644 --- a/include/Class/LineParsing.h +++ b/include/Class/LineParsing.h @@ -1,12 +1,12 @@ #pragma once #include - +#include "ItemsList.h" #include "Global.h" #include "Utils/JsonUtils.h" class LineParsing { - protected: +protected: String _key; String _file; String _page; @@ -26,29 +26,33 @@ class LineParsing { String _val; String _index; - public: + int pinErrors; + +public: LineParsing() : - _key{""}, - _file{""}, - _page{""}, - _descr{""}, - _order{""}, - _addr{""}, - _reg{""}, - _pin{""}, - _map{""}, - _c{""}, - _inv{""}, - _state{""}, - _db{""}, - _type{""}, - _int{""}, - _cnt{""}, - _val{""}, - _index{""} + _key{ "" }, + _file{ "" }, + _page{ "" }, + _descr{ "" }, + _order{ "" }, + _addr{ "" }, + _reg{ "" }, + _pin{ "" }, + _map{ "" }, + _c{ "" }, + _inv{ "" }, + _state{ "" }, + _db{ "" }, + _type{ "" }, + _int{ "" }, + _cnt{ "" }, + _val{ "" }, + _index{ "" }, - {}; + pinErrors{ 0 } + + {}; void update() { //String order = sCmd.order(); @@ -106,17 +110,19 @@ class LineParsing { } } + if (!isPinExist(_pin.toInt()) || !isDigitStr(_pin)) { + pinErrors++; + _pin = ""; + } + _page.replace("#", " "); - _descr.replace("#", " "); - _descr.replace("%ver%", String(FIRMWARE_VERSION)); _descr.replace("%name%", jsonReadStr(configSetupJson, F("name"))); createWidget(_descr, _page, _order, _file, _key); } - //jsonWriteStr(configOptionJson, _key + "_pin", _pin); String gkey() { return _key; @@ -171,6 +177,15 @@ class LineParsing { } + int getPinErrors() { + return pinErrors; + } + + void clearErrors() { + pinErrors = 0; + } + + void clear() { _key = ""; _file = ""; @@ -205,7 +220,7 @@ class LineParsing { return; } - if(filename.indexOf("chart") != -1) jsonWriteStr(buf, "maxCount", _cnt); + if (filename.indexOf("chart") != -1) jsonWriteStr(buf, "maxCount", _cnt); jsonWriteStr(buf, "page", page); jsonWriteStr(buf, "order", order); diff --git a/include/ItemsList.h b/include/ItemsList.h index 54089580..2961d9e1 100644 --- a/include/ItemsList.h +++ b/include/ItemsList.h @@ -12,4 +12,5 @@ extern void delChoosingItems(); extern void delAllItems(); extern uint8_t getNewElementNumber(String file); extern uint8_t getFreePinAll(); +extern bool isPinExist(unsigned int num); extern uint8_t getFreePinAnalog(); diff --git a/src/Init.cpp b/src/Init.cpp index fc0fa3ae..cf1c4248 100644 --- a/src/Init.cpp +++ b/src/Init.cpp @@ -2,6 +2,7 @@ #include "BufferExecute.h" #include "Cmd.h" #include "Global.h" +#include "Class/LineParsing.h" #include "items/vLogging.h" #include "items/vImpulsOut.h" #include "items/vButtonOut.h" @@ -20,6 +21,7 @@ void loadConfig() { jsonWriteStr(configSetupJson, "warning1", ""); jsonWriteStr(configSetupJson, "warning2", ""); + jsonWriteStr(configSetupJson, "warning3", ""); jsonWriteStr(configSetupJson, "chipID", chipId); jsonWriteInt(configSetupJson, "firmware_version", FIRMWARE_VERSION); @@ -76,13 +78,13 @@ void deviceInit() { inOutput_KeyList = ""; inOutput_EnterCounter = -1; //======clear pwm params======= - #ifdef PwmOutEnable +#ifdef PwmOutEnable if (myPwmOut != nullptr) { myPwmOut->clear(); } pwmOut_KeyList = ""; pwmOut_EnterCounter = -1; - #endif +#endif //=================================== if (myCountDown != nullptr) { myCountDown->clear(); @@ -97,8 +99,20 @@ void deviceInit() { #else removeFile(String("layout.txt")); #endif + + myLineParsing.clearErrors(); fileCmdExecute(String(DEVICE_CONFIG_FILE)); + + int errors = myLineParsing.getPinErrors(); + + if (errors != 0) { + jsonWriteStr(configSetupJson, F("warning3"), F("

Обнаружен неверный номер пина

")); + } + else { + jsonWriteStr(configSetupJson, F("warning3"), ""); + } + //outcoming_date(); } //-------------------------------сценарии----------------------------------------------------- diff --git a/src/ItemsList.cpp b/src/ItemsList.cpp index 361b0538..aa83a65d 100644 --- a/src/ItemsList.cpp +++ b/src/ItemsList.cpp @@ -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() { #ifdef ESP8266 return 0;