Adjust oled gen to fix flashing on timeout (#18747)

Fixes an issue in Ocean Dream that causes flashing after the oled screen
times out and turns off.

This occurs because writing to an OLED screen turns it on as well and we
are both writing then immediately turning the screen off, but only if
the timeout has occurred (no WPM, 30 seconds has passed).
This commit is contained in:
Tyler Thrailkill 2022-10-18 18:40:26 -06:00 committed by GitHub
parent 89dbc18161
commit 0b8fbff1cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 62 additions and 61 deletions

View File

@ -502,11 +502,9 @@ static void animate_shooting_stars(void) {
* Calls all different animations at different rates * Calls all different animations at different rates
*/ */
void render_stars(void) { void render_stars(void) {
// // animation timer
if (timer_elapsed32(starry_night_anim_timer) > STARRY_NIGHT_ANIM_FRAME_DURATION) {
starry_night_anim_timer = timer_read32();
current_wpm = get_current_wpm(); current_wpm = get_current_wpm();
void render_stars_anim(void) {
#ifdef ENABLE_ISLAND #ifdef ENABLE_ISLAND
animate_island(); animate_island();
#endif #endif
@ -545,9 +543,12 @@ void render_stars(void) {
animation_counter = increment_counter(animation_counter, NUMBER_OF_FRAMES); animation_counter = increment_counter(animation_counter, NUMBER_OF_FRAMES);
} }
// this fixes the screen on and off bug
if (current_wpm > 0) { // Turn screen on/off based on typing and timeout
if (current_wpm > 0 && timer_elapsed32(starry_night_anim_timer) > STARRY_NIGHT_ANIM_FRAME_DURATION) {
starry_night_anim_timer = timer_read32();
oled_on(); oled_on();
render_stars_anim();
starry_night_anim_sleep = timer_read32(); starry_night_anim_sleep = timer_read32();
} else if (timer_elapsed32(starry_night_anim_sleep) > OLED_TIMEOUT) { } else if (timer_elapsed32(starry_night_anim_sleep) > OLED_TIMEOUT) {
oled_off(); oled_off();