-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Newer ButtonHandler #782
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
Newer ButtonHandler #782
Conversation
|
I just included this in a build and it seems to boot with the screen off, then doesn't wake until the 2nd button press. |
This doesn't happen for me. Can you try the dfu artifact? |
|
I had a bunch of other stuff merged so its likely something I did wrong, I'll try it again tomorrow. |
|
@Riksu9000 is it will be possible to select which app will be tied to the long button? |
Yes, my plan was to allow selecting what app the double click opens. I was thinking that this could be integrated with #708. |
|
Thanks for this newer new version of the button handler :) However, I'm wondering if button handler could be called directly after the debounce timer (or handle the debouncing in ButtonHandler?) That way, SystemTask would need to be woken up only when we know exactly which type of action (Short press, long press, double press) was triggered. Any opinion? |
|
The reason I use the timer to wake up SystemTask is to minimize the use of the Timer task. I have been thinking that the timer task is quite big, and if we only used it to push messages to other tasks, we could shrink its stack size saving memory. |
|
That's a good reason, indeed! |
Are you asking if the stack size would need to be increased if the button was handled in the Timer task? I don't think it would, and I suspect it is already quite oversized for just pushing messages. I can't really test things like that though other than just shrinking it until it crashes or something, so someone else would have to take a closer look at that. |
|
That was also my impression. I was asking this question to see if pre-processing the button actions in the timer callback would cause any issue with the stack of the timer task. In my opinion (but I might be wrong), it would make more sense if the system task was triggered only when the actual action (short press, long press, double press) is known, which would mean we would have to move some of the code from systemtask to the timer handler. |
We would first need to decide how the timer should be used. Allowing only to push messages means we should be able to determine a small and optimized stack size. If we instead used the timer to push messages AND handle the button, then it probably needs more memory. Now if the timer task also handles the button, why not use it to handle some other things as well, and soon we end up with another general task. So we could avoid a task switch by possibly increasing memory usage. Would there be benefits to doing this? Obviously right now using the timer would be fine, but this was done in preparation of shrinking it. EDIT: Also there's a lot of guessing here, so these things would need to be checked more thoroughly. |
Anyway, it's probably good enough, and we'll still be able to change the implementation if needed later on :-) |
Reimplementation of #480 without using a FreeRTOS task.
It should work exactly like the previous PR.
I'm still looking for improvements in the code, but it should be ready to evaluate which approach is better. I might makeDoneHandleEvent()return the action, so it doesn't have to push new messages, and then I might be able to remove SystemTask from ButtonHandler.BUG: Pressing the button while the watch is sleeping wakes the watch up and also sends a button event.Fixed