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
+8 -1
View File
@@ -5,6 +5,8 @@
#define TAG "hardware"
extern const Power power;
static bool lvgl_init() {
lv_init();
lvgl_task_start();
@@ -22,7 +24,12 @@ TT_UNUSED static void lvgl_deinit() {
#endif
}
HardwareConfig sim_hardware = {
const HardwareConfig sim_hardware = {
.bootstrap = NULL,
.init_graphics = &lvgl_init,
.display = {
.set_backlight_duty = NULL,
},
.power = &power,
.sdcard = NULL
};
+1 -1
View File
@@ -1,7 +1,7 @@
#include "hello_world/hello_world.h"
#include "tactility.h"
extern HardwareConfig sim_hardware;
extern const HardwareConfig sim_hardware;
void app_main() {
static const Config config = {
+34
View File
@@ -0,0 +1,34 @@
#include "power.h"
#ifdef __cplusplus
extern "C" {
#endif
static bool is_charging_enabled = false;
static bool power_is_charging() {
return is_charging_enabled;
}
static void power_set_charging_enabled(bool enabled) {
is_charging_enabled = enabled;
}
static uint8_t power_get_charge_level() {
return 204;
}
static int32_t power_get_current() {
return is_charging_enabled ? 100 : -50;
}
const Power 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