From 9a4c99be7ae3b02f8e3636be97cddbeba407d7dd Mon Sep 17 00:00:00 2001 From: Luu <112649910+luu176@users.noreply.github.com> Date: Sat, 5 Oct 2024 22:04:10 +0200 Subject: [PATCH 1/6] Update power.c --- .../services/power/power_service/power.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/applications/services/power/power_service/power.c b/applications/services/power/power_service/power.c index 987bb6861d..cf5ca3ca74 100644 --- a/applications/services/power/power_service/power.c +++ b/applications/services/power/power_service/power.c @@ -8,6 +8,8 @@ #include #include +#include "../power_settings.h" + #define TAG "Power" #define POWER_OFF_TIMEOUT_S (90U) @@ -333,8 +335,19 @@ static void power_storage_callback(const void* message, void* context) { static void power_auto_shutdown_timer_callback(void* context) { furi_assert(context); Power* power = context; - power_auto_shutdown_inhibit(power); - power_off(power); + + // retreive shutdown delay from settings (in ms) + PowerSettings settings; + power_settings_load(&settings); + uint32_t shutdown_delay = settings.shutdown_idle_delay_ms; + + // suppress shutdown on idle while charging to avoid the battery from not charging fully. Then restart timer back to original timeout. + if (power->state == PowerStateCharging) { + furi_timer_restart(power->auto_shutdown_timer, shutdown_delay); + } else { + power_auto_shutdown_inhibit(power); + power_off(power); + } } static void power_apply_settings(Power* power) { From 790cdfeadad717c693c160d7c8a319cee04f569a Mon Sep 17 00:00:00 2001 From: Luu <112649910+luu176@users.noreply.github.com> Date: Mon, 7 Oct 2024 07:21:51 +0200 Subject: [PATCH 2/6] Update power.c Co-authored-by: WillyJL <49810075+Willy-JL@users.noreply.github.com> --- applications/services/power/power_service/power.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/applications/services/power/power_service/power.c b/applications/services/power/power_service/power.c index cf5ca3ca74..6b82d2f7a3 100644 --- a/applications/services/power/power_service/power.c +++ b/applications/services/power/power_service/power.c @@ -336,11 +336,6 @@ static void power_auto_shutdown_timer_callback(void* context) { furi_assert(context); Power* power = context; - // retreive shutdown delay from settings (in ms) - PowerSettings settings; - power_settings_load(&settings); - uint32_t shutdown_delay = settings.shutdown_idle_delay_ms; - // suppress shutdown on idle while charging to avoid the battery from not charging fully. Then restart timer back to original timeout. if (power->state == PowerStateCharging) { furi_timer_restart(power->auto_shutdown_timer, shutdown_delay); From 171b5bba2a5eab136b3622a1959883fbca4662a1 Mon Sep 17 00:00:00 2001 From: Luu <112649910+luu176@users.noreply.github.com> Date: Mon, 7 Oct 2024 07:21:56 +0200 Subject: [PATCH 3/6] Update power.c Co-authored-by: WillyJL <49810075+Willy-JL@users.noreply.github.com> --- applications/services/power/power_service/power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/services/power/power_service/power.c b/applications/services/power/power_service/power.c index 6b82d2f7a3..e863100dba 100644 --- a/applications/services/power/power_service/power.c +++ b/applications/services/power/power_service/power.c @@ -338,7 +338,7 @@ static void power_auto_shutdown_timer_callback(void* context) { // suppress shutdown on idle while charging to avoid the battery from not charging fully. Then restart timer back to original timeout. if (power->state == PowerStateCharging) { - furi_timer_restart(power->auto_shutdown_timer, shutdown_delay); + power_auto_shutdown_arm(power); } else { power_auto_shutdown_inhibit(power); power_off(power); From c5061c664cd65ea0100587ec2eb08223f3fa78e4 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 8 Oct 2024 04:31:51 +0100 Subject: [PATCH 4/6] Format --- applications/services/power/power_service/power.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/applications/services/power/power_service/power.c b/applications/services/power/power_service/power.c index e863100dba..2830377785 100644 --- a/applications/services/power/power_service/power.c +++ b/applications/services/power/power_service/power.c @@ -8,8 +8,6 @@ #include #include -#include "../power_settings.h" - #define TAG "Power" #define POWER_OFF_TIMEOUT_S (90U) @@ -336,8 +334,8 @@ static void power_auto_shutdown_timer_callback(void* context) { furi_assert(context); Power* power = context; - // suppress shutdown on idle while charging to avoid the battery from not charging fully. Then restart timer back to original timeout. - if (power->state == PowerStateCharging) { + // Suppress shutdown on idle while charging to avoid the battery from not charging fully. Then restart timer back to original timeout. + if(power->state == PowerStateCharging) { power_auto_shutdown_arm(power); } else { power_auto_shutdown_inhibit(power); From c25f78df3ac3be0ace47bcdb1bc8786d390b083b Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 8 Oct 2024 05:08:58 +0100 Subject: [PATCH 5/6] Also restart timer when plugged in but fully charged avoids the 'it is now safe to unplug cable' screen --- applications/services/power/power_service/power.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/applications/services/power/power_service/power.c b/applications/services/power/power_service/power.c index 2830377785..ba8e6cd6a7 100644 --- a/applications/services/power/power_service/power.c +++ b/applications/services/power/power_service/power.c @@ -335,7 +335,8 @@ static void power_auto_shutdown_timer_callback(void* context) { Power* power = context; // Suppress shutdown on idle while charging to avoid the battery from not charging fully. Then restart timer back to original timeout. - if(power->state == PowerStateCharging) { + if(power->state != PowerStateNotCharging) { + FURI_LOG_D(TAG, "Plugged in, reset idle timer"); power_auto_shutdown_arm(power); } else { power_auto_shutdown_inhibit(power); From 5de2223451824e7e901e97580b40c7d40710d9b0 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Tue, 8 Oct 2024 05:11:12 +0100 Subject: [PATCH 6/6] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8cd712e69..1e90cc61b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,7 @@ - Desktop: - Fallback Poweroff prompt when power settings is unavailable (by @Willy-JL) - Sub-GHz: Fix GPS "Latitute" typo, switch to "Lat" and "Lon" in .sub files (#246 by @m7i-org) +- Power: Suppress Shutdown on Idle While Charging / Plugged In (#244 by @luu176) - Storage: - Fallback SD format prompt when storage settings is unavailable (by @Willy-JL) - OFW: Fix folder rename fails (by @portasynthinca3)