From a9de80d24b104181f4090f4b7b630e12cf094fd5 Mon Sep 17 00:00:00 2001 From: Jonas Diemer Date: Thu, 18 Dec 2025 16:04:34 +0100 Subject: [PATCH] Reordered boot sequence to load settings in time. --- src/main.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8fff9da..9f25569 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -75,20 +75,16 @@ void enterNewActivity(Activity* activity) { // Verify long press on wake-up from deep sleep void verifyWakeupLongPress() { // Give the user up to 1000ms to start holding the power button, and must hold for SETTINGS.getPowerButtonDuration() - const auto start = millis(); bool abort = false; - Serial.printf("[%lu] [ ] Verifying power button press\n", millis()); inputManager.update(); + // Verify the user has actually pressed while (!inputManager.isPressed(InputManager::BTN_POWER) && millis() - start < 1000) { - delay(50); + delay(10); // only wait 10ms each iteration to not delay too much in case of short configured duration. inputManager.update(); } - // Return immediately if power button duration is less than 100ms - if (SETTINGS.getPowerButtonDuration() < 100) return; - if (inputManager.isPressed(InputManager::BTN_POWER)) { do { delay(10); @@ -156,14 +152,20 @@ void setup() { Serial.printf("[%lu] [ ] Starting CrossPoint version " CROSSPOINT_VERSION "\n", millis()); inputManager.begin(); - // verifyWakeupLongPress(); - // Initialize pins pinMode(BAT_GPIO0, INPUT); // Initialize SPI with custom pins SPI.begin(EPD_SCLK, SD_SPI_MISO, EPD_MOSI, EPD_CS); + // SD Card Initialization + SD.begin(SD_SPI_CS, SPI, SPI_FQ); + + SETTINGS.loadFromFile(); + + // verify power button press duration after we've read settings. + verifyWakeupLongPress(); + // Initialize display einkDisplay.begin(); Serial.printf("[%lu] [ ] Display initialized\n", millis()); @@ -176,10 +178,6 @@ void setup() { exitActivity(); enterNewActivity(new BootActivity(renderer, inputManager)); - // SD Card Initialization - SD.begin(SD_SPI_CS, SPI, SPI_FQ); - - SETTINGS.loadFromFile(); APP_STATE.loadFromFile(); if (APP_STATE.openEpubPath.empty()) { onGoHome();