PowerOFF.ino 611 B

12345678910111213141516171819202122232425262728293031
  1. #include <M5Stack.h>
  2. // the setup routine runs once when M5Stack starts up
  3. void setup(){
  4. // initialize the M5Stack object
  5. M5.begin();
  6. /*
  7. Power chip connected to gpio21, gpio22, I2C device
  8. Set battery charging voltage and current
  9. If used battery, please call this function in your project
  10. */
  11. M5.Power.begin();
  12. // Lcd display
  13. M5.Lcd.setTextSize(2);
  14. M5.Lcd.println("Software Power-OFF Demo");
  15. M5.Lcd.println("Press Button A ...");
  16. }
  17. // the loop routine runs over and over again forever
  18. void loop() {
  19. if(M5.BtnA.wasPressed()) {
  20. M5.Power.powerOFF();
  21. }
  22. M5.update();
  23. }