Skip to content

Commit

Permalink
WebUI config page: Remove unnecessary checkboxes (#19)
Browse files Browse the repository at this point in the history
* Optimize parameter page (less checkboxes)

* Logs for RSSIThreshold change

* Disbale NTP with unselect checkbox

* Adapt logic to modified parameter visu

* Rearrange parameter order to align with config.ini

* Add 'No Rate Check' option + harmonize functions

* Parameter without checkbox -> default enabled
  • Loading branch information
Slider0007 authored May 29, 2023
1 parent 575f504 commit d93eeb5
Show file tree
Hide file tree
Showing 18 changed files with 696 additions and 597 deletions.
32 changes: 17 additions & 15 deletions code/components/jomjol_controlGPIO/server_GPIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,8 @@ bool GpioHandler::readConfig()
// {
// std::string gpioStr = pieces_match[1];
ESP_LOGD(TAG, "conf param %s", toUpper(splitted[0]).c_str());
if (toUpper(splitted[0]) == "MAINTOPICMQTT") {
// ESP_LOGD(TAG, "MAINTOPICMQTT found");
// mainTopicMQTT = splitted[1];
} else if ((splitted[0].rfind("IO", 0) == 0) && (splitted.size() >= 6))

if ((splitted[0].rfind("IO", 0) == 0) && (splitted.size() >= 6))
{
ESP_LOGI(TAG,"Enable GP%s in %s mode", splitted[0].c_str(), splitted[1].c_str());
std::string gpioStr = splitted[0].substr(2, 2);
Expand Down Expand Up @@ -386,10 +384,24 @@ bool GpioHandler::readConfig()
registerISR = true;
}
}

if (toUpper(splitted[0]) == "LEDTYPE")
{
if (splitted[1] == "WS2812")
LEDType = LED_WS2812;
if (splitted[1] == "WS2812B")
LEDType = LED_WS2812B;
if (splitted[1] == "SK6812")
LEDType = LED_SK6812;
if (splitted[1] == "WS2813")
LEDType = LED_WS2813;
}

if (toUpper(splitted[0]) == "LEDNUMBERS")
{
LEDNumbers = stoi(splitted[1]);
}

if (toUpper(splitted[0]) == "LEDCOLOR")
{
uint8_t _r, _g, _b;
Expand All @@ -399,17 +411,7 @@ bool GpioHandler::readConfig()

LEDColor = Rgb{_r, _g, _b};
}
if (toUpper(splitted[0]) == "LEDTYPE")
{
if (splitted[1] == "WS2812")
LEDType = LED_WS2812;
if (splitted[1] == "WS2812B")
LEDType = LED_WS2812B;
if (splitted[1] == "SK6812")
LEDType = LED_SK6812;
if (splitted[1] == "WS2813")
LEDType = LED_WS2813;
}

}

if (registerISR) {
Expand Down
2 changes: 1 addition & 1 deletion code/components/jomjol_flowcontroll/ClassFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ bool ClassFlow::getNextLine(FILE* pfile, string *rt)
ESP_LOGD(TAG, "%s", zw);
*rt = zw;
*rt = trim(*rt);
while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '['))
while ((zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '['))
{
*rt = "";
if (!fgets(zw, sizeof(zw), pfile))
Expand Down
73 changes: 41 additions & 32 deletions code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,39 +71,71 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
{
splitted = ZerlegeZeile(aktparamgraph);

if ((toUpper(splitted[0]) == "ALIGNMENTALGO") && (splitted.size() > 1))
{
if (toUpper(splitted[1]) == "HIGHACCURACY")
alg_algo = 1;
else if (toUpper(splitted[1]) == "FAST")
alg_algo = 2;
else if (toUpper(splitted[1]) == "OFF") // no align algo if set to 3 = off => no draw ref //add disable aligment algo |01.2023
alg_algo = 3;
else
alg_algo = 0; // Default

#ifdef DEBUG_DETAIL_ON
std::string zw2 = "Alignment mode selected: " + std::to_string(alg_algo);
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, zw2);
#endif
}

if ((toUpper(splitted[0]) == "SEARCHFIELDX") && (splitted.size() > 1))
{
search_x = std::stoi(splitted[1]);
}

if ((toUpper(splitted[0]) == "SEARCHFIELDY") && (splitted.size() > 1))
{
search_y = std::stoi(splitted[1]);
}

if ((toUpper(splitted[0]) == "FLIPIMAGESIZE") && (splitted.size() > 1))
{
if (toUpper(splitted[1]) == "TRUE")
initialflip = true;
else
initialflip = false;
}

if ((toUpper(splitted[0]) == "INITIALMIRROR") && (splitted.size() > 1))
{
if (toUpper(splitted[1]) == "TRUE")
initialmirror = true;
else
initialmirror = false;
}

if (((toUpper(splitted[0]) == "INITALROTATE") || (toUpper(splitted[0]) == "INITIALROTATE")) && (splitted.size() > 1))
{
this->initalrotate = std::stof(splitted[1]);
}
if ((toUpper(splitted[0]) == "SEARCHFIELDX") && (splitted.size() > 1))
{
search_x = std::stoi(splitted[1]);
}
if ((toUpper(splitted[0]) == "SEARCHFIELDY") && (splitted.size() > 1))
{
search_y = std::stoi(splitted[1]);
}

if ((toUpper(splitted[0]) == "ANTIALIASING") && (splitted.size() > 1))
{
if (toUpper(splitted[1]) == "TRUE")
use_antialiasing = true;
else
use_antialiasing = false;
}
}

