From 93a89eb95dbd0be29c15824ae67ba2d388e072dd Mon Sep 17 00:00:00 2001 From: paulchilton Date: Sat, 31 Dec 2022 20:19:45 +0000 Subject: [PATCH] Testing different placement of auto-restart --- components/axp192/axp192.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/components/axp192/axp192.cpp b/components/axp192/axp192.cpp index e1a24c2..cdb8099 100644 --- a/components/axp192/axp192.cpp +++ b/components/axp192/axp192.cpp @@ -49,6 +49,15 @@ void AXP192Component::update() { } UpdateBrightness(); + + // If we're waking from a cold boot + if (GetStartupReason() == "ESP_RST_POWERON") + { + ESP_LOGD(TAG, "First power on, restarting ESP..."); + + // Reboot the ESP with the axp initialised + ESP.restart(); + } } @@ -117,16 +126,6 @@ void AXP192Component::begin(bool disableLDO2, bool disableLDO3, bool disableRTC, // Enable bat detection Write1Byte(0x32, 0x46); - ESP_LOGD(TAG, GetStartupReason()); - - // If we're waking from a cold boot, initialise power chip - if (GetStartupReason() == "ESP_RST_POWERON") - { - ESP_LOGD(TAG, "First power on, restarting ESP..."); - - // Reboot the ESP with the axp initialised - ESP.restart(); - } } void AXP192Component::Write1Byte( uint8_t Addr , uint8_t Data )