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

DisplayApp: Go to clock on wakeup if no app loaded #1980

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

vkareh
Copy link
Contributor

@vkareh vkareh commented Jan 18, 2024

When waking the screen up, if there is no actual app loaded (i.e. we are still in the QuickSettings, Settings, or Launcher screens) we should just reload the Clock app directly.

Copy link

github-actions bot commented Jan 18, 2024

Build size and comparison to main:

Section Size Difference
text 378884B 32B
data 948B 0B
bss 63488B 0B

@vkareh
Copy link
Contributor Author

vkareh commented Jan 18, 2024

This supercedes #1436 since that one has conflicts and uses outdated function calls.

@mark9064
Copy link
Member

Future compatibility thought: with always on display (#1869), it'd be preferred if the app was loaded on sleep entry rather than on wake. But the whole sleep state might end up being refactored anyway so if this is annoying to implement then don't worry

@vkareh vkareh force-pushed the watch-face-wake-up branch from 29d3337 to c78b125 Compare January 20, 2024 04:13
@vkareh
Copy link
Contributor Author

vkareh commented Jan 20, 2024

@mark9064 - that's a good point. I tried it on sleep and it works even better (the transition is less choppy). Thanks for the suggestion!

Regarding future refactor, I feel that this is a simple enough change and can be moved around as needed without much overhead.

@mark9064
Copy link
Member

Great to hear it's working even better. To clarify what I meant originally: "as part of 1869, we might have to refactor some sleep stuff so if it's difficult to change this PR to work on sleep entry at the moment then don't worry". But you've managed to work it out anyway, so it doesn't matter 👍

@vkareh vkareh force-pushed the watch-face-wake-up branch from c78b125 to 5de54ac Compare January 22, 2024 21:36
@JustScott
Copy link
Contributor

Finding this quite nice as I consistently forget to return to the watch face. I'm wondering what thoughts are on having this also apply to the notifications, as that isn't an app that really needs to stay open after you view it once.

@vkareh vkareh force-pushed the watch-face-wake-up branch from 5de54ac to 5c4912f Compare January 23, 2024 14:31
@vkareh
Copy link
Contributor Author

vkareh commented Jan 23, 2024

@JustScott at first I assumed that this wouldn't be necessary for the Notifications screen as I usually just dismiss notifications fairly quickly after viewing them, but then realized I use #1716 as part of my daily driver branch, so it's a bit less relevant.

However, after testing it some more, I think it makes sense to add Notifications to the list. It works well with it, so I've pushed a new change.

@vkareh vkareh force-pushed the watch-face-wake-up branch 3 times, most recently from 9e2cde3 to a79cc1d Compare January 24, 2024 15:36
@vkareh vkareh force-pushed the watch-face-wake-up branch 3 times, most recently from d085f49 to a9e46ef Compare February 12, 2024 15:20
@vkareh vkareh force-pushed the watch-face-wake-up branch 2 times, most recently from 1a00af1 to 3d093f3 Compare February 19, 2024 01:11
@vkareh vkareh force-pushed the watch-face-wake-up branch from 3d093f3 to eac181b Compare March 18, 2024 12:52
@vkareh vkareh force-pushed the watch-face-wake-up branch from eac181b to 2999fc7 Compare March 26, 2024 12:15
@mark9064
Copy link
Member

Works great, don't find my watch on random screens where it has clicked itself nearly so often as all of the screens one swipe away now return back to the watchface safely. Integrates with AOD perfectly as well.

@vkareh vkareh force-pushed the watch-face-wake-up branch from 2999fc7 to cb17ba1 Compare April 12, 2024 13:00
@vkareh vkareh force-pushed the watch-face-wake-up branch from cb17ba1 to f83ec05 Compare May 13, 2024 14:56
@vkareh vkareh force-pushed the watch-face-wake-up branch from f83ec05 to 39fe594 Compare June 10, 2024 14:34
@vkareh vkareh force-pushed the watch-face-wake-up branch from 39fe594 to 2128946 Compare June 19, 2024 15:31
@vkareh vkareh force-pushed the watch-face-wake-up branch 2 times, most recently from 1d0df29 to 4dd8a73 Compare August 19, 2024 17:07
@JF002
Copy link
Collaborator

JF002 commented Aug 19, 2024

I noticed a small glitch when the watch wakes up and switches to the clock. Any idea was could be the cause of this?

20240819_182001.mp4

@vkareh vkareh force-pushed the watch-face-wake-up branch from 4dd8a73 to 2fafc1d Compare August 19, 2024 20:17
@vkareh
Copy link
Contributor Author

vkareh commented Aug 20, 2024

@JF002 no idea, but I notice it too. With the Always On option this works even better (and no glitch), but I suspect there's something happening in between turning the LCD off and loading the clock screen that keeps the previous screen in some transient store.

I wonder if a delay might help here... 🤔

@mark9064
Copy link
Member

mark9064 commented Aug 20, 2024

Could call the lvgl task handler in a loop until it has no more work to do after loading the clock screen. That way you can be sure it's fully rendered to the display before sleeping

Generally calling the handler until no more work is a bad idea as some apps e.g the timer have so much work in Refresh() that LVGL never finishes (in this case timer should use dirty value for drawing the numbers). But as watchfaces are fast to render it should be done quickly.

@vkareh
Copy link
Contributor Author

vkareh commented Aug 21, 2024

@mark9064 sounds interesting, how do I accomplish that? I'm not sure I fully understand the LVGL task API

@mark9064
Copy link
Member

mark9064 commented Aug 21, 2024

while (!lv_task_handler()) {};
lv_task_handler runs LVGL, it returns the number of ms to wait until running it again. If it returns 0 it would like to be run immediately i.e it still has more things to do

I'm not 100% on LVGL internals but I'm pretty sure it will only return a positive value once done rendering

@vkareh
Copy link
Contributor Author

vkareh commented Aug 21, 2024

Ah excellent, I was on the right track doing

          while (lv_task_handler() == 0) {
            vTaskDelay(100);
          }

Delay seems unnecessary, but things are looking good. A few more tests and I'll push. Thanks!

@mark9064
Copy link
Member

mark9064 commented Aug 21, 2024

Yeah definitely don't block there, DisplayApp is a lowest priority task so anything else that wants to run will already preempt it (and anything else with the same priority will share).
Edit:
I suppose portYIELD would be fine but

  1. it should be done quickly
  2. yielding probably won't make it finish faster

so I'd just spin in this scenario

@vkareh vkareh force-pushed the watch-face-wake-up branch from 2fafc1d to b2f6677 Compare August 21, 2024 16:55
@vkareh
Copy link
Contributor Author

vkareh commented Aug 21, 2024

Just pushed the change with the lv_task_handler loop.
It loads the clock app and then waits until it's loaded before it turns off the LCD. The effect is much nicer when turning it back on.

@vkareh vkareh force-pushed the watch-face-wake-up branch from b2f6677 to 8ee34ff Compare August 21, 2024 16:57
@JF002 JF002 self-requested a review August 21, 2024 17:40
When turning off the screen, if there is no actual app loaded (i.e. we
are still in the Launcher, Notifications, QuickSettings, or Settings
screens) we should just reload the Clock app directly.
@vkareh vkareh force-pushed the watch-face-wake-up branch from 8ee34ff to 0d26438 Compare August 21, 2024 19:04
@vkareh
Copy link
Contributor Author

vkareh commented Aug 21, 2024

I've put the clock loading code in between setting the brightness and setting the LCD state. This gets rid of the glitch entirely on both screen off and screen on.

@JF002
Copy link
Collaborator

JF002 commented Aug 22, 2024

I've put the clock loading code in between setting the brightness and setting the LCD state. This gets rid of the glitch entirely on both screen off and screen on.

Great, I prefer this solution rather than the infinite loop! I confirm that the glitch is not visible anymore 👍

@JF002 JF002 added this to the 1.15.0 milestone Aug 22, 2024
@JF002 JF002 merged commit 2625ed3 into InfiniTimeOrg:main Aug 22, 2024
6 of 7 checks passed
@vkareh vkareh deleted the watch-face-wake-up branch August 22, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants