+
+
+
+
+
+
+ sec
+
+
Short amounts might shorten lifespan.
+
+
diff --git a/data/src/js/script.ts b/data/src/js/script.ts
index 1000cf6..8c46796 100644
--- a/data/src/js/script.ts
+++ b/data/src/js/script.ts
@@ -19,39 +19,65 @@ toTime = (secs) => {
return obj;
}
-getBcStatus = () => {
- fetch('/api/status', {
- method: 'get'
- })
- .then(response => response.json())
- .then(jsonData => {
- var source = document.getElementById("entry-template").innerHTML;
- var template = Handlebars.compile(source);
+let processStatusData = (jsonData) => {
+ var source = document.getElementById("entry-template").innerHTML;
+ var template = Handlebars.compile(source);
- var context = {
- timerRunning: jsonData.timerRunning,
- memUsage: Math.round(jsonData.espFreeHeap / jsonData.espHeapSize * 100),
- memFree: Math.round(jsonData.espFreeHeap / 1024),
- memTotal: Math.round(jsonData.espHeapSize / 1024),
- 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)) : [],
- connectionStatus: jsonData.connectionStatus
- };
+ var context = {
+ timerRunning: jsonData.timerRunning,
+ memUsage: Math.round(jsonData.espFreeHeap / jsonData.espHeapSize * 100),
+ memFree: Math.round(jsonData.espFreeHeap / 1024),
+ memTotal: Math.round(jsonData.espHeapSize / 1024),
+ uptime: toTime(jsonData.espUptime),
+ currentScreen: jsonData.currentScreen,
+ rendered: jsonData.data,
+ data: jsonData.data,
+ screens: screens,
+ ledStatus: jsonData.ledStatus ? jsonData.ledStatus.map((t) => (t).toString(16)) : [],
+ connectionStatus: jsonData.connectionStatus
+ };
- document.getElementById('output').innerHTML = template(context);
- })
- .catch(err => {
- //error block
- });
+ document.getElementById('output').innerHTML = template(context);
}
-interval = setInterval(getBcStatus, 2500);
-getBcStatus();
+
+if (!!window.EventSource) {
+ var source = new EventSource('/events');
+
+ source.addEventListener('open', function (e) {
+ console.log("Status EventSource Connected");
+ if (e.data) {
+ processStatusData(JSON.parse(e.data));
+ }
+ }, false);
+
+ source.addEventListener('error', function (e) {
+ if (e.target.readyState != EventSource.OPEN) {
+ console.log("Status EventSource Disconnected");
+ }
+ source.close();
+ }, false);
+
+ source.addEventListener('status', function (e) {
+ processStatusData(JSON.parse(e.data));
+ }, false);
+}
+
+
+// getBcStatus = () => {
+// fetch('/api/status', {
+// method: 'get'
+// })
+// .then(response => response.json())
+// .then()
+// .catch(err => {
+// //error block
+// });
+// }
+
+// interval = setInterval(getBcStatus, 2500);
+// getBcStatus();
fetch('/api/settings', {
method: 'get'
@@ -77,17 +103,18 @@ fetch('/api/settings', {
if (jsonData.useBitcoinNode)
document.getElementById('useBitcoinNode').checked = true;
- let nodeFields = ["rpcHost", "rpcPort", "rpcUser", "tzOffset"];
+ // let nodeFields = ["rpcHost", "rpcPort", "rpcUser", "tzOffset"];
- for (let n of nodeFields) {
- document.getElementById(n).value = jsonData[n];
- }
+ // for (let n of nodeFields) {
+ // document.getElementById(n).value = jsonData[n];
+ // }
document.getElementById('timePerScreen').value = jsonData.timerSeconds / 60;
document.getElementById('ledBrightness').value = jsonData.ledBrightness;
document.getElementById('fullRefreshMin').value = jsonData.fullRefreshMin;
- document.getElementById('wpTimeout').value = jsonData.wpTimeout;
+ document.getElementById('tzOffset').value = jsonData.tzOffset;
document.getElementById('mempoolInstance').value = jsonData.mempoolInstance;
+ document.getElementById('minSecPriceUpd').value = jsonData.minSecPriceUpd;
if (jsonData.gitRev)
document.getElementById('gitRev').innerHTML = "Version: " + jsonData.gitRev;
diff --git a/platformio.ini b/platformio.ini
index d946a88..e838636 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -24,12 +24,11 @@ board_build.partitions = partition.csv
build_flags =
!python scripts/git_rev.py
-DLAST_BUILD_TIME=$UNIX_TIME
- -DASYNCWEBSERVER_REGEX
- -D ARDUINO_USB_CDC_ON_BOOT
+ -DARDUINO_USB_CDC_ON_BOOT
-fexceptions
build_unflags =
- -fno-exceptions
-Werror=all
+ -fno-exceptions
lib_deps =
bblanchon/ArduinoJson@^6.21.3
esphome/Improv@^1.2.3
@@ -48,4 +47,6 @@ build_flags =
-D MCP_INT_PIN=8
-D NEOPIXEL_PIN=34
-D NEOPIXEL_COUNT=4
- -D NUM_SCREENS=7
\ No newline at end of file
+ -D NUM_SCREENS=7
+build_unflags =
+ ${btclock_base.build_unflags}
diff --git a/src/lib/block_notify.cpp b/src/lib/block_notify.cpp
index 6378a50..7df45bf 100644
--- a/src/lib/block_notify.cpp
+++ b/src/lib/block_notify.cpp
@@ -32,7 +32,7 @@ void setupBlockNotify()
{
String blockHeightStr = http->getString();
currentBlockHeight = blockHeightStr.toInt();
- xTaskNotifyGive(blockUpdateTaskHandle);
+ // xTaskNotifyGive(blockUpdateTaskHandle);
}
// std::strcpy(wsServer, String("wss://" + mempoolInstance + "/api/v1/ws").c_str());
@@ -95,7 +95,10 @@ void onWebsocketMessage(esp_websocket_event_data_t *event_data)
if (blockUpdateTaskHandle != nullptr) {
xTaskNotifyGive(blockUpdateTaskHandle);
- queueLedEffect(LED_FLASH_BLOCK_NOTIFY);
+ if (preferences.getBool("ledFlashOnUpd", false)) {
+ vTaskDelay(pdMS_TO_TICKS(250)); // Wait until screens are updated
+ queueLedEffect(LED_FLASH_BLOCK_NOTIFY);
+ }
}
}
diff --git a/src/lib/config.cpp b/src/lib/config.cpp
index 125c9ab..13b2a0a 100644
--- a/src/lib/config.cpp
+++ b/src/lib/config.cpp
@@ -10,6 +10,7 @@ std::map
screenNameMap;
void setup()
{
+ setupPreferences();
setupHardware();
if (mcp.digitalRead(3) == LOW)
{
@@ -20,7 +21,6 @@ void setup()
setupDisplays();
tryImprovSetup();
- setupPreferences();
setupWebserver();
// setupWifi();
@@ -112,7 +112,13 @@ void setupTimers()
void finishSetup()
{
- clearLeds();
+
+ if (preferences.getBool("ledStatus", false)) {
+ setLights(preferences.getUInt("ledColor", 0xFFCC00));
+ } else {
+ clearLeds();
+ }
+
}
std::map getScreenNameMap() {
@@ -122,7 +128,7 @@ std::map getScreenNameMap() {
void setupHardware()
{
setupLeds();
-
+ WiFi.setHostname(getMyHostname().c_str());;
if (psramInit())
{
Serial.println(F("PSRAM is correctly initialized"));
diff --git a/src/lib/config.hpp b/src/lib/config.hpp
index 65b2c17..7eeb0e2 100644
--- a/src/lib/config.hpp
+++ b/src/lib/config.hpp
@@ -9,6 +9,7 @@
#include
#include "epd.hpp"
#include "improv.hpp"
+#include