Luna keyboard pet OLED timeout fix #17189
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The old keyboard pet code would cause the screen to flicker after timeout because the animation would keep on running and each new frame would turn the screen on, after which the timeout logic would turn it off (provided the screen was idle for
> OLED_TIMEOUT
). The same flicker would be triggered by other triggers that turn the screen on, for instance toggling Caps Lock.Description
The on/off bug is fixed by using the animation idle timer (
anim_sleep
) also to track whether the screen is off or not. If the screen turns on (for whatever reason), we restart the timer. Also, we only render the keyboard pet when the screen is on, to prevent causing it to turn on.Implications and Alternatives
The keyboard pet OLED timeout logic duplicates the timeout logic in the OLED driver. There are two more thorough solutions I can think of that make reimplementing the logic unnecessary.
OLED_IDLE_BLOCKS_MASK
is easy to implement. This macro would specify aOLED_BLOCK_TYPE
value and blocks in the mask would not cause the screen to be turned on (and the timeout timer to be reset).For (2), the
oled_on()
line indrivers/oled/ssd1306_sh1106.c:oled_render
would change toThis second option would offer a generic solution for using the screen timeout when a long-running animation is being shown. The downside is that figuring out the correct blocks mask is not very ergonomic. It is also a bit of a misuse of the block-based rendering logic.
As a remnant of looking into this, I had the addition of an assertion in the OLED driver implementation laying around. I added it to this PR. The assertion is violated in code by @7-rate, but indeed: that code is broken since support for fonts with lines of any height other than 8 pixels is not implemented.
Types of Changes
Issues Fixed or Closed by This PR
Checklist