increase vTick for time screen, add lost IP event handler and system status to web interface
This commit is contained in:
parent
7cc524f75f
commit
5c165633d1
7 changed files with 49 additions and 3 deletions
|
@ -20,6 +20,7 @@ $form-range-track-bg: #fff;
|
|||
@import "../node_modules/bootstrap/scss/navbar";
|
||||
@import "../node_modules/bootstrap/scss/nav";
|
||||
@import "../node_modules/bootstrap/scss/card";
|
||||
@import "../node_modules/bootstrap/scss/progress";
|
||||
|
||||
@import "../node_modules/bootstrap/scss/helpers";
|
||||
@import "../node_modules/bootstrap/scss/utilities/api";
|
||||
|
|
|
@ -57,6 +57,20 @@
|
|||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<hr>
|
||||
<div>
|
||||
<div class="progress" role="progressbar" aria-label="Memory usage" aria-valuenow="{{ memUsage }}" aria-valuemin="0" aria-valuemax="100">
|
||||
<div class="progress-bar progress-bar-striped" style="width: {{ memUsage }}%">{{ memUsage }}%</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>Memory usage</div>
|
||||
<div>{{ memFree }} / {{ memTotal }} kB</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div>
|
||||
<p>Uptime: {{#if uptime.h }}{{ uptime.h }}h {{/if}}{{ uptime.m }}m {{ uptime.s }}s</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
|
|
@ -2,6 +2,23 @@ import './helpers.js';
|
|||
|
||||
var screens = ["Block Height", "Moscow Time", "Ticker", "Time", "Halving countdown"];
|
||||
|
||||
toTime = (secs) => {
|
||||
var hours = Math.floor(secs / (60 * 60));
|
||||
|
||||
var divisor_for_minutes = secs % (60 * 60);
|
||||
var minutes = Math.floor(divisor_for_minutes / 60);
|
||||
|
||||
var divisor_for_seconds = divisor_for_minutes % 60;
|
||||
var seconds = Math.ceil(divisor_for_seconds);
|
||||
|
||||
var obj = {
|
||||
"h": hours,
|
||||
"m": minutes,
|
||||
"s": seconds
|
||||
};
|
||||
return obj;
|
||||
}
|
||||
|
||||
getBcStatus = () => {
|
||||
fetch('/api/status', {
|
||||
method: 'get'
|
||||
|
@ -11,7 +28,7 @@ getBcStatus = () => {
|
|||
var source = document.getElementById("entry-template").innerHTML;
|
||||
var template = Handlebars.compile(source);
|
||||
|
||||
var context = { timerRunning: jsonData.timerRunning, currentScreen: jsonData.currentScreen, rendered: jsonData.rendered, data: jsonData.data, screens: screens, ledStatus: jsonData.ledStatus ? jsonData.ledStatus.map((t) => (t).toString(16)) : [] };
|
||||
var context = { timerRunning: jsonData.timerRunning, memUsage: Math.round(jsonData.espFreeHeap / jsonData.espHeapSize * 100), memFree: (jsonData.espFreeHeap / 1000), memTotal: (jsonData.espHeapSize / 1000), uptime: toTime(jsonData.espUptime), currentScreen: jsonData.currentScreen, rendered: jsonData.rendered, data: jsonData.data, screens: screens, ledStatus: jsonData.ledStatus ? jsonData.ledStatus.map((t) => (t).toString(16)) : [] };
|
||||
|
||||
|
||||
document.getElementById('output').innerHTML = template(context);
|
||||
|
|
|
@ -64,7 +64,7 @@ void setupComponents()
|
|||
// Serial.println(F("Leds should be on"));
|
||||
|
||||
#ifndef NO_MCP
|
||||
if (!mcp.begin_I2C())
|
||||
if (!mcp.begin_I2C(0x20))
|
||||
{
|
||||
Serial.println(F("Error MCP23017"));
|
||||
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
|
||||
|
@ -143,6 +143,8 @@ void setupWifi()
|
|||
}
|
||||
#endif
|
||||
|
||||
//WiFi.persistent(true);
|
||||
WiFi.enableLongRange(false);
|
||||
setupSoftAP();
|
||||
|
||||
wm.setConfigPortalTimeout(preferences.getUInt("wpTimeout", 600));
|
||||
|
@ -156,6 +158,12 @@ void setupWifi()
|
|||
softAP_password.c_str()); });
|
||||
|
||||
bool ac = wm.autoConnect(softAP_SSID.c_str(), softAP_password.c_str());
|
||||
WiFi.onEvent(onWifiLostIp, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_LOST_IP);
|
||||
|
||||
}
|
||||
|
||||
void onWifiLostIp(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
void setupPreferences()
|
||||
|
|
|
@ -28,6 +28,7 @@ void setCurrentScreen(uint screen);
|
|||
void handleScreenTasks(uint screen);
|
||||
void showNetworkSettings();
|
||||
void toggleScreenTimer();
|
||||
void onWifiLostIp(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||
|
||||
void timebasedChangeTask(void *parameter);
|
||||
|
||||
|
|
|
@ -76,6 +76,11 @@ void onApiStatus(AsyncWebServerRequest *request)
|
|||
root["currentScreen"] = String(getCurrentScreen());
|
||||
root["timerRunning"] = timerRunning;
|
||||
root["numScreens"] = NUM_SCREENS;
|
||||
root["espUptime"] = esp_timer_get_time() / 1000000;
|
||||
root["espFreeHeap"] = ESP.getFreeHeap();
|
||||
root["espHeapSize"] = ESP.getHeapSize();
|
||||
root["espFreePsram"] = ESP.getFreePsram();
|
||||
root["espPsramSize"] = ESP.getPsramSize();
|
||||
JsonArray data = root.createNestedArray("data");
|
||||
JsonArray rendered = root.createNestedArray("rendered");
|
||||
String epdContent[NUM_SCREENS];
|
||||
|
|
|
@ -28,7 +28,7 @@ void minuteTask(void * parameter) {
|
|||
if(rtc.getSecond() != 0) { // Reset the event triggered flag if the second is not 0
|
||||
eventTriggered = false;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(500)); // Sleep for 500 milliseconds to avoid busy waiting
|
||||
vTaskDelay(pdMS_TO_TICKS(1000)); // Sleep for 1000 milliseconds to avoid busy waiting
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue