From 2bc727ffc766734ddeba8f647e0775f4fcb768ee Mon Sep 17 00:00:00 2001 From: andrekir Date: Thu, 1 Feb 2024 20:20:34 -0300 Subject: [PATCH] fix: turn off T-Echo peripherals on deep sleep --- src/Power.cpp | 5 ----- src/graphics/Screen.cpp | 3 +++ src/sleep.cpp | 6 ++++++ variants/rak10701/variant.h | 4 ---- variants/rak4631/variant.h | 4 ---- variants/rak4631_epaper/variant.h | 4 ---- variants/rak4631_epaper_onrxtx/variant.h | 4 ---- variants/t-echo/variant.h | 3 +-- 8 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 8e44ddb983..3d1a1b9b27 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -473,11 +473,6 @@ bool Power::setup() void Power::shutdown() { - screen->setOn(false); -#if defined(USE_EINK) && defined(PIN_EINK_EN) - digitalWrite(PIN_EINK_EN, LOW); // power off backlight first -#endif - LOG_INFO("Shutting down\n"); #ifdef HAS_PMU diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index c0e55ea832..282231dbf0 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -966,6 +966,9 @@ void Screen::doDeepSleep() static const int sleepFrameCount = sizeof(sleepFrames) / sizeof(sleepFrames[0]); ui->setFrames(sleepFrames, sleepFrameCount); ui->update(); +#ifdef PIN_EINK_EN + digitalWrite(PIN_EINK_EN, LOW); // power off backlight +#endif #endif setOn(false); } diff --git a/src/sleep.cpp b/src/sleep.cpp index 0f71ab25b3..ec936329cb 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -192,6 +192,12 @@ void doDeepSleep(uint32_t msecToWake, bool skipPreflight = false) nodeDB.saveToDisk(); +#ifdef TTGO_T_ECHO +#ifdef PIN_EINK_PWR_ON + pinMode(PIN_EINK_PWR_ON, INPUT); // power off peripherals +#endif +#endif + // Kill GPS power completely (even if previously we just had it in sleep mode) if (gps) gps->setGPSPower(false, false, 0); diff --git a/variants/rak10701/variant.h b/variants/rak10701/variant.h index 5ff12a7de0..d15149248d 100644 --- a/variants/rak10701/variant.h +++ b/variants/rak10701/variant.h @@ -133,10 +133,6 @@ static const uint8_t SCK = PIN_SPI_SCK; #define PIN_EINK_SCLK (0 + 3) #define PIN_EINK_MOSI (0 + 30) // also called SDI -// Controls power for the eink display - Board power is enabled either by VBUS from USB or the CPU asserting PWR_ON -// FIXME - I think this is actually just the board power enable - it enables power to the CPU also -// #define PIN_EINK_PWR_ON (-1) - // #define USE_EINK // RAKRGB diff --git a/variants/rak4631/variant.h b/variants/rak4631/variant.h index cc18a901f6..e4116e42da 100644 --- a/variants/rak4631/variant.h +++ b/variants/rak4631/variant.h @@ -133,10 +133,6 @@ static const uint8_t SCK = PIN_SPI_SCK; #define PIN_EINK_SCLK (0 + 3) #define PIN_EINK_MOSI (0 + 30) // also called SDI -// Controls power for the eink display - Board power is enabled either by VBUS from USB or the CPU asserting PWR_ON -// FIXME - I think this is actually just the board power enable - it enables power to the CPU also -// #define PIN_EINK_PWR_ON (-1) - // #define USE_EINK // RAKRGB diff --git a/variants/rak4631_epaper/variant.h b/variants/rak4631_epaper/variant.h index d8a5e55977..b1bd84d217 100644 --- a/variants/rak4631_epaper/variant.h +++ b/variants/rak4631_epaper/variant.h @@ -133,10 +133,6 @@ static const uint8_t SCK = PIN_SPI_SCK; #define PIN_EINK_SCLK (0 + 3) #define PIN_EINK_MOSI (0 + 30) // also called SDI -// Controls power for the eink display - Board power is enabled either by VBUS from USB or the CPU asserting PWR_ON -// FIXME - I think this is actually just the board power enable - it enables power to the CPU also -// #define PIN_EINK_PWR_ON (-1) - #define USE_EINK // RAKRGB diff --git a/variants/rak4631_epaper_onrxtx/variant.h b/variants/rak4631_epaper_onrxtx/variant.h index 411e3eb171..ec53ebd33b 100644 --- a/variants/rak4631_epaper_onrxtx/variant.h +++ b/variants/rak4631_epaper_onrxtx/variant.h @@ -119,10 +119,6 @@ static const uint8_t SCK = PIN_SPI_SCK; #define PIN_EINK_SCLK (0 + 14) // SCL #define PIN_EINK_MOSI (0 + 13) // SDA -// Controls power for the eink display - Board power is enabled either by VBUS from USB or the CPU asserting PWR_ON -// FIXME - I think this is actually just the board power enable - it enables power to the CPU also -// #define PIN_EINK_PWR_ON (-1) - // RAKRGB #define HAS_NCP5623 diff --git a/variants/t-echo/variant.h b/variants/t-echo/variant.h index 345091c2fa..cf56cf0b57 100644 --- a/variants/t-echo/variant.h +++ b/variants/t-echo/variant.h @@ -155,8 +155,7 @@ External serial flash WP25R1635FZUIL0 #define PIN_EINK_SCLK (0 + 31) #define PIN_EINK_MOSI (0 + 29) // also called SDI -// Controls power for the eink display - Board power is enabled either by VBUS from USB or the CPU asserting PWR_ON -// FIXME - I think this is actually just the board power enable - it enables power to the CPU also +// Controls power for all peripherals (eink + GPS + LoRa + Sensor) #define PIN_EINK_PWR_ON (0 + 12) #define USE_EINK