Made wifi config portal timeout and refresh time configurable in WebUI

This commit is contained in:
Djuri 2023-10-07 11:46:34 +02:00
parent 8c608eb164
commit 831e3ee144
6 changed files with 54 additions and 6 deletions

View file

@ -138,7 +138,7 @@ void setupWifi()
setupSoftAP();
wm.setConfigPortalTimeout(600);
wm.setConfigPortalTimeout(preferences.getUInt("wpTimeout", 600));
wm.setAPCallback([&](WiFiManager *wifiManager)
{
showSetupQr(softAP_SSID, softAP_password);

View file

@ -145,6 +145,8 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
root["bgColor"] = getBgColor();
root["timerSeconds"] = timerSeconds;
root["timerRunning"] = timerRunning;
root["fullRefreshMin"] = preferences.getUInt("fullRefreshMin", 30);
root["wpTimeout"] = preferences.getUInt("wpTimeout", 600);
root["tzOffset"] = preferences.getInt("gmtOffset", TIME_OFFSET_SECONDS) / 60;
root["useBitcoinNode"] = preferences.getBool("useNode", false);
root["rpcPort"] = preferences.getUInt("rpcPort", BITCOIND_PORT);
@ -228,6 +230,26 @@ void onApiSettingsPost(AsyncWebServerRequest *request)
settingsChanged = true;
}
if (request->hasParam("fullRefreshMin", true))
{
AsyncWebParameter *fullRefreshMin = request->getParam("fullRefreshMin", true);
preferences.putUInt("fullRefreshMin", fullRefreshMin->value().toInt());
Serial.print("Set full refresh minutes to ");
Serial.println(fullRefreshMin->value().c_str());
settingsChanged = true;
}
if (request->hasParam("wpTimeout", true))
{
AsyncWebParameter *wpTimeout = request->getParam("wpTimeout", true);
preferences.putUInt("wpTimeout", wpTimeout->value().toInt());
Serial.print("Set WiFi portal timeout seconds to ");
Serial.println(wpTimeout->value().c_str());
settingsChanged = true;
}
for (int i = 0; i < screenNameMap.size(); i++)
{
String key = "screen[" + String(i) + "]";
@ -335,6 +357,7 @@ void onApiShowText(AsyncWebServerRequest *request)
{
AsyncWebParameter *p = request->getParam("t");
String t = p->value();
t.toUpperCase(); // This is needed as long as lowercase letters are glitchy
CustomTextScreen::setSimpleText(t);
}
setCurrentScreen(SCREEN_CUSTOM);

View file

@ -321,7 +321,7 @@ void updateDisplay(void *pvParameters)
bool updatePartial = true;
// Full Refresh every half hour
if (!lastFullRefresh[epdIndex] || (millis() - lastFullRefresh[epdIndex]) > (30 * 60 * 1000))
if (!lastFullRefresh[epdIndex] || (millis() - lastFullRefresh[epdIndex]) > (preferences.getUInt("fullRefreshMin", 30) * 60 * 1000))
{
updatePartial = false;
lastFullRefresh[epdIndex] = millis();