Skip to content

Commit

Permalink
Merge pull request #858 from Dmitry422/dev
Browse files Browse the repository at this point in the history
fix errors
  • Loading branch information
xMasterX authored Jan 15, 2025
2 parents d09bbd1 + 818a470 commit 8872b13
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
17 changes: 9 additions & 8 deletions applications/services/power/power_service/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,15 @@ static void power_auto_poweroff_callback(const void* value, void* context) {
static void power_auto_poweroff_timer_callback(void* context) {
furi_assert(context);
Power* power = context;
//check charging state and dont poweroff if battery not fully charged
power_check_charging_state(power);
if (power->state == PowerStateCharged) {

//poweroff if not charging now or if connected to charger and charging done
if (((!furi_hal_power_is_charging())) || (furi_hal_power_is_charging_done())) {
power_off(power);
}
else {
//else we dont poweroff device and restart timer
FURI_LOG_D(TAG, "We dont auto_power_off until battery is charging");
power_start_auto_poweroff_timer(power);
}
}

Expand Down Expand Up @@ -493,12 +495,10 @@ static void power_loader_callback(const void* message, void* context) {
static void power_settings_apply(Power* power) {
//apply auto_poweroff settings
if(power->settings.auto_poweroff_delay_ms && !power->app_running) {
return;
power_auto_poweroff_arm(power);
} else if (power_is_running_auto_poweroff_timer(power)) {
power_auto_poweroff_disarm(power);
}
return;
}

// do something depend from power queue message
Expand Down Expand Up @@ -662,6 +662,10 @@ int32_t power_srv(void* p) {
}

Power* power = power_alloc();

// load inital settings for power service
power_init_settings(power);

power_update_info(power);

furi_record_create(RECORD_POWER, power);
Expand All @@ -671,9 +675,6 @@ int32_t power_srv(void* p) {
power->app_running = loader_is_locked(loader);
furi_record_close(RECORD_LOADER);

// load inital settings for power service
power_init_settings(power);

furi_event_loop_run(power->event_loop);

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
#include <lib/toolbox/value_index.h>

enum PowerSettingsSubmenuIndex {
PowerSettingsSubmenuIndexAutoPowerOff,
PowerSettingsSubmenuIndexBatteryInfo,
PowerSettingsSubmenuIndexReboot,
PowerSettingsSubmenuIndexOff,
PowerSettingsSubmenuIndexAutoPowerOff,
};

#define AUTO_POWEROFF_DELAY_COUNT 9
#define AUTO_POWEROFF_DELAY_COUNT 8
const char* const auto_poweroff_delay_text[AUTO_POWEROFF_DELAY_COUNT] =
{"OFF","5 sec","5min", "10min", "15min", "30min", "45min", "60min", "90min"};
{"OFF","5min", "10min", "15min", "30min", "45min", "60min", "90min"};

const uint32_t auto_poweroff_delay_value[AUTO_POWEROFF_DELAY_COUNT] =
{0, 5000, 300000, 600000, 900000, 1800000, 2700000, 3600000, 5400000};
{0, 300000, 600000, 900000, 1800000, 2700000, 3600000, 5400000};

// change variable_item_list visible text and app_poweroff_delay_time_settings when user change item in variable_item_list
static void power_settings_scene_start_auto_poweroff_delay_changed(VariableItem* item) {
Expand All @@ -34,6 +34,10 @@ void power_settings_scene_start_on_enter(void* context) {
PowerSettingsApp* app = context;
VariableItemList* variable_item_list = app->variable_item_list;

variable_item_list_add(variable_item_list, "Battery Info", 1, NULL, NULL);
variable_item_list_add(variable_item_list, "Reboot", 1, NULL, NULL);
variable_item_list_add(variable_item_list, "Power OFF", 1, NULL, NULL);

VariableItem* item;
uint8_t value_index;
item = variable_item_list_add(
Expand All @@ -49,11 +53,7 @@ void power_settings_scene_start_on_enter(void* context) {
AUTO_POWEROFF_DELAY_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, auto_poweroff_delay_text[value_index]);

variable_item_list_add(variable_item_list, "Battery Info", 1, NULL, NULL);
variable_item_list_add(variable_item_list, "Reboot", 1, NULL, NULL);
variable_item_list_add(variable_item_list, "Power OFF", 1, NULL, NULL);


variable_item_list_set_selected_item(
variable_item_list, scene_manager_get_scene_state(app->scene_manager, PowerSettingsAppSceneStart));
variable_item_list_set_enter_callback( //callback to show next mennu screen
Expand Down

0 comments on commit 8872b13

Please sign in to comment.