mirror of
https://github.com/qmk/qmk_userspace.git
synced 2025-05-07 16:14:17 -04:00
Fix keyboard pet OLED timeout logic (#17189)
The animation itself turns the screen on, preventing the normal timeout from ever triggering.
This commit is contained in:
parent
095692003a
commit
7936e7a139
1 changed files with 15 additions and 15 deletions
|
@ -78,7 +78,6 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {
|
||||||
|
|
||||||
/* timers */
|
/* timers */
|
||||||
uint32_t anim_timer = 0;
|
uint32_t anim_timer = 0;
|
||||||
uint32_t anim_sleep = 0;
|
|
||||||
|
|
||||||
/* current frame */
|
/* current frame */
|
||||||
uint8_t current_frame = 0;
|
uint8_t current_frame = 0;
|
||||||
|
@ -170,37 +169,38 @@ static void render_luna(int LUNA_X, int LUNA_Y) {
|
||||||
|
|
||||||
/* current status */
|
/* current status */
|
||||||
if (led_usb_state.caps_lock) {
|
if (led_usb_state.caps_lock) {
|
||||||
oled_write_raw_P(bark[abs(1 - current_frame)], ANIM_SIZE);
|
oled_write_raw_P(bark[current_frame], ANIM_SIZE);
|
||||||
|
|
||||||
} else if (isSneaking) {
|
} else if (isSneaking) {
|
||||||
oled_write_raw_P(sneak[abs(1 - current_frame)], ANIM_SIZE);
|
oled_write_raw_P(sneak[current_frame], ANIM_SIZE);
|
||||||
|
|
||||||
} else if (current_wpm <= MIN_WALK_SPEED) {
|
} else if (current_wpm <= MIN_WALK_SPEED) {
|
||||||
oled_write_raw_P(sit[abs(1 - current_frame)], ANIM_SIZE);
|
oled_write_raw_P(sit[current_frame], ANIM_SIZE);
|
||||||
|
|
||||||
} else if (current_wpm <= MIN_RUN_SPEED) {
|
} else if (current_wpm <= MIN_RUN_SPEED) {
|
||||||
oled_write_raw_P(walk[abs(1 - current_frame)], ANIM_SIZE);
|
oled_write_raw_P(walk[current_frame], ANIM_SIZE);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
oled_write_raw_P(run[abs(1 - current_frame)], ANIM_SIZE);
|
oled_write_raw_P(run[current_frame], ANIM_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# if OLED_TIMEOUT > 0
|
||||||
|
/* the animation prevents the normal timeout from occuring */
|
||||||
|
if (last_input_activity_elapsed() > OLED_TIMEOUT && last_led_activity_elapsed() > OLED_TIMEOUT) {
|
||||||
|
oled_off();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
oled_on();
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
/* animation timer */
|
/* animation timer */
|
||||||
if (timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION) {
|
if (timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION) {
|
||||||
anim_timer = timer_read32();
|
anim_timer = timer_read32();
|
||||||
animate_luna();
|
animate_luna();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this fixes the screen on and off bug */
|
|
||||||
if (current_wpm > 0) {
|
|
||||||
oled_on();
|
|
||||||
anim_sleep = timer_read32();
|
|
||||||
} else if (timer_elapsed32(anim_sleep) > OLED_TIMEOUT) {
|
|
||||||
oled_off();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* KEYBOARD PET END */
|
/* KEYBOARD PET END */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue