mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 06: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;
|
||||
|
||||
//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");
|
||||
power_start_auto_poweroff_timer(power);
|
||||
} 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) {
|
||||
furi_assert(context);
|
||||
Power* power = context;
|
||||
@@ -560,6 +578,8 @@ static void power_tick_callback(void* context) {
|
||||
power_check_charging_state(power);
|
||||
// Check and notify about battery level change
|
||||
power_check_battery_level_change(power);
|
||||
// charge supress arm/disarm
|
||||
power_charge_supress(power);
|
||||
// Update battery view port
|
||||
if(need_refresh) {
|
||||
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) {
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
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_apply(power);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
power->charge_is_supressed = false;
|
||||
}
|
||||
|
||||
static Power* power_alloc(void) {
|
||||
@@ -661,7 +682,7 @@ int32_t power_srv(void* p) {
|
||||
|
||||
Power* power = power_alloc();
|
||||
|
||||
// load inital settings for power service
|
||||
// power service settings initialization
|
||||
power_init_settings(power);
|
||||
|
||||
power_update_info(power);
|
||||
|
||||
@@ -41,6 +41,7 @@ struct Power {
|
||||
bool app_running;
|
||||
FuriPubSub* input_events_pubsub;
|
||||
FuriPubSubSubscription* input_events_subscription;
|
||||
bool charge_is_supressed;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
typedef struct {
|
||||
uint32_t auto_poweroff_delay_ms;
|
||||
uint8_t charge_supress_percent;
|
||||
bool charge_is_supressed;
|
||||
} PowerSettings;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user