From 2b7decbaeb020c5320ada182552e633deec77ff7 Mon Sep 17 00:00:00 2001 From: comaid <44457151+comaid@users.noreply.github.com> Date: Tue, 13 Nov 2018 05:20:50 +0900 Subject: [PATCH] Fix up screen off timer of helix (#4347) * Fix up screen off timer of helix * Fix Up ScreenOffInterval exceeded uint16_t * Fix Up never waking up once screen off if in case of matrix are not dirty * Changing referenIng incorrect constant name * OLED_ENABLED => SSD1306OLED * Improve internal processing of process_record_kb() * Use the return value of process_record_gfx() * Move a include statement into #ifdef block Move #include "ssd1306.h` statement into #ifdef block * Move process_record_kbI() Move process_record_kb() from helix.c to rev1.c/rev2.c/pico.c * Move process_record_kb() --- keyboards/helix/pico/pico.c | 6 ++++++ keyboards/helix/rev1/rev1.c | 6 ++++++ keyboards/helix/rev2/rev2.c | 6 ++++++ keyboards/helix/ssd1306.c | 17 +++++++++++++++-- keyboards/helix/ssd1306.h | 3 ++- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/keyboards/helix/pico/pico.c b/keyboards/helix/pico/pico.c index 5e248ccffe..bb8ba9ca2b 100644 --- a/keyboards/helix/pico/pico.c +++ b/keyboards/helix/pico/pico.c @@ -2,6 +2,12 @@ #ifdef SSD1306OLED +#include "ssd1306.h" + +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + return process_record_gfx(keycode,record) && process_record_user(keycode, record); +} + void led_set_kb(uint8_t usb_led) { // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here //led_set_user(usb_led); diff --git a/keyboards/helix/rev1/rev1.c b/keyboards/helix/rev1/rev1.c index d7ea9b7235..309cca010f 100644 --- a/keyboards/helix/rev1/rev1.c +++ b/keyboards/helix/rev1/rev1.c @@ -2,6 +2,12 @@ #ifdef SSD1306OLED +#include "ssd1306.h" + +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + return process_record_gfx(keycode,record) && process_record_user(keycode, record); +} + void led_set_kb(uint8_t usb_led) { // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here led_set_user(usb_led); diff --git a/keyboards/helix/rev2/rev2.c b/keyboards/helix/rev2/rev2.c index 75765f1d35..abaa02cdb1 100644 --- a/keyboards/helix/rev2/rev2.c +++ b/keyboards/helix/rev2/rev2.c @@ -2,6 +2,12 @@ #ifdef SSD1306OLED +#include "ssd1306.h" + +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + return process_record_gfx(keycode,record) && process_record_user(keycode, record); +} + void led_set_kb(uint8_t usb_led) { // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here //led_set_user(usb_led); diff --git a/keyboards/helix/ssd1306.c b/keyboards/helix/ssd1306.c index b3e55a67c2..dd3290ba0c 100644 --- a/keyboards/helix/ssd1306.c +++ b/keyboards/helix/ssd1306.c @@ -1,3 +1,4 @@ + #ifdef SSD1306OLED #include "ssd1306.h" @@ -27,12 +28,17 @@ //static uint16_t last_battery_update; //static uint32_t vbat; //#define BatteryUpdateInterval 10000 /* milliseconds */ -#define ScreenOffInterval 300000 /* milliseconds */ + +// 'last_flush' is declared as uint16_t, +// so this must be less than 65535 +#define ScreenOffInterval 60000 /* milliseconds */ #if DEBUG_TO_SCREEN static uint8_t displaying; #endif static uint16_t last_flush; +static bool force_dirty = true; + // Write command sequence. // Returns true on success. static inline bool _send_cmd1(uint8_t cmd) { @@ -318,12 +324,19 @@ void iota_gfx_task_user(void) { void iota_gfx_task(void) { iota_gfx_task_user(); - if (display.dirty) { + if (display.dirty|| force_dirty) { iota_gfx_flush(); + force_dirty = false; } if (timer_elapsed(last_flush) > ScreenOffInterval) { iota_gfx_off(); } } + +bool process_record_gfx(uint16_t keycode, keyrecord_t *record) { + force_dirty = true; + return true; +} + #endif diff --git a/keyboards/helix/ssd1306.h b/keyboards/helix/ssd1306.h index 77ce7c211a..9cf6983b7e 100644 --- a/keyboards/helix/ssd1306.h +++ b/keyboards/helix/ssd1306.h @@ -4,6 +4,7 @@ #include #include #include "pincontrol.h" +#include "action.h" enum ssd1306_cmds { DisplayOff = 0xAE, @@ -87,6 +88,6 @@ void matrix_write(struct CharacterMatrix *matrix, const char *data); void matrix_write_P(struct CharacterMatrix *matrix, const char *data); void matrix_render(struct CharacterMatrix *matrix); - +bool process_record_gfx(uint16_t keycode, keyrecord_t *record); #endif