File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,26 @@ static void setPmuFlag()
4444{
4545 pmuInterrupt = true ;
4646}
47+
48+ static void keepPmuAwake ()
49+ {
50+ if (!PMU) {
51+ return ;
52+ }
53+
54+ const auto chip = PMU->getChipModel ();
55+ if (chip == XPOWERS_AXP2101) {
56+ auto *axp2101 = static_cast <XPowersAXP2101 *>(PMU);
57+ axp2101->disableSleep ();
58+ axp2101->disableLongPressShutdown ();
59+ axp2101->setLongPressRestart ();
60+ axp2101->disableWatchdog ();
61+ axp2101->setLowBatShutdownThreshold (0 );
62+ } else if (chip == XPOWERS_AXP192) {
63+ auto *axp192 = static_cast <XPowersAXP192 *>(PMU);
64+ axp192->disablePowerKeyLongPressPowerOff ();
65+ }
66+ }
4767#endif
4868
4969bool beginPower ()
@@ -76,6 +96,7 @@ bool beginPower()
7696 }
7797
7898 PMU->setChargingLedMode (XPOWERS_CHG_LED_CTRL_CHG);
99+ keepPmuAwake ();
79100
80101 pinMode (PMU_IRQ, INPUT_PULLUP);
81102 attachInterrupt (PMU_IRQ, setPmuFlag, FALLING);
@@ -847,4 +868,4 @@ bool beginGPS()
847868 SerialGPS.write (" $PCAS11,3*1E\r\n " );
848869 return result;
849870}
850- #endif
871+ #endif
Original file line number Diff line number Diff line change 11#include < Arduino.h>
22#include < WiFi.h>
3+ #if defined(ESP32)
4+ #include < esp_wifi.h>
5+ #endif
36#include < ArduinoWebsockets.h>
47#include < ArduinoJson.h>
58#include < SPI.h>
@@ -82,13 +85,20 @@ void loop() {
8285
8386 wsClient.poll ();
8487 publishStatus ();
88+ #ifdef HAS_PMU
89+ loopPMU ();
90+ #endif
8591 delay (5 );
8692}
8793
8894// ----- Wi-Fi & WebSocket ---------------------------------------------
8995void connectWiFi () {
9096 Serial.printf (" [WiFi] Connecting to %s\n " , WIFI_SSID);
9197 WiFi.mode (WIFI_STA);
98+ #if defined(ESP32)
99+ WiFi.setSleep (false );
100+ esp_wifi_set_ps (WIFI_PS_NONE);
101+ #endif
92102 WiFi.begin (WIFI_SSID, WIFI_PASSWORD);
93103
94104 const uint32_t start = millis ();
You can’t perform that action at this time.
0 commit comments