-
-
Notifications
You must be signed in to change notification settings - Fork 745
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
Keep the locked warning for some time #1957
Conversation
allow to use remaining state1 for timer
revert last commit
show the locked warning for half a second
change locked warning display time to 1 second
Does not work because handleSolderingButtons is not called when nothing happens with the buttons?! |
fix timer logic
Timer logic was wrong, it seems to work now with 1s display time. Can be shorter on tick overflow. |
fix another logic error
|
The implementation uses the remaining 14 bits of the state as a tick counter. So with e.g. 1000 ticks per second and one-second display time, there is a 1 out of 16 seconds window for a short display to happen. Increasing the state to 32-bit can make this less likely. Looking at other uses of the global tick counter, it seems the current policy is for the device not to be powered until an overflow can happen. |
If it is ok to block the task, the tick stuff can be removed. |
cxt->scratch_state.state2 = 1; | ||
if (cxt->scratch_state.state1 > 3) { | ||
// show locked until timer is up | ||
if ((uint16_t)(xTaskGetTickCount() << 2) - (cxt->scratch_state.state1 & ~3) > TICKS_SECOND << 2) { |
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.
Rather than bit packing this I would advise to use a uint32_t or a dedicated uint16_t so that rollover/under wraps and does roughly what is expected. You can use one of the other state variables for the time by itself. If none a spare, add another one :)
I do agree with the concept though, this is good as it keeps it non-blocking which is the end-game goal of the UI code.
Hia @neon12345 ,
Yeah, I would strongly suggest using a 32bit state variable if you can. I added the comment in the code review to keep it a bit more trackable. I think your on the right path though.
The general logic is to use the TickType_t (aka uint32_t) and to use the rollover/under of the uint32_t in the maths. Which often will work. But also its not expected for a device to be powered for 49 days straight often. |
add state7 for locked timer ticks
fix timed locked warning based on review comments with additional state7 field.
I added state7, but state4 is possibly also safe to use. |
@neon12345 Please test this build: https://github.com/discip/IronOS/actions/runs/10274229163 I've tested it successfully on all of these: @Ralim |
Could you explain the changes compared to this pull request? Since I would only release the buttons after the confirmation, I am fine with the double-button handling. |
@neon12345 The little change I made does only let the mentioned confirmation texts stay a bit longer. 😊 Also this line:
will not be missed if it gets removed. The warning will be still displayed. |
If you let go of the buttons, you will then have to wait one second for the message to go away. Why not just press (as long as you want) until you recognize what happened? 😃 But if this is what you want, I would suggest using the timer ticks and states instead of vTaskDelay. |
allow unlock during locked warning
|
use the LockingKeysString message for state 2
I have changed the message used for state 2 to LockingKeysString, to make it more consistent. For 1: This would be multiple times the effort of the current implementation. I can not commit more time for this at the moment. |
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.
That'll do! 👍
Thank you! 😊
This is an untested draft to keep the locked warning for some time, independet of how long a button is pressed.