if ((toUpper(splitted[0]) == "SAVEALLFILES") && (splitted.size() > 1))
{
if (toUpper(splitted[1]) == "TRUE")
SaveAllFiles = true;
else
SaveAllFiles = false;
}

if ((splitted.size() == 3) && (anz_ref < 2))
{
int x=0,y=0,n=0;
Expand Down Expand Up @@ -132,29 +164,6 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
References[anz_ref].alignment_algo = alg_algo;
anz_ref++;
}
if ((toUpper(splitted[0]) == "SAVEALLFILES") && (splitted.size() > 1))
{
if (toUpper(splitted[1]) == "TRUE")
SaveAllFiles = true;
else
SaveAllFiles = false;
}
if ((toUpper(splitted[0]) == "ALIGNMENTALGO") && (splitted.size() > 1))
{
if (toUpper(splitted[1]) == "HIGHACCURACY")
alg_algo = 1;
else if (toUpper(splitted[1]) == "FAST")
alg_algo = 2;
else if (toUpper(splitted[1]) == "OFF") // no align algo if set to 3 = off => no draw ref //add disable aligment algo |01.2023
alg_algo = 3;
else
alg_algo = 0; // Default

#ifdef DEBUG_DETAIL_ON
std::string zw2 = "Alignment mode selected: " + std::to_string(alg_algo);
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, zw2);
#endif
}
}

if (References[0].alignment_algo == 2)
Expand Down
40 changes: 20 additions & 20 deletions code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,33 +326,41 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph)
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
{
splitted = ZerlegeZeile(aktparamgraph);
if ((toUpper(splitted[0]) == "ROIIMAGESLOCATION") && (splitted.size() > 1))
if ((toUpper(splitted[0]) == "MODEL") && (splitted.size() > 1))
{
this->imagesLocation = "/sdcard" + splitted[1];
this->isLogImage = true;
this->cnnmodelfile = splitted[1];
}

if ((toUpper(splitted[0]) == "LOGIMAGESELECT") && (splitted.size() > 1))
if ((toUpper(splitted[0]) == "CNNGOODTHRESHOLD") && (splitted.size() > 1))
{
LogImageSelect = splitted[1];
isLogImageSelect = true;
CNNGoodThreshold = std::stof(splitted[1]);
}

if ((toUpper(splitted[0]) == "ROIIMAGESLOCATION") && (splitted.size() > 1))
{
this->imagesLocation = "/sdcard" + splitted[1];
this->isLogImage = true;
}

if ((toUpper(splitted[0]) == "ROIIMAGESRETENTION") && (splitted.size() > 1))
{
this->imagesRetention = std::stoi(splitted[1]);
}

if ((toUpper(splitted[0]) == "MODEL") && (splitted.size() > 1))
if ((toUpper(splitted[0]) == "LOGIMAGESELECT") && (splitted.size() > 1))
{
this->cnnmodelfile = splitted[1];
LogImageSelect = splitted[1];
isLogImageSelect = true;
}
if ((toUpper(splitted[0]) == "CNNGOODTHRESHOLD") && (splitted.size() > 1))

if ((toUpper(splitted[0]) == "SAVEALLFILES") && (splitted.size() > 1))
{
CNNGoodThreshold = std::stof(splitted[1]);
if (toUpper(splitted[1]) == "TRUE")
SaveAllFiles = true;
else
SaveAllFiles = false;
}

if (splitted.size() >= 5)
{
general* _analog = GetGENERAL(splitted[0], true);
Expand All @@ -370,14 +378,6 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph)
neuroi->image = NULL;
neuroi->image_org = NULL;
}

if ((toUpper(splitted[0]) == "SAVEALLFILES") && (splitted.size() > 1))
{
if (toUpper(splitted[1]) == "TRUE")
SaveAllFiles = true;
else
SaveAllFiles = false;
}
}

