-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Feat: BLE prevent sleep while active connected and Feat: allow sleep while USB powered #3286
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
Changes from all commits
91d2712
2f6c220
718363e
ab99ab0
5eebe71
6257e54
40dc54d
d9d4575
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,6 +26,10 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); | |||||||||||||||||||||||
| #include <zmk/usb.h> | ||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #if IS_ENABLED(CONFIG_ZMK_BLE_PREVENT_SLEEP_WHILE_ACTIVE_CONNECTED) | ||||||||||||||||||||||||
| #include <zmk/ble.h> | ||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #if IS_ENABLED(CONFIG_ZMK_POINTING) | ||||||||||||||||||||||||
| #include <zephyr/input/input.h> | ||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||
|
|
@@ -75,7 +79,16 @@ void activity_work_handler(struct k_work *work) { | |||||||||||||||||||||||
| int32_t current = k_uptime_get(); | ||||||||||||||||||||||||
| int32_t inactive_time = current - activity_last_uptime; | ||||||||||||||||||||||||
| #if IS_ENABLED(CONFIG_ZMK_SLEEP) | ||||||||||||||||||||||||
| if (inactive_time > MAX_SLEEP_MS && !is_usb_power_present()) { | ||||||||||||||||||||||||
| bool prevent_sleep = !IS_ENABLED(CONFIG_ZMK_USB_ALLOW_SLEEP_WHILE_POWERED) && is_usb_power_present(); | ||||||||||||||||||||||||
| #if IS_ENABLED(CONFIG_ZMK_BLE_PREVENT_SLEEP_WHILE_ACTIVE_CONNECTED) | ||||||||||||||||||||||||
| prevent_sleep = prevent_sleep || | ||||||||||||||||||||||||
| #if !IS_ENABLED(CONFIG_ZMK_SPLIT) || IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL) | ||||||||||||||||||||||||
| zmk_ble_active_profile_is_connected(); | ||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||
| zmk_split_bt_peripheral_is_connected(); | ||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||
|
Comment on lines
+84
to
+89
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
maybe clearer to not split statements across preproc directives?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely more readable, I like it. |
||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||
| if (inactive_time > MAX_SLEEP_MS && !prevent_sleep) { | ||||||||||||||||||||||||
| // Put devices in suspend power mode before sleeping | ||||||||||||||||||||||||
| set_state(ZMK_ACTIVITY_SLEEP); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phrase in terms of preventing/allowing sleep instead of keeping awake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also a great catch, I think I spotted this one and forgot it unfortunately.