Power.h 1007 B

12345678910111213141516171819202122232425262728293031323334
  1. /******************************************************************************
  2. * M5Snake : Power management *
  3. * -------------------------- *
  4. * Management of the charge of the battery to avoid over charging *
  5. * Author: Olivier Staquet *
  6. * Last version available on https://github.com/ostaquet/M5Snake *
  7. *****************************************************************************/
  8. #ifndef _POWER_H_
  9. #define _POWER_H_
  10. #include <Arduino.h>
  11. #include <M5Stack.h>
  12. class PowerClass {
  13. public:
  14. // Initialize
  15. void begin();
  16. // Adjust charge mode
  17. void adaptChargeMode();
  18. // Return battery level (0-100%)
  19. // (-1 if cannot communicate with the controller)
  20. int8_t getBatteryLevel();
  21. private:
  22. // Power control available
  23. bool canControl = false;
  24. };
  25. extern PowerClass Power;
  26. #endif // _POWER_H_