From 95c992d96612671d6c71231ffae6ccbc7b64d0ba Mon Sep 17 00:00:00 2001 From: pelgraine <140762863+pelgraine@users.noreply.github.com> Date: Sat, 2 May 2026 10:19:37 +1000 Subject: [PATCH] Hibernate now enters true deep sleep on T-Deck Pro. UITask shutdown (already occurs/unchanged): 1. BLE disabled (_serial->disable()). 2. WiFi disconnected + WIFI_OFF. 3. 4G modem shutdown(). 4. GPS power cut (PIN_GPS_EN LOW). 5. LoRa radio powerOff() (standby mode). 6. Display turnOff(). TDeckBoard::powerOff() (new): 7. btStop() -- BLE controller stop. 8. Peripheral power OFF (PIN_PERF_POWERON LOW) -- keyboard, BQ27220, sensors. 9. LoRa module power OFF (P_LORA_EN LOW) -- cuts power entirely. 10. Hold LoRa NSS high (prevents SX1262 drawing current from floating CS). 11. esp_deep_sleep_start() -- CPU halts, ~10-40uA. Wake (reset button or USB power-on): 12. ESP32-S3 cold boots. 13. TDeckBoard::begin() runs: peripheral power ON, I2C init, LoRa power ON, NSS hold released. 14. App starts fresh -- prefs/contacts/messages load from flash. No LoRa wake during hibernate -- the device is truly off. Only a hardware reset (reset button) or USB power-on wakes the device. --- variants/lilygo_tdeck_pro/TDeckBoard.h | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/variants/lilygo_tdeck_pro/TDeckBoard.h b/variants/lilygo_tdeck_pro/TDeckBoard.h index c9a09b29..ab469249 100644 --- a/variants/lilygo_tdeck_pro/TDeckBoard.h +++ b/variants/lilygo_tdeck_pro/TDeckBoard.h @@ -30,10 +30,28 @@ public: void begin(); void powerOff() override { - // Stop Bluetooth before power off - btStop(); - // Don't call parent or enterDeepSleep - let normal shutdown continue - // Display will show "hibernating..." text + // True hibernate: deep sleep with no software wake sources. + // Only a hardware reset (reset button) or USB power-on wakes the device. + // BLE, WiFi, 4G, GPS, and LoRa are already shut down by UITask + // before this method is called. + + btStop(); // Belt and suspenders -- BLE controller stop + + // Cut power to peripherals (keyboard, BQ27220, sensors) + pinMode(PIN_PERF_POWERON, OUTPUT); + digitalWrite(PIN_PERF_POWERON, LOW); + + // Cut power to LoRa module (radio already in standby from radio_driver.powerOff) + #ifdef P_LORA_EN + digitalWrite(P_LORA_EN, LOW); + #endif + + // Hold LoRa NSS high to prevent SX1262 drawing current from floating CS + rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS); + + // Enter deep sleep with no wake sources -- only hardware reset wakes + esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_OFF); + esp_deep_sleep_start(); } void enterDeepSleep(uint32_t secs, int pin_wake_btn) {