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

pico_display_demo sleep (why?) #1001

Open
peardox opened this issue Sep 23, 2024 · 2 comments
Open

pico_display_demo sleep (why?) #1001

peardox opened this issue Sep 23, 2024 · 2 comments

Comments

@peardox
Copy link

peardox commented Sep 23, 2024

I just made a small tweak to the pico_display demo for the pico display pack

I noticed the code has sleep_ms(1000 / 60);

I set a variable to time_us_64() at the start of the main loop then calculated the elapsed time (i.e. frame time) at the end of the loop where the sleep is

The elapsed time was in the 62700 us region (fluctuates slightly) which is about 16 FPS

The sleep adds an extra 16667 us to the frame and is far less than the implied 60FPS it's seemingly trying to limit

OK, some screens could potentially go > 60FPS but surely it'd be better to at least check if the frame time was under the limit before adding more delay? Better in such cases would be to calc a more accurate value for the sleep....

@Gadgetoid
Copy link
Member

It looks like a relatively old example into which not much thought was put. Could probably use some TLC, albeit I'd reserve that for after the PicoVector rewrite has been merged: #853

Accurate frame pacing is probably somewhat outside of the scope of a simple API demo, though, but could be nice in a standalone example.

@peardox
Copy link
Author

peardox commented Sep 26, 2024

Removing the code that draws a load of trangles to create a sort of windmill effect so you've just got the bouncing balls left and removing the sleep increases the speed to > 60FPS - making it a bit more realistic

But, yeah, the display demos prob need a bit of an overhaul

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

No branches or pull requests

2 participants