change update the Battery info

This commit is contained in:
Patrik Burleson 2022-09-08 07:31:57 +02:00
parent 015fcf239c
commit 563cf986d6
2 changed files with 13 additions and 6 deletions

View File

@ -41,6 +41,7 @@ const uint32_t displayBatteryPercentage_value[BATTERY_VIEW_COUNT] = {0, 1, 2, 3,
static void desktop_settings_scene_start_var_list_enter_callback(void* context, uint32_t index) {
DesktopSettingsApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
}
static void desktop_settings_scene_start_battery_view_changed(VariableItem* item) {

View File

@ -171,11 +171,6 @@ static void power_check_charging_state(Power* power) {
static bool power_update_info(Power* power) {
PowerInfo info;
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
LOAD_DESKTOP_SETTINGS(settings);
power->displayBatteryPercentage = settings->displayBatteryPercentage;
free(settings);
info.gauge_is_ok = furi_hal_power_gauge_is_ok();
info.charge = furi_hal_power_get_pct();
@ -256,6 +251,11 @@ int32_t power_srv(void* p) {
Power* power = power_alloc();
power_update_info(power);
furi_record_create(RECORD_POWER, power);
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
LOAD_DESKTOP_SETTINGS(settings);
power->displayBatteryPercentage = settings->displayBatteryPercentage;
free(settings);
while(1) {
// Update data from gauge and charger
@ -271,7 +271,13 @@ int32_t power_srv(void* p) {
power_check_battery_level_change(power);
// Update battery view port
if(need_refresh) view_port_update(power->battery_view_port);
if(need_refresh) {
DesktopSettings* settings = malloc(sizeof(DesktopSettings));
LOAD_DESKTOP_SETTINGS(settings);
power->displayBatteryPercentage = settings->displayBatteryPercentage;
free(settings);
view_port_update(power->battery_view_port);
}
// Check OTG status and disable it in case of fault
if(furi_hal_power_is_otg_enabled()) {