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

Luna keyboard pet OLED timeout fix #17189

Merged
merged 1 commit into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions keyboards/crkbd/keymaps/bermeo/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {
# define ANIM_SIZE 96 // number of bytes in array. If you change sprites, minimize for adequate firmware size. max is 1024
/* timers */
uint32_t anim_timer = 0;
uint32_t anim_sleep = 0;
/* current frame */
uint8_t current_frame = 0;
/* status variables */
Expand Down Expand Up @@ -351,19 +350,19 @@ static void render_luna(int LUNA_X, int LUNA_Y) {
current_frame = (current_frame + 1) % 2;
/* draw */
if (isBarking) {
oled_write_raw_P(bark[abs(1 - current_frame)], ANIM_SIZE);
oled_write_raw_P(bark[current_frame], ANIM_SIZE);

} 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) {
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) {
oled_write_raw_P(walk[abs(1 - current_frame)], ANIM_SIZE);
oled_write_raw_P(walk[current_frame], ANIM_SIZE);

} else {
oled_write_raw_P(run[abs(1 - current_frame)], ANIM_SIZE);
oled_write_raw_P(run[current_frame], ANIM_SIZE);
}
}
/* animation timer */
Expand Down
29 changes: 15 additions & 14 deletions keyboards/kikoslab/ellora65/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {

/* timers */
uint32_t anim_timer = 0;
uint32_t anim_sleep = 0;

/* current frame */
uint8_t current_frame = 0;
Expand Down Expand Up @@ -160,35 +159,37 @@ static void render_luna(int LUNA_X, int LUNA_Y) {

/* current status */
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) {
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) {
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) {
oled_write_raw_P(walk[abs(1 - current_frame)], ANIM_SIZE);
oled_write_raw_P(walk[current_frame], ANIM_SIZE);

} 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 */
if (timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION) {
anim_timer = timer_read32();
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();
}
}


Expand Down
30 changes: 15 additions & 15 deletions keyboards/kikoslab/ellora65/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ oled_rotation_t oled_init_user(oled_rotation_t rotation) {

/* timers */
uint32_t anim_timer = 0;
uint32_t anim_sleep = 0;

/* current frame */
uint8_t current_frame = 0;
Expand Down Expand Up @@ -170,38 +169,39 @@ static void render_luna(int LUNA_X, int LUNA_Y) {

/* current status */
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) {
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) {
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) {
oled_write_raw_P(walk[abs(1 - current_frame)], ANIM_SIZE);
oled_write_raw_P(walk[current_frame], ANIM_SIZE);

} 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 */
if (timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION) {
anim_timer = timer_read32();
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 */

static void print_status_narrow(void) {
Expand Down
8 changes: 4 additions & 4 deletions keyboards/sofle/keymaps/flare576/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,16 @@ static void render_luna(int LUNA_X, int LUNA_Y) {
current_frame = (current_frame + 1) % 2;

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) {
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) {
oled_write_raw_P(walk[abs(1 - current_frame)], ANIM_SIZE);
oled_write_raw_P(walk[current_frame], ANIM_SIZE);

} else {
oled_write_raw_P(run[abs(1 - current_frame)], ANIM_SIZE);
oled_write_raw_P(run[current_frame], ANIM_SIZE);
}
}

Expand Down
29 changes: 15 additions & 14 deletions keyboards/sofle/keymaps/helltm/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ static uint16_t held_shift = 0;

/* timers */
uint32_t anim_timer = 0;
uint32_t anim_sleep = 0;

/* current frame */
uint8_t current_frame = 0;
Expand Down Expand Up @@ -280,35 +279,37 @@ static void render_luna(int LUNA_X, int LUNA_Y) {

/* current status */
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) {
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) {
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) {
oled_write_raw_P(walk[abs(1 - current_frame)], ANIM_SIZE);
oled_write_raw_P(walk[current_frame], ANIM_SIZE);

} 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 */
if (timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION) {
anim_timer = timer_read32();
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 */
Expand Down
36 changes: 17 additions & 19 deletions keyboards/sofle/keymaps/noqmk/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
#ifdef OLED_ENABLE

bool show_lock = true; // this is used to display the lock icon and disable keypresses when the keyboard is locked
bool animate = true; // this variable is used to fix the flickering bug

static void render_logo(void) {
static const char PROGMEM no_qmk[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
Expand Down Expand Up @@ -230,7 +229,6 @@ static const char PROGMEM mac_logo[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

/* timers */
uint32_t anim_timer = 0;
uint32_t anim_sleep = 0;

/* current frame */
uint8_t current_frame = 0;
Expand Down Expand Up @@ -322,36 +320,36 @@ static void render_luna(int LUNA_X, int LUNA_Y) {

/* current status */
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) {
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) {
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) {
oled_write_raw_P(walk[abs(1 - current_frame)], ANIM_SIZE);
oled_write_raw_P(walk[current_frame], ANIM_SIZE);

} else {
oled_write_raw_P(run[abs(1 - current_frame)], ANIM_SIZE);
oled_write_raw_P(run[current_frame], ANIM_SIZE);
}
}

/* animation timer, stops the animation logic when the oled is turned off */
if (timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION && animate == true) {
anim_timer = timer_read32();
animate_luna();
# 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

/* this fixes the screen on and off bug by disabling the animation logic when the oled is off */
if (current_wpm > 0) {
oled_on();
anim_sleep = timer_read32();
animate = true;
} else if (timer_elapsed32(anim_sleep) > OLED_TIMEOUT) {
oled_off();
animate = false;
/* animation timer */
if (timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION) {
anim_timer = timer_read32();
animate_luna();
}
}

Expand Down