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

Async matrix scanning, reduce power consumption #45

Merged
merged 9 commits into from
Jun 8, 2024
Merged

Conversation

HaoboGu
Copy link
Owner

@HaoboGu HaoboGu commented Jun 6, 2024

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 using wait_for_low(), which is actually the Wait trait in embedded-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 for embassy-stme32, or gpiote feature should be enabled for embassy-nrf. That means, the input pins for stm32 could not share the same pin number(see the doc of ExtiInput)

Power consumption

~200ua when advertising

~450ua when idle (no key).

3ma when scanning and sending BLE keyboard report

TODO list

  • basic implementation of async matrix
  • test embassy-nrf, report the power consumption
  • update rmk-macro to generate correct input pin types, add an option in keyboard.toml
  • update documentation and examples
  • update rmk-template

Signed-off-by: HaoboGu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: HaoboGu <haobogu@outlook.com>
Signed-off-by: HaoboGu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
Signed-off-by: Haobo Gu <haobogu@outlook.com>
@HaoboGu HaoboGu merged commit 2fdbe63 into main Jun 8, 2024
2 checks passed
@HaoboGu HaoboGu deleted the feat/low_power branch June 8, 2024 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uC Power Consumption and sleep mode
1 participant