Implemented power management (#67)

- Implemented HAL for for power management
- Implemented the Power app (accessible via Settings app)
- Implemented status bar icon for battery status
This commit is contained in:
Ken Van Hoeylandt
2024-11-02 23:40:26 +01:00
committed by GitHub
parent 6520655795
commit 632d7ccccf
29 changed files with 373 additions and 26 deletions
+34
View File
@@ -0,0 +1,34 @@
#include "power.h"
#include "M5Unified.hpp"
#ifdef __cplusplus
extern "C" {
#endif
static bool power_is_charging() {
return M5.Power.isCharging() == m5::Power_Class::is_charging;
}
static void power_set_charging_enabled(bool enabled) {
M5.Power.setBatteryCharge(enabled);
}
static uint8_t power_get_charge_level() {
uint16_t scaled = (uint16_t)M5.Power.getBatteryLevel() * 255 / 100;
return (uint8_t)scaled;
}
static int32_t power_get_current() {
return M5.Power.getBatteryCurrent();
}
Power core2_power = {
.is_charging = &power_is_charging,
.set_charging_enabled = &power_set_charging_enabled,
.get_charge_level = &power_get_charge_level,
.get_current = &power_get_current
};
#ifdef __cplusplus
}
#endif