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

Introduce a restricted clock-only-mode when not woken with the button #1359

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

tgc-dk
Copy link
Contributor

@tgc-dk tgc-dk commented Oct 5, 2022

To avoid random touches ends up changing settings or starting a timer, this introduces a restricted mode where no touch input is accepted unless the hardware button is used to turn on the watch. A settings is introduces to enable this.
The restricted mode is only active on watchfaces.

This is not a perfect solution since it will require the button to be pressed several times to leave the restricted mode once in it.

@minacode
Copy link
Contributor

minacode commented Oct 6, 2022

The restricted mode is only active on watchfaces.

Why is this necessary? Wouldn't this feature be useful regardless of the active app?

@tgc-dk
Copy link
Contributor Author

tgc-dk commented Oct 7, 2022

The restricted mode is only active on watchfaces.

Why is this necessary? Wouldn't this feature be useful regardless of the active app?

The reasoning is that if you (for example) are playing the "2" game and the screen goes to sleep due to no activity, if you then wake up the screen by shaking your arm, touch input will be ignored and if you push the hardware button you will exit the game, loosing the progress.
One way to solve this is of course to make the first hardware button push unlock the restricted mode, but IMHO this would probably be a bit confusing for users since it would change how the button-push is handled depending on how the wakeup was done...

@minacode
Copy link
Contributor

minacode commented Oct 7, 2022

I think this is exactly how this should be done. The watch goes into a lock mode where the first button press does nothing but exiting that mode. Maybe we could have a popup with a lock symbol and something like "press the button to unlock" on touch events so users can better understand what is going on.

Another thing is a lock screen. We could always show the watch face on non-button wakeup (with a clue that this is a lock screen) and after pressing the button go back to the current screen. This is closer to what other devices like phones do.

@taukakao
Copy link

taukakao commented Oct 7, 2022

I agree with @minacode although I don't think a real "lock screen" makes sense. Maybe a visual indicator but a lock screen for a watch that only has a couple of modes is a bit much.

One reason I prefer it is because it enables you to have for example the navigation or timer app open on the watch and look at it from time to time. Right now this would always randomly switch to different watch faces on it's own.

@taukakao
Copy link

taukakao commented Oct 7, 2022

And because I know it will be mentioned:
No, I don't think this is a weird workaround for the issue of a too sensitive touch panel.
This is for when you currently don't want to interact with your watch but still look at it.

@tgc-dk
Copy link
Contributor Author

tgc-dk commented Oct 9, 2022

Thanks for the into @minacode and @Joheyy! I'll look into the possibility of implementing a "pop up" notifying about the lock and that the hardware button should be used to unlock.

@minacode
Copy link
Contributor

Keep in mind that the watch can wake itself (for example via notifications).

@tgc-dk
Copy link
Contributor Author

tgc-dk commented Oct 16, 2022

I've just pushed a new commit that adds a 'Popup' notification and display it when a touch input is received during 'locked' wakeup. The lock is now active on all screens, though not when an app as caused the wakeup.
I have only tested this in the simulator so far...
Let me know what you think!
I've attached a small animation that shows the lock in action.

InfiniSim_2022-10-16_195522

@Avamander
Copy link
Collaborator

That approach seems good, also very similar to that of say Apple Watch.

@minacode
Copy link
Contributor

I like it.

Can you explain the intuition behind the three WokenBy values? Button explains itself, but what exactly are WakeUpAction and Other? What cases do and don't they cover?

@tgc-dk
Copy link
Contributor Author

tgc-dk commented Oct 17, 2022

Can you explain the intuition behind the three WokenBy values? Button explains itself, but what exactly are WakeUpAction and Other? What cases do and don't they cover?

The WokenBy values are:

  • Button: Pretty self explanatory as you say)
  • WakeUpAction: The actions selected in the wakeup settings, single/double tap, raise, shake
  • Other: Other things that can wake the watch up, basically apps and notifications.

In reality it might be possible to replace the values with a simple boolean wokenByAction, but I'm not yet sure...

@minacode
Copy link
Contributor

I would like that in a comment, in the code. Or better names, I don't know. UserButtonWakeup, UserNonButtonWakeup, SystemAutoWakeup? Sounds weird as well..

Copy link
Contributor

@NeroBurner NeroBurner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be a good idea to move the popup to displayapp and use displayapp/Messages.h to communicate between the systemtask and DisplayApp

src/systemtask/SystemTask.cpp Outdated Show resolved Hide resolved
src/displayapp/widgets/PopupMessage.cpp Outdated Show resolved Hide resolved
src/displayapp/screens/settings/SettingWakeUp.cpp Outdated Show resolved Hide resolved
src/displayapp/widgets/PopupMessage.h Outdated Show resolved Hide resolved
@tgc-dk
Copy link
Contributor Author

tgc-dk commented Nov 7, 2022

I think it would be a good idea to move the popup to displayapp and use displayapp/Messages.h to communicate between the systemtask and DisplayApp

Changed as suggested

@tgc-dk tgc-dk requested a review from NeroBurner November 7, 2022 21:23
@NeroBurner NeroBurner added the enhancement Enhancement to an existing app/feature label Nov 29, 2022
@github-actions
Copy link

github-actions bot commented May 2, 2023

Build size and comparison to main:

Section Size Difference
text 375680B 1152B
data 948B 0B
bss 63504B 16B

@pipe01
Copy link
Contributor

pipe01 commented Oct 26, 2023

Any updates on this?

@tgc-dk
Copy link
Contributor Author

tgc-dk commented Nov 28, 2023

I've introduced a second page to the WakeUp settings since there was no room left for new checkbox.
Note that the CI simulator build fails due to changes needed in InfiniSim to build with the changes in this PR, see InfiniTimeOrg/InfiniSim#131

@NeroBurner Are you up for a re-review?

@riban-bw
Copy link

riban-bw commented Jan 19, 2024

I've just pushed a new commit that adds a 'Popup' notification and display it when a touch input is received during 'locked' wakeup. The lock is now active on all screens, though not when an app as caused the wakeup. I have only tested this in the simulator so far... Let me know what you think! I've attached a small animation that shows the lock in action.

InfiniSim_2022-10-16_195522

The popup seems rather intrusive. If we are trying to avoid activity that occurs fairly frequently then it is possible that the popup will obscure the display when the user wants to view the watchface. Could we just use a lock icon instead? This is a user configured feature that would probably be disabled by default so the user must enable it and therefore shoudl understand the purpose of the icon. (It could be reinforced by showing the same icon in the settings screen.) The lock icon could show in a notification space, e.g. top of screen. It could either be always visible when locked, shown on activity or visible and highlight on activity. This may also reduce the memory increase. (One icon may be less than lots of text?)

I really like the idea of a lock mechanism (as I too suffer the issue of unexpected activity) but don't want something obscuring the screen.

@NeroBurner
Copy link
Contributor

I'm in favor of the lock as it doesn't need to be translated and should be easily understood. I like the visual hint to use the lock in the setting screen as well

@jgonyea
Copy link

jgonyea commented Jan 25, 2024

I also would love to see this feature added. I don't know how, but I constantly am waking the screen and accidentally tapping on screen elements. This would solve this issue for me!

@tgc-dk
Copy link
Contributor Author

tgc-dk commented Jan 27, 2024

@riban-bw

The popup seems rather intrusive. If we are trying to avoid activity that occurs fairly frequently then it is possible that the popup will obscure the display when the user wants to view the watchface.

Please note that the lock screen first shows up after the screen has been woken up AND a touch gesture has been identified, meaning that the lock screen does not automatically show when the display is on.

@riban-bw @NeroBurner

I'm in favor of the lock as it doesn't need to be translated and should be easily understood. I like the visual hint to use the lock in the setting screen as well

This is a valid point, I'll change the lock screen to use an actual icon. Regarding using the lock in the in the settings, how do you envision this to be done? See the screenshot below for the current settings screen, shown is the (new) second settings page under "Wake Up". Where should the lock icon be placed?

InfiniSim_2024-01-27_181545

The lock icon could show in a notification space, e.g. top of screen. It could either be always visible when locked, shown on activity or visible and highlight on activity.

If I understand you correctly, this would be nice, but it would require that InfiniTime has a global notification bar for it to be consisted across screens, which it don't, so I think I'll stick with the pop-up for now.

@tgc-dk
Copy link
Contributor Author

tgc-dk commented Jan 27, 2024

@NeroBurner @riban-bw
Using the popup with a lock icon could look like this:
InfiniSim_2024-01-27_220733

@jgonyea
Copy link

jgonyea commented Jan 27, 2024 via email

@mark9064
Copy link
Member

mark9064 commented Jan 28, 2024

If you check the build logs, the difference in RAM usage is just 64B. It's just that infinitime is very close to the memory limit right now - keep the lock change but decrease the heap size a little

@tgc-dk
Copy link
Contributor Author

tgc-dk commented Jan 29, 2024

@mark9064

If you check the build logs, the difference in RAM usage is just 64B. It's just that infinitime is very close to the memory limit right now - keep the lock change but decrease the heap size a little

Just to be sure... Would I be right in assuming this can be done by in src/FreeRTOSConfig.h changing configTOTAL_HEAP_SIZE from (1024 * 40) to (1024 * 39) ?

@minacode
Copy link
Contributor

(1024 * 35) was recommended before by JF to me for the calculator app.

@tgc-dk
Copy link
Contributor Author

tgc-dk commented Jan 29, 2024

Pushed the new changes. The simulator build still fails due to dependent on changes in InfiniTimeOrg/InfiniSim#131

@tgc-dk tgc-dk requested a review from NeroBurner May 5, 2024 18:53
@NeroBurner
Copy link
Contributor

NeroBurner commented Sep 16, 2024

Just for visuals a screenshot of how the lock overlay looks on the Analog Watch Face

Analog Watch Face showing lock overlay

edit: oh you posted exactly the same screenshot already in #1359 (comment) 🙈

@NeroBurner
Copy link
Contributor

@tgc-dk I rebased your changes on current main, resolved merge conflicts, squashed commits down to 3 commits

  • first commit all your changes rebased and squashed
  • second commit reducing heap size
  • third default buttonUnlocksOn to false to make it work with current InfiniSim

The rebased branch can be found here: https://github.com/InfiniTimeOrg/InfiniTime/tree/button-unlock_neroburner

tgc-dk and others added 2 commits September 30, 2024 22:55
Improve the lock and the code
Squeeze in button unlock option in Wake Up settings
Split the WakeUp settings into 2 pages
Replace the text in the popup with a lock icon.

Co-authored-by: NeroBurner <[email protected]>
@mark9064
Copy link
Member

mark9064 commented Sep 30, 2024

Can I suggest lowering the heap size to 39 rather than 35? Ideally the heap should be as large as possible as long as it compiles

@tgc-dk
Copy link
Contributor Author

tgc-dk commented Oct 3, 2024

@tgc-dk I rebased your changes on current main, resolved merge conflicts, squashed commits down to 3 commits

* first commit all your changes rebased and squashed

* second commit reducing heap size

* third default buttonUnlocksOn to false to make it work with current InfiniSim

The rebased branch can be found here: https://github.com/InfiniTimeOrg/InfiniTime/tree/button-unlock_neroburner

Hi @NeroBurner
I've commited you're suggested change, but I currently do not have the "bandwidth" to do much more... Feel free to create a PR based on your branch!
I will probably get some more time later in the year, so I can probably do the merge and resolve conflicts then, but I don't see any reason to wait...

@NeroBurner
Copy link
Contributor

