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

Avoid over-releasing the displayport in cmsYieldDisplay() #3351

Merged
merged 1 commit into from
Jun 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/main/cms/cms.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,13 @@ long cmsMenuExit(displayPort_t *pDisplay, const void *ptr)

void cmsYieldDisplay(displayPort_t *pPort, timeMs_t duration)
{
// Check if we're already yielding, in that case just extend
// the yield time without releasing the display again, otherwise
// the yield/grab become unbalanced.
if (cmsYieldUntil == 0) {
displayRelease(pPort);
}
cmsYieldUntil = millis() + duration;
displayRelease(pPort);
}

// Stick/key detection and key codes
Expand Down Expand Up @@ -1209,6 +1214,8 @@ void cmsUpdate(uint32_t currentTimeUs)

// Only scan keys and draw if we're not yielding
if (cmsYieldUntil == 0) {
// XXX: Note that one call to cmsScanKeys() might generate multiple keypresses
// when repeating, that's why cmsYieldDisplay() has to check for multiple calls.
rcDelayMs = cmsScanKeys(currentTimeMs, lastCalledMs, rcDelayMs);
// Check again, the keypress might have produced a yield
if (cmsYieldUntil == 0) {
Expand Down