Async matrix scanning, reduce power consumption #45
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #24
Background
In current implementation, the keyboard matrix is continuously scanned, which leads to high power consumption, and low battery life in BLE situation.
Implementation
This PR adds a RMK feature,
async_matrix
, which is an async way for matrix scanning. When the the keyboard is idle, the matrix will not be scanned. Instead, all the output pins are set to high level, and the keyboard will monitor the input pins usingwait_for_low()
, which is actually theWait
trait inembedded-hal-async
. In embassy's implementation,wait_for_low()
is low-power by default. So this would reduce the idle power consumption.Notes
To use the
Wait
trait in the input pins,exti
feature should be enabled forembassy-stme32
, orgpiote
feature should be enabled forembassy-nrf
. That means, the input pins for stm32 could not share the same pin number(see the doc ofExtiInput
)Power consumption
~200ua when advertising
~450ua when idle (no key).
3ma when scanning and sending BLE keyboard report
TODO list
rmk-macro
to generate correct input pin types, add an option inkeyboard.toml