-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Use PORT events for kscan matrix interrupts, add option for deep sleep. #211
Use PORT events for kscan matrix interrupts, add option for deep sleep. #211
Conversation
255cc73
to
3b3c7e5
Compare
Ok, I've pushed ever more to this branch, this now includes the initial sleep/power management support I've been working on. This include support for:
To test, you should be able to add:
And uncomment the timeout to change the default idle from 15 minutes to 30 seconds for easier testing. @Nicell I haven't had a chance to fix the adveristing stuff yet to reduce power further, but can you try profiling this, in particularr once this actually enters deep sleep? CaveatsOn Linux (only so far), sometimes when resuming from sleep, my laptop will reconnect to the keyboard, but fail to setup the correct HOG input device, so even though the keyboard is sending GATT notifications on HID events, no one on the other end is listening. I've got some |
Ok, so digging a bit more on the Linux reconnect issue, I find this discrepancy between working and non-working Working:
There is a "read by type" request that the keyboard responds to with an error. When not working, I see this:
The "read by type" never is responded to by ZMK, which I think leaves the Linux HOG code "waiting" for a response, so it never finishes subscribing, creating the necessary HOG input device, etc. Will dig more. |
The |
Oh! For testing, make sure you do a |
* Lower power usage compared to regular interrupts on nrf52.
e9e432e
to
dfa316b
Compare
* New ZMK_SLEEP Kconfig symbol to enable the functionality. * Switch to PORT events that allows wake from deep sleep. * Initial basic power management policy, with idle ms, and ignoring deep sleep if we detect a USB connection.
dfa316b
to
a7496ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here goes nothing!
…-event-exploration Use PORT events for kscan matrix interrupts, add option for deep sleep.
…-event-exploration Use PORT events for kscan matrix interrupts, add option for deep sleep.
I've taken the first approach suggested in zephyrproject-rtos/zephyr#28499 and updated the matrix KSCAN driver to using
GPIO_INT_LEVEL_ACTIVE
, and disabling the interrupt(s) as soon as we get our first one.This is fine, since we continuously poll and read while keys are pressed to properly detect releases, especially for multiple keys sharing the same input pin.
@Nicell Before I spend more time pursuing this, would you mind testing this, and power profiling it to compare the idle usage with this change?
Assuming this is working properly (I believe it is), we should be able to leverage this for enabling deep sleep, and allow waking each half with key presses, since the PORT events should still trigger when in that low power mode.