From f19ccf70789bd93831605e86aaaf9a447c0fd533 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 18 May 2024 01:07:38 +0200 Subject: [PATCH] Added deep sleep support on T3S3 --- Boards.h | 13 ++++++++----- Display.h | 21 +++++++++++++++------ RNode_Firmware.ino | 12 +++++++++++- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Boards.h b/Boards.h index e9c069e..7816e00 100644 --- a/Boards.h +++ b/Boards.h @@ -79,6 +79,7 @@ #define HAS_EEPROM false #define HAS_INPUT false #define HAS_SLEEP false + #define PIN_DISP_SLEEP -1 #define VALIDATE_FIRMWARE true #if defined(ENABLE_TCXO) @@ -353,11 +354,13 @@ #define HAS_SD false #define HAS_EEPROM true - // #define HAS_INPUT true - // #define HAS_SLEEP true - // #define PIN_WAKEUP GPIO_NUM_0 - // #define WAKEUP_LEVEL 0 - // const int pin_btn_usr1 = 0; + #define HAS_INPUT true + #define HAS_SLEEP true + #define PIN_WAKEUP GPIO_NUM_0 + #define WAKEUP_LEVEL 0 + // #define PIN_DISP_SLEEP 21 + // #define DISP_SLEEP_LEVEL HIGH + const int pin_btn_usr1 = 0; const int pin_cs = 7; const int pin_reset = 8; diff --git a/Display.h b/Display.h index a988f0e..dd24475 100644 --- a/Display.h +++ b/Display.h @@ -564,17 +564,26 @@ void update_disp_area() { } } -void update_display() { - if (millis()-last_disp_update >= disp_update_interval) { +void update_display(bool blank = false) { + if (blank) { if (display_contrast != display_intensity) { display_contrast = display_intensity; set_contrast(&display, display_contrast); } display.clearDisplay(); - update_stat_area(); - update_disp_area(); - display.display(); - last_disp_update = millis(); + display.display(); + } else { + if (millis()-last_disp_update >= disp_update_interval) { + if (display_contrast != display_intensity) { + display_contrast = display_intensity; + set_contrast(&display, display_contrast); + } + display.clearDisplay(); + update_stat_area(); + update_disp_area(); + display.display(); + last_disp_update = millis(); + } } } diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 34d31e7..db0605a 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -77,7 +77,9 @@ void setup() { fifo_init(&serialFIFO, serialBuffer, CONFIG_UART_BUFFER_SIZE); Serial.begin(serial_baudrate); - while (!Serial); + #if BOARD_MODEL != BOARD_RNODE_NG_22 + while (!Serial); + #endif serial_interrupt_init(); @@ -1305,6 +1307,14 @@ void loop() { void sleep_now() { #if HAS_SLEEP == true + #if BOARD_MODEL == BOARD_RNODE_NG_22 + display_intensity = 0; + update_display(true); + #endif + #if PIN_DISP_SLEEP >= 0 + pinMode(PIN_DISP_SLEEP, OUTPUT); + digitalWrite(PIN_DISP_SLEEP, DISP_SLEEP_LEVEL); + #endif esp_sleep_enable_ext0_wakeup(PIN_WAKEUP, WAKEUP_LEVEL); esp_deep_sleep_start(); #endif