Made wifi config portal timeout and refresh time configurable in WebUI
This commit is contained in:
parent
8c608eb164
commit
831e3ee144
6 changed files with 54 additions and 6 deletions
|
@ -110,3 +110,7 @@ nav {
|
||||||
.digit-blank {
|
.digit-blank {
|
||||||
content: "abc";
|
content: "abc";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#customText {
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
|
@ -116,6 +116,15 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label for="fullRefreshMin" class="col-sm-6 col-form-label">Full refresh every</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input type="text" name="fullRefreshMin" id="fullRefreshMin" class="form-control">
|
||||||
|
<span class="input-group-text">minutes</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label for="tzOffset" class="col-sm-6 col-form-label">Timezone offset</label>
|
<label for="tzOffset" class="col-sm-6 col-form-label">Timezone offset</label>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
@ -140,6 +149,15 @@
|
||||||
<input type="range" class="form-range" id="ledBrightness" name="ledBrightness" value="128" min="0" max="255">
|
<input type="range" class="form-range" id="ledBrightness" name="ledBrightness" value="128" min="0" max="255">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<label for="wpTimeout" class="col-sm-6 col-form-label">WiFi portal timeout</label>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input type="number" name="wpTimeout" id="wpTimeout" class="form-control">
|
||||||
|
<span class="input-group-text">seconds</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class=" col-sm-6">
|
<div class=" col-sm-6">
|
||||||
<div class="form-check form-switch">
|
<div class="form-check form-switch">
|
||||||
|
|
|
@ -52,6 +52,9 @@ fetch('/api/settings', {
|
||||||
|
|
||||||
document.getElementById('timePerScreen').value = jsonData.timerSeconds / 60;
|
document.getElementById('timePerScreen').value = jsonData.timerSeconds / 60;
|
||||||
document.getElementById('ledBrightness').value = jsonData.ledBrightness;
|
document.getElementById('ledBrightness').value = jsonData.ledBrightness;
|
||||||
|
document.getElementById('fullRefreshMin').value = jsonData.fullRefreshMin;
|
||||||
|
document.getElementById('wpTimeout').value = jsonData.wpTimeout;
|
||||||
|
|
||||||
|
|
||||||
if (jsonData.gitRev)
|
if (jsonData.gitRev)
|
||||||
document.getElementById('gitRev').innerHTML = "Version: " + jsonData.gitRev;
|
document.getElementById('gitRev').innerHTML = "Version: " + jsonData.gitRev;
|
||||||
|
|
|
@ -138,7 +138,7 @@ void setupWifi()
|
||||||
|
|
||||||
setupSoftAP();
|
setupSoftAP();
|
||||||
|
|
||||||
wm.setConfigPortalTimeout(600);
|
wm.setConfigPortalTimeout(preferences.getUInt("wpTimeout", 600));
|
||||||
wm.setAPCallback([&](WiFiManager *wifiManager)
|
wm.setAPCallback([&](WiFiManager *wifiManager)
|
||||||
{
|
{
|
||||||
showSetupQr(softAP_SSID, softAP_password);
|
showSetupQr(softAP_SSID, softAP_password);
|
||||||
|
|
|
@ -145,6 +145,8 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
|
||||||
root["bgColor"] = getBgColor();
|
root["bgColor"] = getBgColor();
|
||||||
root["timerSeconds"] = timerSeconds;
|
root["timerSeconds"] = timerSeconds;
|
||||||
root["timerRunning"] = timerRunning;
|
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["tzOffset"] = preferences.getInt("gmtOffset", TIME_OFFSET_SECONDS) / 60;
|
||||||
root["useBitcoinNode"] = preferences.getBool("useNode", false);
|
root["useBitcoinNode"] = preferences.getBool("useNode", false);
|
||||||
root["rpcPort"] = preferences.getUInt("rpcPort", BITCOIND_PORT);
|
root["rpcPort"] = preferences.getUInt("rpcPort", BITCOIND_PORT);
|
||||||
|
@ -228,6 +230,26 @@ void onApiSettingsPost(AsyncWebServerRequest *request)
|
||||||
settingsChanged = true;
|
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++)
|
for (int i = 0; i < screenNameMap.size(); i++)
|
||||||
{
|
{
|
||||||
String key = "screen[" + String(i) + "]";
|
String key = "screen[" + String(i) + "]";
|
||||||
|
@ -335,6 +357,7 @@ void onApiShowText(AsyncWebServerRequest *request)
|
||||||
{
|
{
|
||||||
AsyncWebParameter *p = request->getParam("t");
|
AsyncWebParameter *p = request->getParam("t");
|
||||||
String t = p->value();
|
String t = p->value();
|
||||||
|
t.toUpperCase(); // This is needed as long as lowercase letters are glitchy
|
||||||
CustomTextScreen::setSimpleText(t);
|
CustomTextScreen::setSimpleText(t);
|
||||||
}
|
}
|
||||||
setCurrentScreen(SCREEN_CUSTOM);
|
setCurrentScreen(SCREEN_CUSTOM);
|
||||||
|
|
|
@ -321,7 +321,7 @@ void updateDisplay(void *pvParameters)
|
||||||
bool updatePartial = true;
|
bool updatePartial = true;
|
||||||
|
|
||||||
// Full Refresh every half hour
|
// 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;
|
updatePartial = false;
|
||||||
lastFullRefresh[epdIndex] = millis();
|
lastFullRefresh[epdIndex] = millis();
|
||||||
|
|
Loading…
Reference in a new issue