Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Cem Aksoylar <[email protected]>
  • Loading branch information
petejohanson and caksoylar authored Jul 20, 2023
1 parent 0569d80 commit 5ee0382
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions docs/docs/features/soft-on-off.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,29 @@ soft off state when it goes active again later.

The simplest way to achieve this is with a push button between a GPIO pin and ground.

Another, more complicate option, if you want to use a key combination in your existing keyboard matrix, is to tie two of the switch outputs in the matrix together through an AND gate and connect that to the dedicated GPIO pin.
Another, more complicated option is to tie two of the switch outputs in the matrix together through an AND gate and connect that to the dedicated GPIO pin. This way you can use a key combination in your existing keyboard matrix to trigger soft on/off.

### Firmware Changes

To add soft on/off to a board or shield, a new node needs to be added to your devicetree source. Here is an example complete node:

```
/ {
...
...
soft_on_off {
compatible = "zmk,soft-on-off-gpio";
input-gpios = <&gpio0 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
soft_on_off {
compatible = "zmk,soft-on-off-gpio";
input-gpios = <&gpio0 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
wakeup-sources = <&kscan0>;
};
};
};
```

Here are the requirements for the node:

- The `compatible` property for the node must be `zmk,soft-on-off-gpio`.
- The `input-gpios` property is a phandle to the GPIO pin, with the correct pull up/down and active high/low flag set.
- The `input-gpios` property is a phandle to the GPIO pin, with the correct pull up/down and active high/low flag set. In the above example the soft on/off would be triggered by pulling the pin low.
- The `wakeup-sources` is a list of devices that needs to be shutdown before going into power off state, to ensure
that _only_ our soft on/off device will wake up the keyboard later. Typically this points to the `kscan` node that
is configured for the keyboard, which can also wake the keyboard from a "deep sleep from idle" state.
is configured for the keyboard, which can also wake the keyboard from a ["deep sleep from idle"](../config/power.md#idlesleep) state.
- An optional `output-gpios` property contains a list of GPIO pins to set active before going into power off, if needed to ensure the GPIO pin will trigger properly to wake the keyboard.

0 comments on commit 5ee0382

Please sign in to comment.