Added build version to web interface, WiFi reset button

This commit is contained in:
Djuri Baars 2023-08-23 20:22:55 +02:00
parent fdd32456bc
commit df184bb4ec
10 changed files with 2805 additions and 1345 deletions

View File

@ -193,6 +193,12 @@
</div> </div>
</div> </div>
</div> </div>
<footer>
<small>
<span id="gitRev"></span>
<span id="lastBuildTime"></span>
</small>
</footer>
<script src="/js/script.js"></script> <script src="/js/script.js"></script>
</body> </body>

View File

@ -53,6 +53,12 @@ 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;
if (jsonData.gitRev)
document.getElementById('gitRev').innerHTML = "Version: " + jsonData.gitRev;
if (jsonData.lastBuildTime)
document.getElementById('lastBuildTime').innerHTML = " / " + new Date((jsonData.lastBuildTime* 1000)).toLocaleString();
var source = document.getElementById("screens-template").innerHTML; var source = document.getElementById("screens-template").innerHTML;
var template = Handlebars.compile(source); var template = Handlebars.compile(source);
var context = { screens: jsonData.screens }; var context = { screens: jsonData.screens };

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@ monitor_speed = 115200
upload_speed = 921600 upload_speed = 921600
monitor_filters = esp32_exception_decoder, colorize monitor_filters = esp32_exception_decoder, colorize
extra_scripts = post:scripts/extra_script.py extra_scripts = post:scripts/extra_script.py
build_flags = !python scripts/git_rev.py
lib_deps = lib_deps =
bblanchon/ArduinoJson@^6.21.2 bblanchon/ArduinoJson@^6.21.2
fbiego/ESP32Time@^2.0.1 fbiego/ESP32Time@^2.0.1
@ -50,6 +51,8 @@ framework = arduino
board = lolin_s3_mini board = lolin_s3_mini
board_build.partitions = partition.csv board_build.partitions = partition.csv
build_flags = build_flags =
!python scripts/git_rev.py
-DLAST_BUILD_TIME=$UNIX_TIME
-D IS_S3 -D IS_S3
-D IS_BW -D IS_BW
-D CONFIG_FREERTOS_USE_TRACE_FACILITY -D CONFIG_FREERTOS_USE_TRACE_FACILITY
@ -101,18 +104,3 @@ build_flags =
-DASYNCWEBSERVER_REGEX -DASYNCWEBSERVER_REGEX
-D HOSTNAME="\"btclocks3d\"" -D HOSTNAME="\"btclocks3d\""
[env:esp32_c6]
platform = espressif32
board = esp32-s3-devkitc-1
board_build.partitions = partition.csv
;upload_protocol = esp-builtin
build_flags =
-D NO_DISPLAY
-D NO_MCP
-D IS_BW
-D WITH_RGB_LED
-D NEOPIXEL_COUNT=1
-D NEOPIXEL_PIN=38
-D CONFIG_ASYNC_TCP_PRIORITY=500
-DASYNCWEBSERVER_REGEX
-D HOSTNAME="\"btclocks3d\""

8
scripts/git_rev.py Normal file
View File

@ -0,0 +1,8 @@
import subprocess
revision = (
subprocess.check_output(["git", "rev-parse", "HEAD"])
.strip()
.decode("utf-8")
)
print("'-DGIT_REV=\"%s\"'" % revision)

View File

