When the device went into deep sleep while plugged into USB, a power-button press would occasionally not wake it. The display held its last frame, the chip stayed in deep sleep, and recovery required an unplug + reset + hold-power cycle. On battery the symptom never surfaced because the power button physically re-energises the chip. Two peripherals were holding power domains alive across the deep sleep boundary and interfering with the configured GPIO wake on the power button: 1. HWCDC. Once Serial is initialized, the USB Serial/JTAG peripheral keeps its power domain configured even with TX timeout at zero and no host draining. Tear it down with Serial.end() in HalPowerManager::startDeepSleep, gated by ENABLE_SERIAL_LOG to match the Serial.begin site. This hit me if I was charging off my computer. 2. WiFi. enterDeepSleep had no WiFi teardown, so sleeping from any network-using activity left the modem domain alive. Call WiFi.disconnect(true) + WiFi.mode(WIFI_OFF) when WiFi is active. Wake from deep sleep is effectively a chip reset, so no WiFi state needs to survive. While this doesn't cause higher power drain, it apparently was causing issues where I'd occasionally have the chip hang on sleep transition from a wifi activity. Confirmed on device. Did you use AI tools to help write this code? partial
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into the executable file.
The source code of each library should be placed in a separate directory
("lib/your_library_name/[Code]").
For example, see the structure of the following example libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
Example contents of `src/main.c` using Foo and Bar:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
The PlatformIO Library Dependency Finder will find automatically dependent
libraries by scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html