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>
<footer>
<small>
<span id="gitRev"></span>
<span id="lastBuildTime"></span>
</small>
</footer>
<script src="/js/script.js"></script>
</body>

View File

@ -53,6 +53,12 @@ fetch('/api/settings', {
document.getElementById('timePerScreen').value = jsonData.timerSeconds / 60;
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 template = Handlebars.compile(source);
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
monitor_filters = esp32_exception_decoder, colorize
extra_scripts = post:scripts/extra_script.py
build_flags = !python scripts/git_rev.py
lib_deps =
bblanchon/ArduinoJson@^6.21.2
fbiego/ESP32Time@^2.0.1
@ -50,6 +51,8 @@ framework = arduino
board = lolin_s3_mini
board_build.partitions = partition.csv
build_flags =
!python scripts/git_rev.py
-DLAST_BUILD_TIME=$UNIX_TIME
-D IS_S3
-D IS_BW
-D CONFIG_FREERTOS_USE_TRACE_FACILITY
@ -101,18 +104,3 @@ build_flags =
-DASYNCWEBSERVER_REGEX
-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_password;
WiFiMulti wifiMulti;
WiFiManager wm;
bool screenVisible[5];
@ -42,7 +44,6 @@ void setupSoftAP()
void setupComponents()
{
#ifdef WITH_RGB_LED
pixels.begin();
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
@ -108,7 +109,35 @@ void synchronizeTime()
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();
wm.setAPCallback([&](WiFiManager *wifiManager)
{
showSetupQr(softAP_SSID, softAP_password);
@ -161,7 +190,8 @@ uint getCurrentScreen()
void setCurrentScreen(uint screen)
{
if (screen != SCREEN_CUSTOM) {
if (screen != SCREEN_CUSTOM)
{
preferences.putUInt("currentScreen", screen);
}
@ -282,7 +312,8 @@ void showNetworkSettings()
int ipAddrPos = 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;
subnetPos = subNet.indexOf('.') + 1;

View File

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

View File

@ -154,6 +154,13 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
#endif
root["ledFlashOnUpdate"] = preferences.getBool("ledFlashOnUpd", false);
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");
for (int i = 0; i < screenNameMap.size(); i++)

View File

@ -18,6 +18,7 @@ bool useBitcoind = true;
void checkBitcoinBlock(void *pvParameters)
{
int blockHeight = preferences.getUInt("blockHeight", currentBlockHeight);
HTTPClient http;
http.setReuse(true);
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);
if (blockNotifyTaskHandle == nullptr) {
if (blockNotifyTaskHandle == nullptr)
{
xTaskCreate(checkBitcoinBlock, "checkBitcoinBlock", 4096, NULL, 1, &blockNotifyTaskHandle);
vTaskSuspend(blockNotifyTaskHandle);
}

View File

@ -141,7 +141,7 @@ void initDisplays()
int *taskParam = new int;
*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);
}
epdContent = {"B", "T", "C", "L", "O", "C", "K"};