mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 08:18:35 -07:00
SafeCharging (charging supress) finished.
This commit is contained in:
@@ -442,7 +442,7 @@ static void power_auto_poweroff_timer_callback(void* context) {
|
|||||||
Power* power = context;
|
Power* power = context;
|
||||||
|
|
||||||
//Dont poweroff device if charger connected
|
//Dont poweroff device if charger connected
|
||||||
if (furi_hal_power_is_charging()) {
|
if(furi_hal_power_is_charging()) {
|
||||||
FURI_LOG_D(TAG, "We dont auto_power_off until battery is charging");
|
FURI_LOG_D(TAG, "We dont auto_power_off until battery is charging");
|
||||||
power_start_auto_poweroff_timer(power);
|
power_start_auto_poweroff_timer(power);
|
||||||
} else {
|
} else {
|
||||||
@@ -548,6 +548,24 @@ static void power_message_callback(FuriEventLoopObject* object, void* context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void power_charge_supress(Power* power) {
|
||||||
|
// if charge_supress_percent selected (not OFF) and current charge level equal or higher than selected level
|
||||||
|
// then we start supression if we not supress it before.
|
||||||
|
if(power->settings.charge_supress_percent &&
|
||||||
|
power->info.charge >= power->settings.charge_supress_percent) {
|
||||||
|
if(!power->charge_is_supressed) {
|
||||||
|
power->charge_is_supressed = true;
|
||||||
|
furi_hal_power_suppress_charge_enter();
|
||||||
|
}
|
||||||
|
// disable supression if charge_supress_percent OFF but charge still supressed
|
||||||
|
} else {
|
||||||
|
if(power->charge_is_supressed) {
|
||||||
|
power->charge_is_supressed = false;
|
||||||
|
furi_hal_power_suppress_charge_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void power_tick_callback(void* context) {
|
static void power_tick_callback(void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
Power* power = context;
|
Power* power = context;
|
||||||
@@ -560,6 +578,8 @@ static void power_tick_callback(void* context) {
|
|||||||
power_check_charging_state(power);
|
power_check_charging_state(power);
|
||||||
// Check and notify about battery level change
|
// Check and notify about battery level change
|
||||||
power_check_battery_level_change(power);
|
power_check_battery_level_change(power);
|
||||||
|
// charge supress arm/disarm
|
||||||
|
power_charge_supress(power);
|
||||||
// Update battery view port
|
// Update battery view port
|
||||||
if(need_refresh) {
|
if(need_refresh) {
|
||||||
view_port_update(power->battery_view_port);
|
view_port_update(power->battery_view_port);
|
||||||
@@ -585,7 +605,7 @@ static void power_storage_callback(const void* message, void* context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// load inital settings from file for power service
|
// loading and initializing power service settings
|
||||||
static void power_init_settings(Power* power) {
|
static void power_init_settings(Power* power) {
|
||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
furi_pubsub_subscribe(storage_get_pubsub(storage), power_storage_callback, power);
|
furi_pubsub_subscribe(storage_get_pubsub(storage), power_storage_callback, power);
|
||||||
@@ -598,6 +618,7 @@ static void power_init_settings(Power* power) {
|
|||||||
power_settings_load(&power->settings);
|
power_settings_load(&power->settings);
|
||||||
power_settings_apply(power);
|
power_settings_apply(power);
|
||||||
furi_record_close(RECORD_STORAGE);
|
furi_record_close(RECORD_STORAGE);
|
||||||
|
power->charge_is_supressed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Power* power_alloc(void) {
|
static Power* power_alloc(void) {
|
||||||
@@ -661,7 +682,7 @@ int32_t power_srv(void* p) {
|
|||||||
|
|
||||||
Power* power = power_alloc();
|
Power* power = power_alloc();
|
||||||
|
|
||||||
// load inital settings for power service
|
// power service settings initialization
|
||||||
power_init_settings(power);
|
power_init_settings(power);
|
||||||
|
|
||||||
power_update_info(power);
|
power_update_info(power);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ struct Power {
|
|||||||
bool app_running;
|
bool app_running;
|
||||||
FuriPubSub* input_events_pubsub;
|
FuriPubSub* input_events_pubsub;
|
||||||
FuriPubSubSubscription* input_events_subscription;
|
FuriPubSubSubscription* input_events_subscription;
|
||||||
|
bool charge_is_supressed;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t auto_poweroff_delay_ms;
|
uint32_t auto_poweroff_delay_ms;
|
||||||
uint8_t charge_supress_percent;
|
uint8_t charge_supress_percent;
|
||||||
bool charge_is_supressed;
|
|
||||||
} PowerSettings;
|
} PowerSettings;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -15,10 +15,11 @@ const char* const auto_poweroff_delay_text[AUTO_POWEROFF_DELAY_COUNT] =
|
|||||||
const uint32_t auto_poweroff_delay_value[AUTO_POWEROFF_DELAY_COUNT] =
|
const uint32_t auto_poweroff_delay_value[AUTO_POWEROFF_DELAY_COUNT] =
|
||||||
{0, 300000, 600000, 900000, 1800000, 2700000, 3600000, 5400000};
|
{0, 300000, 600000, 900000, 1800000, 2700000, 3600000, 5400000};
|
||||||
|
|
||||||
#define CHARGE_SUPRESS_PERCENT_COUNT 2
|
#define CHARGE_SUPRESS_PERCENT_COUNT 6
|
||||||
const char* const charge_supress_percent_text[CHARGE_SUPRESS_PERCENT_COUNT] = {"OFF", "80%"};
|
const char* const charge_supress_percent_text[CHARGE_SUPRESS_PERCENT_COUNT] =
|
||||||
|
{"OFF", "90%", "85%", "80%", "75%", "70%"};
|
||||||
|
|
||||||
const uint32_t charge_supress_percent_value[CHARGE_SUPRESS_PERCENT_COUNT] = {0, 80};
|
const uint32_t charge_supress_percent_value[CHARGE_SUPRESS_PERCENT_COUNT] = {0, 90, 85, 80, 75, 70};
|
||||||
|
|
||||||
// change variable_item_list visible text and charge_supress_percent_settings when user change item in variable_item_list
|
// change variable_item_list visible text and charge_supress_percent_settings when user change item in variable_item_list
|
||||||
static void power_settings_scene_start_charge_supress_percent_changed(VariableItem* item) {
|
static void power_settings_scene_start_charge_supress_percent_changed(VariableItem* item) {
|
||||||
@@ -72,7 +73,7 @@ void power_settings_scene_start_on_enter(void* context) {
|
|||||||
|
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
variable_item_list,
|
variable_item_list,
|
||||||
"Safe charging",
|
"Safe Charging",
|
||||||
CHARGE_SUPRESS_PERCENT_COUNT,
|
CHARGE_SUPRESS_PERCENT_COUNT,
|
||||||
power_settings_scene_start_charge_supress_percent_changed,
|
power_settings_scene_start_charge_supress_percent_changed,
|
||||||
app);
|
app);
|
||||||
|
|||||||
Reference in New Issue
Block a user