-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored soft off. Squashed and merged.
Co-authored-by: [email protected]
- Loading branch information
1 parent
42cdca5
commit ab03ece
Showing
6 changed files
with
159 additions
and
326 deletions.
There are no files selected for viewing
This file contains 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 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 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,70 @@ | ||
--- | ||
title: Low Power States | ||
sidebar_label: Low Power States | ||
--- | ||
|
||
## Idle | ||
|
||
In the idle state, peripherals such as displays and lighting are disabled, but the keyboard remains connected to Bluetooth so it can immediately respond when you press a key. Idle state is entered automatically after a timeout period that is [30 seconds by default](../config/power.md#low-power-states). | ||
|
||
## Deep Sleep | ||
|
||
In the deep sleep state, the keyboard additionally disconnects from Bluetooth and any external power output is disabled. This state uses very little power, but it may take a few seconds to reconnect after waking. | ||
|
||
### Config | ||
|
||
Deep sleep must be enabled via its corresponding [config](../config/power.md#low-power-states). | ||
|
||
### Wakeup Sources | ||
|
||
Zephyr has general support for the concept of a device as a "wakeup source". Using deep sleep requires `kscan` nodes to have the `wakeup-source` property to enable them to wake the keyboard, e.g.: | ||
|
||
```dts | ||
/ { | ||
kscan: kscan { | ||
compatible = "zmk,kscan-gpio-matrix"; | ||
diode-direction = "col2row"; | ||
wakeup-source; | ||
... | ||
}; | ||
}; | ||
``` | ||
|
||
It is recommended to add the `wakeup-source` property to `kscan` devices even if the deep sleep feature is not used -- there is no downside to it. | ||
|
||
## Soft Off | ||
|
||
The soft off feature is used to turn the keyboard on and off explicitly, rather than through a timeout like the deep sleep feature. Depending on the keyboard, this may be through a dedicated on/off push button defined in hardware, or merely through an additional binding in the keymap to turn the device off and an existing reset button to turn the device back on. | ||
|
||
The feature is intended as an alternative to using a hardware switch to physically cut power from the battery to the keyboard. This can be useful for existing PCBs not designed for wireless that don't have a power switch, or for new designs that favor a push button on/off like found on other devices. It yields power savings comparable to the deep sleep state. | ||
|
||
:::note | ||
|
||
The power off is accomplished by putting the MCU into a "soft off" state. Power is _not_ technically removed from the entire system, but the device will only be woken from the state by a few possible events. | ||
|
||
::: | ||
|
||
A device can be put in the soft off state by: | ||
|
||
- Triggering a hardware-defined dedicated GPIO pin, if one exists; | ||
- Triggering the [soft off behavior](../keymaps/behaviors/soft-off.md) from the keymap. | ||
|
||
Once in the soft off state, the device can only be woken up by: | ||
|
||
- Triggering any GPIO pin specified to enable waking from sleep, if one exists; | ||
- Pressing a reset button found on the device. | ||
|
||
The GPIO pin used to wake from sleep can be a hardware-defined one, such as for a dedicated on-off push button, or it can be a single specific key switch reused for waking up (which may be accidentally pressed, e.g. while the device is being carried in a bag). To allow the simultaneous pressing of multiple key switches to trigger and exit soft off, some keyboards make use of additional hardware to integrate the dedicated GPIO pin into the keyboard matrix. | ||
|
||
### Config | ||
|
||
Soft off must be enabled via [its corresponding config](../config/power.md#low-power-states) before it can be used. | ||
|
||
### Using Soft Off | ||
|
||
If your keyboard has hardware designed to take advantage of soft off, refer to your keyboard's documentation. | ||
|
||
For keyboards which do not have such hardware, using soft off is as simple as placing the [soft off behavior](../keymaps/behaviors/soft-off.md) in your keymap and then invoking it. | ||
|
||
You can then wake up the keyboard by pressing the reset button once, and repeating this for each side for split keyboards. |
Oops, something went wrong.