@ -28,6 +28,8 @@ Adafruit_NeoPixel pixels(NEOPIXEL_COUNT, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
String softAP_SSID; String softAP_SSID;
String softAP_password; String softAP_password;
WiFiMulti wifiMulti;
WiFiManager wm; WiFiManager wm;
bool screenVisible[5]; bool screenVisible[5];
@ -42,7 +44,6 @@ void setupSoftAP()
void setupComponents() void setupComponents()
{ {
#ifdef WITH_RGB_LED #ifdef WITH_RGB_LED
pixels.begin(); pixels.begin();
pixels.setPixelColor(0, pixels.Color(255, 0, 0)); pixels.setPixelColor(0, pixels.Color(255, 0, 0));
@ -52,8 +53,8 @@ void setupComponents()
pixels.show(); pixels.show();
#endif #endif
//delay(3000); // delay(3000);
//Serial.println("Leds should be on"); // Serial.println("Leds should be on");
#ifndef NO_MCP #ifndef NO_MCP
if (!mcp.begin_I2C()) if (!mcp.begin_I2C())
@ -75,7 +76,7 @@ void setupComponents()
pixels.setPixelColor(2, pixels.Color(0, 255, 0)); pixels.setPixelColor(2, pixels.Color(0, 255, 0));
pixels.setPixelColor(3, pixels.Color(0, 255, 0)); pixels.setPixelColor(3, pixels.Color(0, 255, 0));
pixels.show(); pixels.show();
// delay(200); // delay(200);
pinMode(MCP_INT_PIN, INPUT); pinMode(MCP_INT_PIN, INPUT);
mcp.setupInterrupts(true, false, LOW); mcp.setupInterrupts(true, false, LOW);
} }
@ -108,7 +109,35 @@ void synchronizeTime()
void setupWifi() void setupWifi()
{ {
#ifndef NO_MCP
if (mcp.digitalRead(3) == LOW)
{
pixels.setPixelColor(0, pixels.Color(0, 0, 255));
pixels.setPixelColor(1, pixels.Color(0, 0, 255));
pixels.setPixelColor(2, pixels.Color(0, 0, 255));
pixels.setPixelColor(3, pixels.Color(0, 0, 255));
pixels.show();
delay(1500);
if (mcp.digitalRead(3) == LOW)
{
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
pixels.setPixelColor(1, pixels.Color(0, 0, 255));
pixels.setPixelColor(2, pixels.Color(255, 0, 0));
pixels.setPixelColor(3, pixels.Color(0, 0, 255));
pixels.show();
Serial.println("Erasing WiFi Config, restarting");
wm.resetSettings();
ESP.restart();
}
return;
}
#endif
setupSoftAP(); setupSoftAP();
wm.setAPCallback([&](WiFiManager *wifiManager) wm.setAPCallback([&](WiFiManager *wifiManager)
{ {
showSetupQr(softAP_SSID, softAP_password); showSetupQr(softAP_SSID, softAP_password);
@ -161,7 +190,8 @@ uint getCurrentScreen()
void setCurrentScreen(uint screen) void setCurrentScreen(uint screen)
{ {
if (screen != SCREEN_CUSTOM) { if (screen != SCREEN_CUSTOM)
{
preferences.putUInt("currentScreen", screen); preferences.putUInt("currentScreen", screen);
} }
@ -273,8 +303,8 @@ void previousScreen()
void showNetworkSettings() void showNetworkSettings()
{ {
std::array<String, 7> epdContent = { "", "", "", "", "", "", ""}; std::array<String, 7> epdContent = {"", "", "", "", "", "", ""};
String ipAddr = WiFi.localIP().toString(); String ipAddr = WiFi.localIP().toString();
String subNet = WiFi.subnetMask().toString(); String subNet = WiFi.subnetMask().toString();
@ -282,9 +312,10 @@ void showNetworkSettings()
int ipAddrPos = 0; int ipAddrPos = 0;
int subnetPos = 0; int subnetPos = 0;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++)
epdContent[2 + i] = ipAddr.substring(0, ipAddr.indexOf('.')) + "/" + subNet.substring(0, subNet.indexOf('.')); {
ipAddrPos = ipAddr.indexOf('.') + 1; epdContent[2 + i] = ipAddr.substring(0, ipAddr.indexOf('.')) + "/" + subNet.substring(0, subNet.indexOf('.'));
ipAddrPos = ipAddr.indexOf('.') + 1;
subnetPos = subNet.indexOf('.') + 1; subnetPos = subNet.indexOf('.') + 1;
ipAddr = ipAddr.substring(ipAddrPos); ipAddr = ipAddr.substring(ipAddrPos);
subNet = subNet.substring(subnetPos); subNet = subNet.substring(subnetPos);
@ -333,4 +364,4 @@ void onI2CRequest()
{ {
Wire.print("I2C Packets."); Wire.print("I2C Packets.");
Serial.println("onRequest"); Serial.println("onRequest");
} }

View File

@ -2,6 +2,7 @@
#include <WiFi.h> #include <WiFi.h>
#include <Arduino.h> #include <Arduino.h>
#include <WiFiManager.h> #include <WiFiManager.h>
#include <WiFiMulti.h>
#include "config.h" #include "config.h"
#include "shared.hpp" #include "shared.hpp"

View File

@ -154,6 +154,13 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
#endif #endif
root["ledFlashOnUpdate"] = preferences.getBool("ledFlashOnUpd", false); root["ledFlashOnUpdate"] = preferences.getBool("ledFlashOnUpd", false);
root["ledBrightness"] = preferences.getUInt("ledBrightness", 128); root["ledBrightness"] = preferences.getUInt("ledBrightness", 128);
#ifdef GIT_REV
root["gitRev"] = String(GIT_REV);
#endif
#ifdef LAST_BUILD_TIME
root["lastBuildTime"] = String(LAST_BUILD_TIME);
#endif
JsonArray screens = root.createNestedArray("screens"); JsonArray screens = root.createNestedArray("screens");
for (int i = 0; i < screenNameMap.size(); i++) for (int i = 0; i < screenNameMap.size(); i++)

View File

@ -18,6 +18,7 @@ bool useBitcoind = true;
void checkBitcoinBlock(void *pvParameters) void checkBitcoinBlock(void *pvParameters)
{ {
int blockHeight = preferences.getUInt("blockHeight", currentBlockHeight); int blockHeight = preferences.getUInt("blockHeight", currentBlockHeight);
HTTPClient http; HTTPClient http;
http.setReuse(true); http.setReuse(true);
useBitcoind = wifiClientInsecure.connect(preferences.getString("rpcHost", BITCOIND_HOST).c_str(), preferences.getUInt("rpcPort", BITCOIND_PORT)); useBitcoind = wifiClientInsecure.connect(preferences.getString("rpcHost", BITCOIND_HOST).c_str(), preferences.getUInt("rpcPort", BITCOIND_PORT));
@ -103,7 +104,8 @@ void setupBlockNotify()
{ {
// bitcoinQueue = xQueueCreate(10, sizeof(BitcoinEvent) * 2); // bitcoinQueue = xQueueCreate(10, sizeof(BitcoinEvent) * 2);
if (blockNotifyTaskHandle == nullptr) { if (blockNotifyTaskHandle == nullptr)
{
xTaskCreate(checkBitcoinBlock, "checkBitcoinBlock", 4096, NULL, 1, &blockNotifyTaskHandle); xTaskCreate(checkBitcoinBlock, "checkBitcoinBlock", 4096, NULL, 1, &blockNotifyTaskHandle);
vTaskSuspend(blockNotifyTaskHandle); vTaskSuspend(blockNotifyTaskHandle);
} }

View File

@ -141,7 +141,7 @@ void initDisplays()
int *taskParam = new int; int *taskParam = new int;
*taskParam = i; *taskParam = i;
xTaskCreate(updateDisplay, "EpdUpd" + char(i), 2048, taskParam, 1, &tasks[i]); // create task xTaskCreate(updateDisplay, "EpdUpd" + char(i), 4096, taskParam, 1, &tasks[i]); // create task
// delay(1000); // delay(1000);
} }
epdContent = {"B", "T", "C", "L", "O", "C", "K"}; epdContent = {"B", "T", "C", "L", "O", "C", "K"};