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,12 +1,12 @@
|
|||||||
#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"
|
||||||
|
|
||||||
class LineParsing {
|
class LineParsing {
|
||||||
protected:
|
protected:
|
||||||
String _key;
|
String _key;
|
||||||
String _file;
|
String _file;
|
||||||
String _page;
|
String _page;
|
||||||
@@ -26,29 +26,33 @@ class LineParsing {
|
|||||||
String _val;
|
String _val;
|
||||||
String _index;
|
String _index;
|
||||||
|
|
||||||
public:
|
int pinErrors;
|
||||||
|
|
||||||
|
public:
|
||||||
LineParsing() :
|
LineParsing() :
|
||||||
|
|
||||||
_key{""},
|
_key{ "" },
|
||||||
_file{""},
|
_file{ "" },
|
||||||
_page{""},
|
_page{ "" },
|
||||||
_descr{""},
|
_descr{ "" },
|
||||||
_order{""},
|
_order{ "" },
|
||||||
_addr{""},
|
_addr{ "" },
|
||||||
_reg{""},
|
_reg{ "" },
|
||||||
_pin{""},
|
_pin{ "" },
|
||||||
_map{""},
|
_map{ "" },
|
||||||
_c{""},
|
_c{ "" },
|
||||||
_inv{""},
|
_inv{ "" },
|
||||||
_state{""},
|
_state{ "" },
|
||||||
_db{""},
|
_db{ "" },
|
||||||
_type{""},
|
_type{ "" },
|
||||||
_int{""},
|
_int{ "" },
|
||||||
_cnt{""},
|
_cnt{ "" },
|
||||||
_val{""},
|
_val{ "" },
|
||||||
_index{""}
|
_index{ "" },
|
||||||
|
|
||||||
{};
|
pinErrors{ 0 }
|
||||||
|
|
||||||
|
{};
|
||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
//String order = sCmd.order();
|
//String order = sCmd.order();
|
||||||
@@ -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 = "";
|
||||||
@@ -205,7 +220,7 @@ class LineParsing {
|
|||||||
return;
|
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, "page", page);
|
||||||
jsonWriteStr(buf, "order", order);
|
jsonWriteStr(buf, "order", order);
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
18
src/Init.cpp
18
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);
|
||||||
@@ -76,13 +78,13 @@ void deviceInit() {
|
|||||||
inOutput_KeyList = "";
|
inOutput_KeyList = "";
|
||||||
inOutput_EnterCounter = -1;
|
inOutput_EnterCounter = -1;
|
||||||
//======clear pwm params=======
|
//======clear pwm params=======
|
||||||
#ifdef PwmOutEnable
|
#ifdef PwmOutEnable
|
||||||
if (myPwmOut != nullptr) {
|
if (myPwmOut != nullptr) {
|
||||||
myPwmOut->clear();
|
myPwmOut->clear();
|
||||||
}
|
}
|
||||||
pwmOut_KeyList = "";
|
pwmOut_KeyList = "";
|
||||||
pwmOut_EnterCounter = -1;
|
pwmOut_EnterCounter = -1;
|
||||||
#endif
|
#endif
|
||||||
//===================================
|
//===================================
|
||||||
if (myCountDown != nullptr) {
|
if (myCountDown != nullptr) {
|
||||||
myCountDown->clear();
|
myCountDown->clear();
|
||||||
@@ -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