On GitHub the PR receiver can force push on the branch to be merged? Didn't expect that, but now I force pushed into your repo and overwrote the branch. I hope this is OK for you 😅

@mark9064
Copy link
Member

mark9064 commented Oct 5, 2024

Is this ready for review?

@tgc-dk
Copy link
Contributor Author

tgc-dk commented Oct 6, 2024

On GitHub the PR receiver can force push on the branch to be merged? Didn't expect that, but now I force pushed into your repo and overwrote the branch. I hope this is OK for you 😅

No worries :)

@tgc-dk
Copy link
Contributor Author

tgc-dk commented Oct 6, 2024

Is this ready for review?

I believe so 👍

@NeroBurner
Copy link
Contributor

I am testing if the RAM increase can be lessened by drawing the clock symbol using LVGL rectangles instead of a font symbol. Just a matter of time ⌛ 😁

@mark9064
Copy link
Member

mark9064 commented Oct 6, 2024

That would be great, as fonts seem to be a ram sucker 👍

@NeroBurner
Copy link
Contributor

Got a lock symbol drawn with lvgl. Only two lv_obj needed (in addition to the pop-up background lv_obj). Not pretty, but help welcome :D

InfiniSim_2024-10-06_button_unlock_lvgl

comparing f0211e5 (lock with font symbol) against 2a8e953 (lock with lvgl)

On WatchFace::Terminal we're saving 340B FLASH and 64B of RAM when drawing with LVGL instead of using the font (this is a 0.1% reduction in FLASH)

For comparison the current main branch with the same HEAP reduction as this PR currently has (1024 * 35) we have the following numbers.

  • main with HEAP size 35KB:
    • default config:
      • FLASH: 374548 B -- 78.91%
      • RAM: 59320 B -- 90.52 %
    • WatchFace::Terminal
      • FLASH: 300232 B -- 63.26%
      • RAM: 59104 B -- 90.19%

Which means with lvgl lock we still add 16B RAM and we reduce FLASH by 544 B ( ❓ )

@NeroBurner
Copy link
Contributor

NeroBurner commented Oct 6, 2024

I can revert the HEAP-size reduction now and we still stay in RAM bounds 🎉

all default Apps/WatchFaces
USERAPP_TYPES:STRING=Apps::StopWatch, Apps::Alarm, Apps::Timer, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Paint, Apps::Paddle, Apps::Twos, Apps::Dice, Apps::Metronome, Apps::Navigation, Apps::Weather
WATCHFACE_TYPES:STRING=WatchFace::Digital, WatchFace::Analog, WatchFace::PineTimeStyle, WatchFace::Terminal, WatchFace::Infineat, WatchFace::CasioStyleG7710
           FLASH:      375700 B     474632 B     79.16%
             RAM:       64456 B        64 KB     98.35%
WatchFace::Terminal
           FLASH:      299688 B     474632 B     63.14%
             RAM:       64240 B        64 KB     98.02%

vs current main branch this PR is based on a2356f2

all default Apps/WatchFaces
USERAPP_TYPES:STRING=Apps::StopWatch, Apps::Alarm, Apps::Timer, Apps::Steps, Apps::HeartRate, Apps::Music, Apps::Paint, Apps::Paddle, Apps::Twos, Apps::Dice, Apps::Metronome, Apps::Navigation, Apps::Weather
WATCHFACE_TYPES:STRING=WatchFace::Digital, WatchFace::Analog, WatchFace::PineTimeStyle, WatchFace::Terminal, WatchFace::Infineat, WatchFace::CasioStyleG7710
           FLASH:      374548 B     474632 B     78.91%
             RAM:       64440 B        64 KB     98.33%
WatchFace::Terminal
           FLASH:      298520 B     474632 B     62.90%
             RAM:       64224 B        64 KB     98.00%

@mark9064
Copy link
Member

@NeroBurner is this now ready for review? If so could you rebase onto main?

@mark9064 mark9064 modified the milestones: 1.15.0, 1.16.0 Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement to an existing app/feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants