-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Feature: Soft Off #1942
Feature: Soft Off #1942
Conversation
78b84c4
to
2645a67
Compare
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.
Note that the descriptions of the nodes (like the properties etc.) can go in a table format in a dedicated page under "Configuration" and linked to from here. It is not crucial but it might have been good for consistency.
683a74a
to
3870392
Compare
3870392
to
e526122
Compare
eb8dea8
to
8af7f22
Compare
8af7f22
to
77aa402
Compare
Testing this on a nice!nanov2 sofle, I haven't been able to turn the right side off. I have mapped a &soft_off on the right half on the default layer, but that only turns off the left side. I added .locality in behavior_soft_off_driver_api and moved the target_sources to above the if statement in CMakeLists to make the peripheral power off |
another issue I found is the idle sleep now doesn't wake up with key presses anymore. |
Did you tag your kscan node with |
Does that affect both the soft_off and CONFIG_ZMK_IDLE_SLEEP_TIMEOUT? And if I were to add it, would it be the sofle. dtsi since that's the shield I'm using? |
It's needed for wake from deep sleep to work when soft off is enabled. |
happy to report that worked as expected after I added wakeup-source in the sofle shield's kscan |
593fbe4
to
251bc6d
Compare
Ok, I've just pushed tweaks for this to do this hopefully correctly, including making it soft off the peripheral side ASAP on press, not on release, so it can be invoked sooner before the central goes away. Can you please test this branch as is? |
Ah OK then, shouldn't be a breaking change in that case. |
f62df55
to
ab12762
Compare
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.
Fixed a typo on the last update, otherwise docs look good to me.
app/Kconfig.behaviors
Outdated
@@ -1,6 +1,16 @@ | |||
# Copyright (c) 2023 The ZMK Contributors | |||
# SPDX-License-Identifier: MIT | |||
|
|||
config ZMK_BEHAVIOR_KEY |
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.
This may make more sense to me once I get to the relevant files, but I have no idea what "behavior key" and "behavior key scanned" mean. Adding a description to these or finding a more descriptive name would be helpful.
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.
Renamed per the other review comment. I believe that mostly addresses it.
size_t device_count; | ||
const struct device *devs; | ||
|
||
#if !IS_ENABLED(CONFIG_ZMK_SPLIT) || IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL) |
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.
Probably something for another PR, but there are a lot of these checks for "if split and peripheral" or "if not split or central" in the codebase. Might be useful to create some macros to simplify those.
Initial work on a soft on/off support for ZMK. Triggering soft off puts the device into deep sleep with only a specific GPIO pin configured to wake the device, avoiding waking from other key presses in the matrix like the normal deep sleep. Co-authored-by: Cem Aksoylar <[email protected]>
* Add PM device hook to the kscan direct & matrix drivers.
* New soft-off behavior that can be used to force the device into soft-off state with only certain configured wakeup devices.
* Use Button 1 for soft off on the nrf52840 when using the ZMK Uno shield.
* Add ability for external callers to clear the current endpoint.
* Make sure the connected host has no held HID usages before we sleep.
* Move to explicit enable of `ZMK_PM_SOFT_OFF` to turn on the feature and use the behaviors, which matches how other features work, and helps with split and testing schemes.
Co-authored-by: Cem Aksoylar <[email protected]>
7a4892c
to
141dbd3
Compare
* Better naming for gpio-key behavior triggers. * Tweaks to scanned behavior trigger to avoid bad semaphore use, and reduce chance of issues with slowly scanned matrixes. * Various code cleanups of style issues.
141dbd3
to
b2a9990
Compare
* Code style to avoid goto. * Enable pm.c compilation via dedicated Kconfig flag. * Comment wakeup trigger PM behavior.
Will you do a soft off for charliepex? |
Closing in favor of #2085 |
This PR supersedes #1840 after some useful feedback from @joelspadin in #1840 (comment)
This new branch includes all the previous features, and also:
&soft_off
behavior that you can trigger from your keymap, and use a keyboard/controllers reset button to wake from.hold-time-ms
of the behavior, so you can require the behavior be pressed for at least that long in order for soft off to be triggered on release.See the docs deploy for this PR for details on the feature and behavior:
Only item that is a nice-to-have for the future would be some circuit diagrams for the possible hardware designs to leverage this, to complement the text descriptions of them. Don't think that should hold up this work though today.