From afafb3ba3272c5e2bd688a049e812166e4bd9efd Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 30 Oct 2022 20:40:30 -0500 Subject: [PATCH] Fixing a number of T-Beam poweroff display issues (#1876) --- src/Power.cpp | 14 +++++++------- src/graphics/Screen.h | 3 +-- src/shutdown.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Power.cpp b/src/Power.cpp index 7443fc428..af10acb5e 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -233,14 +233,14 @@ 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 #ifdef HAS_PMU DEBUG_MSG("Shutting down\n"); - if(PMU){ + if(PMU) { PMU->setChargingLedMode(XPOWERS_CHG_LED_OFF); PMU->shutdown(); } @@ -315,7 +315,7 @@ int32_t Power::runOnce() #ifdef HAS_PMU // WE no longer use the IRQ line to wake the CPU (due to false wakes from sleep), but we do poll // the IRQ status by reading the registers over I2C - if(PMU){ + if(PMU) { PMU->getIrqStatus(); @@ -344,10 +344,11 @@ int32_t Power::runOnce() if (PMU->isBatRemoveIrq()) { DEBUG_MSG("Battery removed\n"); } - if (PMU->isPekeyShortPressIrq()) { - DEBUG_MSG("PEK short button press\n"); - } */ + if (PMU->isPekeyLongPressIrq()) { + DEBUG_MSG("PEK long button press\n"); + screen->setOn(false); + } PMU->clearIrqStatus(); } @@ -454,7 +455,6 @@ bool Power::axpChipInit() // Set constant current charging current PMU->setChargerConstantCurr(XPOWERS_AXP192_CHG_CUR_450MA); - } else if (PMU->getChipModel() == XPOWERS_AXP2101) { // t-beam s3 core diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index ab8d44430..cee00f174 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -131,8 +131,7 @@ class Screen : public concurrency::OSThread void setOn(bool on) { if (!on) - handleSetOn( - false); // We handle off commands immediately, because they might be called because the CPU is shutting down + handleSetOn(false); // We handle off commands immediately, because they might be called because the CPU is shutting down else enqueueCmd(ScreenCmd{.cmd = on ? Cmd::SET_ON : Cmd::SET_OFF}); } diff --git a/src/shutdown.h b/src/shutdown.h index f37339641..678a1401c 100644 --- a/src/shutdown.h +++ b/src/shutdown.h @@ -17,7 +17,7 @@ void powerCommandsCheck() #endif } -#if defined(ARCH_NRF52) +#if defined(ARCH_NRF52) || defined(HAS_PMU) if (shutdownAtMsec) { screen->startShutdownScreen(); playBeep();