APIs and example programs related to PowerHub Wakeup.
#include <M5Unified.h> int myIndex = 0; void setup() { M5.begin(); M5.Led.setBrightness(255); Serial.begin(115200); Serial.println("\n\nPowerHub Sleep & Wakeup Test"); delay(1000); } void loop() { myIndex++; Serial.printf("%d ", myIndex); M5.Led.setAllColor(TFT_WHITE); M5.Led.display(); delay(200); if (myIndex % 20 == 0) { M5.Led.setAllColor(TFT_BLACK); M5.Led.display(); M5.Power.timerSleep(5); // in seconds // M5.Power.deepSleep(5000000, false); // in microseconds // M5.Power.lightSleep(5000000, false); // in microseconds } if (myIndex >= 1000) { myIndex = 0; } }This program will turn on the LED and print a counter that starts from 0 and increments by 1 in the serial monitor. Each time the counter reaches a multiple of 20, the device will enter timed sleep mode for 5 seconds (LED turns off), then wake up, restart the program, and light up the LED again.
The PowerHub Wakeup driver uses the Power_Class from the M5Unified library. For more related APIs, refer to the following documentation: