Jump to content
Sign in to follow this  
TurboMagic

Precisely timed display output on Android

Recommended Posts

For some research we need to create an Android app with a precisely timed output of colored rectangles/bars.

Unfortunately TTimer has a too big jitter.

 

I need a low interval (if possible < 10ms) and unless my code in the timer event runs for longer than the interval
the timer events should come precisely and not sometimes after 10ms (given a 10ms interval is set) and sometimes
after 11 or 12 ms).

Share this post


Link to post

You need different architecture to achieve such timing. 

 

Timer is not precise enough and even if you can make it precise, there will always be other events that will mess up your timer schedule. You need a some kind of game loop. 

 

Basically, you should not rely on timer to calculate and paint your screen, you need to trigger paint event with delta time and based on that time (elapsed from last paint) you will calculate positions and render your screen.

 

Some starting point: https://gamedev.stackexchange.com/questions/651/how-should-i-write-a-main-game-loop 

 

Share this post


Link to post

For us it is sufficient to swap color of a rectangle.

Today we tried something with the bitmap of a TImage which has a clear method where you can specify the new color.

That might be sufficient, if the timer would be more jitter free. Thus we call it from a secondary thread as TBitmap is thread-safe nowadays.

 

Question is how to "time" such a thread on Android precisely enough?

Do busy waiting with TStopWatch until the necessary time is elapsed?

Or is there something better?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×