T-Watch S3 Power button managment#9855
Conversation
Added interrupt handling for the Power/Corona button on T-Watch S3, I use it to control screen state.
|
|
There was a problem hiding this comment.
Pull request overview
Enable the T-Watch S3 “Power/Corona” button to wake/trigger logic via the PMU interrupt line, without affecting other boards (guarded by T_WATCH_S3).
Changes:
- Define the PMU interrupt GPIO for the T-Watch S3 variant.
- Attach a PMU IRQ interrupt in
Power::setup()to wake/schedule the power task immediately. - Handle PMU short-press events in
Power::runOnce()to toggle the display on/off.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| variants/esp32s3/t-watch-s3/variant.h | Adds a macro identifying the PMU IRQ GPIO used by the watch. |
| src/Power.cpp | Wires PMU IRQ into the power task scheduling and adds short-press behavior for screen toggling. |
Updated interrupt management not to cause random crashes.
|
Finally got a chance to test this, and Bravo! Really adds something that was missing to the T-watch-s3, and I'll look at re-using this idea for other devices. Thanks! |
|
There is a bit of trouble in paradise: This code currently crashes when the crown is pressed during sleep. |
Thank you for testing my code, I will look into this. |
I'm doing a little more testing, and I think this crash happens even without your code. Elsewhere in the code we unhook interrupts for sleep, and for whatever reason we're not doing so in the power function. I'll spend a bit more time on this today, and see if I can get it cleaned up. |
|
Once we get the upstream branches wrangled, this one is good to go. |
|
Thank you @jp-bennett for your precious work and time, I didn't know about the input broker channel you used. |
* PMU interrupt pin defined in t-watch s3 * Implement button control on T-Watch S3 Added interrupt handling for the Power/Corona button on T-Watch S3, I use it to control screen state. * Reducing labels * Reducing labels * Updated the comment * ISR is now IRAM-safe Updated interrupt management not to cause random crashes. * Trunk * Simplify and use INPUT_BROKER_CANCEL --------- Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz>
Hello there
I started working on this easy and simple modification because the only way to wake the t-watch s3 from light sleep status was tapping the screen and the button didn't do anything.
I noticed by looking at the circuit that the button is connected not to a pin of the main esp32s3 board, but directly and only to the PMU. So I made it so that when you press the button the PMU raises an interrupt that resets the counter of the run_once() function in the power class, making it possible to add further modifications to it if needed (for example in the future I might add something on the long press).
To prevent any impact on other devices, I've enclosed the changes within the
#ifdef T_WATCH_S3macro.In the process of doing this I noticed that the PMU interrupt pin wasn't defined on the variant.h file, so I defined it (info obtained via official documentation of the watch).
🤝 Attestations