-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Automatic shutdown on idle #1647
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SHxKenzuto
wants to merge
35
commits into
flipperdevices:dev
Choose a base branch
from
SHxKenzuto:shutdown_idle
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+249
−2
Open
Changes from 6 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
6dc39ba
Merge pull request #1 from flipperdevices/dev
SHxKenzuto cf053b4
Merge remote-tracking branch 'upstream/dev' into dev
SHxKenzuto 409151f
Merge remote-tracking branch 'upstream/dev' into dev
SHxKenzuto af8d236
added "Shutdown on Idle" setting under power settings
SHxKenzuto 024326e
Merge remote-tracking branch 'upstream/dev' into dev
SHxKenzuto 94b2d25
Merge remote-tracking branch 'origin/dev' into shutdown_idle
SHxKenzuto 44e3842
fix issues Shutdown on idle
SHxKenzuto 40cabd5
Merge remote-tracking branch 'upstream/dev' into shutdown_idle
SHxKenzuto 6d83a3e
Merge branch 'dev' into shutdown_idle
skotopes a3ade92
Power: free variable_item_list after removing from view dispatcher
skotopes d3c1ff5
Merge remote-tracking branch 'upstream/dev' into shutdown_idle
SHxKenzuto 82f2354
event based check for auto shutdown timer setting
SHxKenzuto 12515b2
Merge remote-tracking branch 'upstream/dev' into shutdown_idle
SHxKenzuto dfe7828
Merge branch 'dev' into shutdown_idle
skotopes 3a5d70b
Merge branch 'dev' into shutdown_idle
SHxKenzuto f07424f
added 2 hours interval option in shutdown on idle submenu
SHxKenzuto 76c2ccd
Merge branch 'dev-upstream' into shutdown_idle
SHxKenzuto 400558a
Shutdown on Idle: auto-shutdown timer arm/inhibit hooked to loader ev…
SHxKenzuto bfc563e
Merge remote-tracking branch 'upstream/dev' into shutdown_idle
SHxKenzuto 4ed6950
Merge branch 'dev' into shutdown_idle
skotopes 461aca0
Remove merge artifact
skotopes 1cb5d6f
Merge branch 'dev' into shutdown_idle
skotopes b931ef7
Merge branch 'dev' into shutdown_idle
skotopes d8db432
Shutdown on Idle: moved timer allocation before callbacks subscriptions
SHxKenzuto d65fd6f
Shutdown on Idle: optimized loader callback subscription
SHxKenzuto d75e6a1
grouped furi_record_open instructions
SHxKenzuto 8f46234
Merge remote-tracking branch 'upstream/dev' into shutdown_idle
SHxKenzuto 3aa4229
changed power_off instruction to furi_hal_power_off
SHxKenzuto 345c654
Merge remote-tracking branch 'origin/dev' into shutdown_idle
skotopes 104e34d
Merge branch 'dev' into shutdown_idle
skotopes b69b4f4
Merge remote-tracking branch 'origin/dev' into shutdown_idle
skotopes 4ab846b
Sync api symbols
skotopes 9a86178
Merge branch 'dev' into shutdown_idle
skotopes 0dbc1b6
Merge branch 'dev' into shutdown_idle
hedger 4fdb8f0
Merge remote-tracking branch 'origin/dev' into shutdown_idle
skotopes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| #include <toolbox/saved_struct.h> | ||
| #include <storage/storage.h> | ||
| #include "power_settings_filename.h" | ||
|
|
||
| #define POWER_SETTINGS_VER (1) | ||
|
|
||
| #define POWER_SETTINGS_PATH INT_PATH(POWER_SETTINGS_FILE_NAME) | ||
| #define POWER_SETTINGS_MAGIC (0x21) | ||
|
|
||
| #define SAVE_POWER_SETTINGS(x) \ | ||
| saved_struct_save( \ | ||
| POWER_SETTINGS_PATH, \ | ||
| (x), \ | ||
| sizeof(uint32_t), \ | ||
| POWER_SETTINGS_MAGIC, \ | ||
| POWER_SETTINGS_VER) | ||
|
|
||
|
|
||
| #define LOAD_POWER_SETTINGS(x) \ | ||
| saved_struct_load( \ | ||
| POWER_SETTINGS_PATH, \ | ||
| (x), \ | ||
| sizeof(uint32_t), \ | ||
| POWER_SETTINGS_MAGIC, \ | ||
| POWER_SETTINGS_VER) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
applications/power/power_settings_app/scenes/power_settings_scene_shutdown_idle.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #include "../power_settings_app.h" | ||
| #include <lib/toolbox/value_index.h> | ||
|
|
||
| #define SHUTDOWN_IDLE_DELAY_COUNT 8 | ||
| #define SCENE_EVENT_SELECT_SHUTDOWN_IDLE_DELAY 0 | ||
|
|
||
| const char* const shutdown_idle_delay_text[SHUTDOWN_IDLE_DELAY_COUNT] = { | ||
| "OFF", | ||
| "15min", | ||
| "30min", | ||
| "1h", | ||
| "6h", | ||
| "12h", | ||
| "24h", | ||
| "48h" | ||
| }; | ||
|
|
||
| const uint32_t shutdown_idle_delay_value[SHUTDOWN_IDLE_DELAY_COUNT] = | ||
| {0, 900000, 1800000, 3600000, 21600000, 43200000, 86400000, 172800000}; | ||
|
|
||
| static void power_settings_scene_shutodwn_idle_callback(void* context, uint32_t index) { | ||
| PowerSettingsApp* app = context; | ||
| view_dispatcher_send_custom_event(app->view_dispatcher, index); | ||
| } | ||
|
|
||
| static void power_settings_scene_start_shutdown_idle_delay_changed(VariableItem* item) { | ||
| PowerSettingsApp* app = variable_item_get_context(item); | ||
| uint8_t index = variable_item_get_current_value_index(item); | ||
|
|
||
| variable_item_set_current_value_text(item, shutdown_idle_delay_text[index]); | ||
| app->shutdown_idle_delay_ms = shutdown_idle_delay_value[index]; | ||
| } | ||
|
|
||
| void power_settings_scene_shutdown_idle_on_enter(void* context) { | ||
| PowerSettingsApp* app = context; | ||
| LOAD_POWER_SETTINGS(&app->shutdown_idle_delay_ms); | ||
| VariableItemList* variable_item_list = app->variable_item_list; | ||
| VariableItem* item; | ||
| uint8_t value_index; | ||
|
|
||
| item = variable_item_list_add( | ||
| variable_item_list, | ||
| "Set Time", | ||
| SHUTDOWN_IDLE_DELAY_COUNT, | ||
| power_settings_scene_start_shutdown_idle_delay_changed, | ||
| app); | ||
|
|
||
|
|
||
| variable_item_list_set_enter_callback( | ||
| variable_item_list, power_settings_scene_shutodwn_idle_callback, app); | ||
|
|
||
| value_index = value_index_uint32( | ||
| app->shutdown_idle_delay_ms, shutdown_idle_delay_value, SHUTDOWN_IDLE_DELAY_COUNT); | ||
| variable_item_set_current_value_index(item, value_index); | ||
| variable_item_set_current_value_text(item, shutdown_idle_delay_text[value_index]); | ||
|
|
||
| view_dispatcher_switch_to_view(app->view_dispatcher, PowerSettingsAppViewVariableItemList); | ||
| } | ||
|
|
||
| bool power_settings_scene_shutdown_idle_on_event(void* context, SceneManagerEvent event) { | ||
| UNUSED(context); | ||
| bool consumed = false; | ||
|
|
||
| if(event.type == SceneManagerEventTypeCustom) { | ||
| switch(event.event) { | ||
SHxKenzuto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| case SCENE_EVENT_SELECT_SHUTDOWN_IDLE_DELAY: | ||
| consumed = true; | ||
| break; | ||
| } | ||
| } | ||
| return consumed; | ||
| } | ||
|
|
||
| void power_settings_scene_shutdown_idle_on_exit(void* context) { | ||
| PowerSettingsApp* app = context; | ||
| SAVE_POWER_SETTINGS(&app->shutdown_idle_delay_ms); | ||
| variable_item_list_reset(app->variable_item_list); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #pragma once | ||
|
|
||
| #define POWER_SETTINGS_FILE_NAME ".power.settings" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.