Skip to content
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

Soft Off (take 3) #2085

Merged
merged 28 commits into from
Mar 28, 2024
Merged

Conversation

petejohanson
Copy link
Contributor

Ok, after some good discussion with @joelspadin around the cursed "scanned behavior trigger" we've decided to pursue another route. This PR replaces #1942 and removes the scanned trigger, as well as fixing the last few review items there. Hoping this will be the one that finally wins. A follow up PR will add "side band kscan behavior triggers" so that the "matrix integrated soft off" is supported sanely.

@petejohanson petejohanson added enhancement New feature or request core Core functionality/behavior of ZMK behaviors labels Dec 30, 2023
@petejohanson petejohanson self-assigned this Dec 30, 2023
@petejohanson petejohanson requested a review from a team as a code owner December 30, 2023 00:32
app/boards/shields/zmk_uno/zmk_uno.overlay Outdated Show resolved Hide resolved
app/boards/shields/zmk_uno/zmk_uno_split.keymap Outdated Show resolved Hide resolved
app/dts/bindings/kscan/zmk,kscan-sideband-behaviors.yaml Outdated Show resolved Hide resolved
app/dts/bindings/kscan/zmk,kscan-sideband-behaviors.yaml Outdated Show resolved Hide resolved
app/module/drivers/kscan/kscan_gpio_direct.c Outdated Show resolved Hide resolved
app/src/kscan_sideband_behaviors.c Outdated Show resolved Hide resolved
app/src/kscan_sideband_behaviors.c Outdated Show resolved Hide resolved
app/src/kscan_sideband_behaviors.c Outdated Show resolved Hide resolved
app/src/kscan_sideband_behaviors.c Show resolved Hide resolved
app/src/kscan_sideband_behaviors.c Show resolved Hide resolved
@petejohanson petejohanson force-pushed the features/soft-off-take-3 branch 2 times, most recently from 60ac8b0 to ecac94d Compare January 22, 2024 22:11
app/src/kscan_sideband_behaviors.c Outdated Show resolved Hide resolved
app/Kconfig Outdated Show resolved Hide resolved
app/Kconfig Outdated Show resolved Hide resolved
app/Kconfig Outdated Show resolved Hide resolved
app/src/kscan_sideband_behaviors.c Outdated Show resolved Hide resolved
app/src/kscan_sideband_behaviors.c Outdated Show resolved Hide resolved
@petejohanson petejohanson force-pushed the features/soft-off-take-3 branch 2 times, most recently from 6c2dc72 to 82dbe3c Compare January 30, 2024 00:39
@petejohanson petejohanson force-pushed the features/soft-off-take-3 branch 3 times, most recently from c3281e9 to 911ad68 Compare February 20, 2024 06:23
@petejohanson
Copy link
Contributor Author

@caksoylar Ok, I've pushed updated docs to cover the new sideband behavior kscan driver and how to use it with simple direct GPIO and for matrix integrated hardware combos. Would appreciate your feedback when you have a sec.

docs/docs/behaviors/soft-off.md Show resolved Hide resolved
docs/docs/features/soft-off.md Outdated Show resolved Hide resolved
docs/docs/features/soft-off.md Outdated Show resolved Hide resolved

- The `gpios` property should be a phandle-array with a fully defined GPIO pin and with the correct pull up/down and active high/low flags set. In the above example the soft on/off would be triggered by pulling the specified pin low, typically by pressing a switch that has the other leg connected to ground.

#### Soft Off Waker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am having some trouble understanding: Is this still necessary if you follow the "Simple Direct Pin" section under sideband?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So.. good question. Yes, but let me think if we could avoid it and just depend on the direct kscan itself to do the waking in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so did a little testing, and no, it isn't actually required in that case, you can directly use the small dedicated direct kscan as the soft off waker.... Let me think about how best to capture this in the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caksoylar Ok, pushed docs tweaks and changed the ZMK Uno shield to reflect the updated recommended approach that adds the extra waker only when using the matrix integrated approach.

docs/docs/features/soft-off.md Show resolved Hide resolved
petejohanson and others added 18 commits March 25, 2024 02:41
* Code style to avoid goto.
* Enable pm.c compilation via dedicated Kconfig flag.
* Comment wakeup trigger PM behavior.
* Remove the painful scanned behavior trigger for now, future enhancement
  will restore this high level functionality using kscan directly.
* Allow specifying direct kscan driver pins using gpio-key list
  as an alternative.
* Instead of gpio key behavior trigger, add new kscan driver that
  decorates/wraps a given kscan driver and will invoke basic system
  behavior assigned to a given row + column, without the need for keymap
  mapping in the matrix transform, bypassing keymaps entirely.
* Invoke output selection from the slider on the ZMK Uno via
  sideband behavior setup, to simplify keymap.
* Add a small sleep to allow other threads to send data for the
  endpoint clearing before sleep.
* Properly implement the PM hook needed for sideband behavior
  kscan device to have wakeup source enabled on it.
* Add dedicated init priority for the sideband kscan.
* Refactor sideband code for clarity.
* Tweaks to direct kscan for clarity.
* Make sideband behavior row optional for brevity.
* Allow overriding ZMK Uno sideband behaviors.
* Document new sideband behavior kscan driver for integrated
  soft-off support.
* Use the correct property for extra GPIOs to
  make active for the waker before going into soft
  off state.
* Change header depth for easier navigation of the
  soft off feature page.

Co-authored-by: Pablo Martínez <[email protected]>
* When adding a dedicated GPIO pin for soft off/on, use the direct
  kscan as the waker, instead of adding an additional node.
* Avoid overwriting random memory by using
  iterable section created by Zephyr PM.
* Add new flag to differentiate soft off on peripherals that
  is invoked by split GATT svc and dedicated additional ones
  tied to GPIO pin.
@petejohanson petejohanson force-pushed the features/soft-off-take-3 branch from 5de1c85 to 89f564d Compare March 25, 2024 09:41
@petejohanson petejohanson force-pushed the features/soft-off-take-3 branch from e414937 to be0ada2 Compare March 28, 2024 03:38
@petejohanson petejohanson requested a review from caksoylar March 28, 2024 03:40
@petejohanson petejohanson merged commit e66f068 into zmkfirmware:main Mar 28, 2024
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
behaviors core Core functionality/behavior of ZMK enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants