Compare commits

...

3 Commits

Author SHA1 Message Date
Djuri Baars
3149259309
chore: update webui 2025-06-12 16:28:12 +02:00
Djuri Baars
b185d86186
chore: dependency update 2025-06-12 16:10:33 +02:00
Djuri Baars
7853bf3e06
feat: Add restore screen after zap setting 2025-06-12 16:10:17 +02:00
6 changed files with 20 additions and 4 deletions

2
data

@ -1 +1 @@
Subproject commit 8389ed8e36a9a1a7a39ca31f53324a0949aedb1d
Subproject commit f5a9133cabfbab82325275575545c12f7aacf8f2

View File

@ -40,7 +40,7 @@ lib_deps =
bblanchon/ArduinoJson@^7.4.1
esp32async/ESPAsyncWebServer @ 3.7.7
robtillaart/MCP23017@^0.9.1
adafruit/Adafruit NeoPixel@^1.12.5
adafruit/Adafruit NeoPixel@^1.15.1
https://github.com/dsbaars/universal_pin#feature/mcp23017_rt
https://github.com/dsbaars/GxEPD2#universal_pin
https://github.com/tzapu/WiFiManager.git#v2.0.17

View File

@ -86,6 +86,7 @@
#define DEFAULT_CUSTOM_ENDPOINT "ws-staging.btclock.dev"
#define DEFAULT_CUSTOM_ENDPOINT_DISABLE_SSL false
#define DEFAULT_MOW_MODE false
#define DEFAULT_SCREEN_RESTORE_AFTER_ZAP true
// Define data source types
enum DataSourceType {

View File

@ -10,6 +10,14 @@ boolean nostrIsSubscribing = true;
String subIdZap;
void screenRestoreAfterZapCallback(TimerHandle_t xTimer)
{
Serial.println("Restoring screen after zap");
int screenBeforeZap = (int)(uintptr_t)pvTimerGetTimerID(xTimer);
ScreenHandler::setCurrentScreen(screenBeforeZap);
xTimerDelete(xTimer, 0);
}
void setupNostrNotify(bool asDatasource, bool zapNotify)
{
nostr::esp32::ESP32Platform::initNostr(false);
@ -288,12 +296,13 @@ void handleNostrZapCallback(const String &subId, nostr::SignedNostrEvent *event)
}
uint64_t timerPeriod = 0;
int screenBeforeZap = ScreenHandler::getCurrentScreen();
if (isTimerActive())
{
// store timer periode before making inactive to prevent artifacts
timerPeriod = getTimerSeconds();
esp_timer_stop(screenRotateTimer);
}
}
ScreenHandler::setCurrentScreen(SCREEN_CUSTOM);
EPDManager::getInstance().setContent(textEpdContent);
@ -306,6 +315,10 @@ void handleNostrZapCallback(const String &subId, nostr::SignedNostrEvent *event)
{
esp_timer_start_periodic(screenRotateTimer,
timerPeriod * usPerSecond);
} else if (preferences.getBool("scrnRestoreZap", DEFAULT_SCREEN_RESTORE_AFTER_ZAP)) {
TimerHandle_t screenRestoreAfterZapTimer = xTimerCreate("screenRestoreAfterZap", pdMS_TO_TICKS(getTimerSeconds() * msPerSecond), pdFALSE, (void*)(uintptr_t)screenBeforeZap, screenRestoreAfterZapCallback);
Serial.println("Starting screen restore after zap");
xTimerStart(screenRestoreAfterZapTimer, 0);
}
}

View File

@ -66,6 +66,7 @@ const PROGMEM int screens[SCREEN_COUNT] = {
SCREEN_BLOCK_FEE_RATE};
const int usPerSecond = 1000000;
const int usPerMinute = 60 * usPerSecond;
const int msPerSecond = 1000;
// extern const char *github_root_ca;
// extern const char *isrg_root_x1cert;

View File

@ -18,7 +18,7 @@ static const char *const PROGMEM boolSettings[] = {"ledTestOnPower", "ledFlashOn
"mempoolSecure", "bitaxeEnabled",
"miningPoolStats", "verticalDesc",
"nostrZapNotify", "httpAuthEnabled",
"enableDebugLog", "ceDisableSSL", "dndEnabled", "dndTimeBasedEnabled"};
"enableDebugLog", "ceDisableSSL", "dndEnabled", "dndTimeBasedEnabled", "scrnRestoreZap"};
AsyncWebServer server(80);
AsyncEventSource events("/events");
@ -717,6 +717,7 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
root["nostrZapNotify"] = preferences.getBool("nostrZapNotify", DEFAULT_ZAP_NOTIFY_ENABLED);
root["nostrZapPubkey"] = preferences.getString("nostrZapPubkey", DEFAULT_ZAP_NOTIFY_PUBKEY);
root["ledFlashOnZap"] = preferences.getBool("ledFlashOnZap", DEFAULT_LED_FLASH_ON_ZAP);
root["scrnRestoreZap"] = preferences.getBool("scrnRestoreZap", DEFAULT_SCREEN_RESTORE_AFTER_ZAP);
root["fontName"] = preferences.getString("fontName", DEFAULT_FONT_NAME);
root["availableFonts"] = FontNames::getAvailableFonts();
// Custom endpoint settings (only used for CUSTOM_SOURCE)