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

Improve calculation of frame rate delay #35

Open
embedded-creations opened this issue May 22, 2019 · 0 comments
Open

Improve calculation of frame rate delay #35

embedded-creations opened this issue May 22, 2019 · 0 comments

Comments

@embedded-creations
Copy link
Contributor

    // wait until time to display next frame
    while(nextFrameTime_ms > millis());

    // calculate time to display next frame
    nextFrameTime_ms = millis() + (10 * frameDelay);
    if(updateScreenCallback)
        (*updateScreenCallback)();

Ideally we want nextFrameTime_ms to be exactly equal to millis() when we calculate the time for next frame. If however it's taken longer, and now nextFrameTime_ms is less than millis(), we update the frame late, and extend that delay into the nextFrameTime_ms calculation, so a late frame makes the next frame even later, instead of trying to make up the delay. The nextFrameTime_ms calculation should take this into account.

Potentially if keeping the pacing of the GIF is important and we get behind we may want to skip frames

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

1 participant