summaryrefslogtreecommitdiffstats
path: root/keyboards/sofle
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2022-09-30 22:24:43 +0200
committerGitHub <noreply@github.com>2022-09-30 16:24:43 -0400
commit8bd73d44555ecb50d0da9bb0e1e48c07b9764e35 (patch)
treee16fe6d5ad251089d0cf28435d47a35cf864bfb0 /keyboards/sofle
parentff1aa6be9ad7a35bd422b294ed3ef4aca92db95a (diff)
Fix keyboard pet OLED timeout logic (#17189)
The animation itself turns the screen on, preventing the normal timeout from ever triggering.
Diffstat (limited to 'keyboards/sofle')
-rw-r--r--keyboards/sofle/keymaps/flare576/graphics.c8
-rw-r--r--keyboards/sofle/keymaps/helltm/keymap.c29
-rw-r--r--keyboards/sofle/keymaps/noqmk/keymap.c36
3 files changed, 36 insertions, 37 deletions
diff --git a/keyboards/sofle/keymaps/flare576/graphics.c b/keyboards/sofle/keymaps/flare576/graphics.c
index 918334a508..8cade61668 100644
--- a/keyboards/sofle/keymaps/flare576/graphics.c
+++ b/keyboards/sofle/keymaps/flare576/graphics.c
@@ -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);
}
}
diff --git a/keyboards/sofle/keymaps/helltm/keymap.c b/keyboards/sofle/keymaps/helltm/keymap.c
index c0fd5edb5e..4624bc4700 100644
--- a/keyboards/sofle/keymaps/helltm/keymap.c
+++ b/keyboards/sofle/keymaps/helltm/keymap.c
@@ -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;
@@ -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 */
diff --git a/keyboards/sofle/keymaps/noqmk/keymap.c b/keyboards/sofle/keymaps/noqmk/keymap.c
index ae92a7ec7f..29afbcb842 100644
--- a/keyboards/sofle/keymaps/noqmk/keymap.c
+++ b/keyboards/sofle/keymaps/noqmk/keymap.c
@@ -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,
@@ -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;
@@ -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();
}
}