if (!getNetworkParameter())
Expand Down
64 changes: 39 additions & 25 deletions code/components/jomjol_flowcontroll/ClassFlowControll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
{
splitted = ZerlegeZeile(aktparamgraph, " =");

if ((toUpper(splitted[0]) == "AUTOSTART") && (splitted.size() > 1))
{
if (toUpper(splitted[1]) == "TRUE")
Expand Down Expand Up @@ -147,40 +148,38 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
LogFile.SetLogFileRetention(std::stoi(splitted[1]));
}

// Initial timezone setup was already done during boot: see main.cpp -> setupTime()
// Check timezone here anyway due to parameter reloading without reboot
if (toUpper(splitted[0]) == "TIMEZONE") {
std::string timeZone;
if (splitted.size() <= 1) { // parameter part is empty
timeZone = "";
// Initial timeserver setup was already done during boot: see main.cpp -> setupTime()
// Check timeserver here anyway due to parameter reloading without reboot
if ((toUpper(splitted[0]) == "TIMESERVER") || (toUpper(splitted[0]) == ";TIMESERVER"))
{
std::string _timeServer = "";

if (toUpper(splitted[0]) == ";TIMESERVER") { // parameter disabled
_timeServer = ""; // Disable NTP
}
else if (splitted.size() <= 1) { // parameter part is empty
_timeServer = "pool.ntp.org"; // Use Default
}
else {
timeZone = splitted[1];
_timeServer = splitted[1];
}
setupTimeZone(timeZone);

setupTimeServer(_timeServer);
}

// Initial timeserver setup was already done during boot: see main.cpp -> setupTime()
// Check timeserver here anyway due to parameter reloading without reboot
if (toUpper(splitted[0]) == "TIMESERVER") {
std::string timeServer;
if (splitted.size() <= 1) { // Key has no value => we use this to show it as disabled
timeServer = "";
// Initial timezone setup was already done during boot: see main.cpp -> setupTime()
// Check timezone here anyway due to parameter reloading without reboot
if (toUpper(splitted[0]) == "TIMEZONE")
{
std::string _timeZone = "";
if (splitted.size() <= 1) { // parameter part is empty
_timeZone = ""; // Use Default
}
else {
timeServer = splitted[1];
_timeZone = splitted[1];
}
setupTimeServer(timeServer);
setupTimeZone(_timeZone);
}

#if (defined WLAN_USE_ROAMING_BY_SCANNING || (defined WLAN_USE_MESH_ROAMING && defined WLAN_USE_MESH_ROAMING_ACTIVATE_CLIENT_TRIGGERED_QUERIES))
if ((toUpper(splitted[0]) == "RSSITHRESHOLD") && (splitted.size() > 1))
{
int RSSIThresholdTMP = atoi(splitted[1].c_str());
RSSIThresholdTMP = min(0, max(-100, RSSIThresholdTMP)); // Verify input limits (-100 - 0)
ChangeRSSIThreshold(WLAN_CONFIG_FILE, RSSIThresholdTMP);
}
#endif

if ((toUpper(splitted[0]) == "HOSTNAME") && (splitted.size() > 1))
{
Expand All @@ -190,6 +189,21 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
LogFile.WriteToFile(ESP_LOG_WARN, TAG, "Please reboot to activate new hostname");
}
}

#if (defined WLAN_USE_ROAMING_BY_SCANNING || (defined WLAN_USE_MESH_ROAMING && defined WLAN_USE_MESH_ROAMING_ACTIVATE_CLIENT_TRIGGERED_QUERIES))
if ((toUpper(splitted[0]) == "RSSITHRESHOLD") || (toUpper(splitted[0]) == ";RSSITHRESHOLD"))
{
int _RSSIThresholdTMP;
if ((toUpper(splitted[0]) == ";RSSITHRESHOLD") || (splitted.size() <= 1)) { // parameter disabled or parameter empty
_RSSIThresholdTMP = 0; // Disable function
}
else {
_RSSIThresholdTMP = atoi(splitted[1].c_str());
_RSSIThresholdTMP = min(0, max(-100, _RSSIThresholdTMP)); // Verify input limits (-100 - 0)
}
ChangeRSSIThreshold(WLAN_CONFIG_FILE, _RSSIThresholdTMP);
}
#endif

if ((toUpper(splitted[0]) == "SETUPMODE") && (splitted.size() > 1))
{
Expand Down
1 change: 1 addition & 0 deletions code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct general {
};

enum t_RateType {
RateCheckOff,
AbsoluteChange,
RateChange
};
Expand Down
21 changes: 13 additions & 8 deletions code/components/jomjol_flowcontroll/ClassFlowInfluxDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,31 @@ bool ClassFlowInfluxDB::ReadParameter(FILE* pfile, string& aktparamgraph)
splitted = ZerlegeZeile(aktparamgraph);
std::string _param = GetParameterName(splitted[0]);

if ((toUpper(_param) == "USER") && (splitted.size() > 1))
{
this->user = splitted[1];
}
if ((toUpper(_param) == "PASSWORD") && (splitted.size() > 1))
{
this->password = splitted[1];
}
if ((toUpper(_param) == "URI") && (splitted.size() > 1))
{
this->uri = splitted[1];
}

if (((toUpper(_param) == "DATABASE")) && (splitted.size() > 1))
{
this->database = splitted[1];
}

if ((toUpper(_param) == "USER") && (splitted.size() > 1))
{
this->user = splitted[1];
}

if ((toUpper(_param) == "PASSWORD") && (splitted.size() > 1))
{
this->password = splitted[1];
}

if (((toUpper(_param) == "MEASUREMENT")) && (splitted.size() > 1))
{
handleMeasurement(splitted[0], splitted[1]);
}

if (((toUpper(_param) == "FIELD")) && (splitted.size() > 1))
{
handleFieldname(splitted[0], splitted[1]);
Expand Down
Loading

0 comments on commit d93eeb5

Please sign in to comment.