mirror of
https://git.btclock.dev/btclock/btclock_v3
synced 2025-06-19 05:55:06 +00:00
feat: Add restore screen after zap setting
This commit is contained in:
parent
2ac2a62c61
commit
7853bf3e06
@ -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 {
|
||||
|
@ -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,6 +296,7 @@ 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
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user