From dd6aecba7aa98480c47e5f7825dd86054537f1fa Mon Sep 17 00:00:00 2001 From: comaid Date: Sat, 27 Oct 2018 19:21:32 +0900 Subject: [PATCH] Fix up screen off timer of crkbd * Fix Up ScreenOffInterval exceeded uint16_t * Fix Up never waking up once screen off if in case of matrix are not dirty. --- keyboards/crkbd/crkbd.c | 6 ++++++ keyboards/crkbd/ssd1306.c | 16 ++++++++++++++-- keyboards/crkbd/ssd1306.h | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/keyboards/crkbd/crkbd.c b/keyboards/crkbd/crkbd.c index 5e8ba8bacf4..0fd1564404e 100644 --- a/keyboards/crkbd/crkbd.c +++ b/keyboards/crkbd/crkbd.c @@ -1 +1,7 @@ #include "crkbd.h" +#include "ssd1306.h" + +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + process_record_gfx(keycode,record); + return process_record_user(keycode, record); +} \ No newline at end of file diff --git a/keyboards/crkbd/ssd1306.c b/keyboards/crkbd/ssd1306.c index 205ce67a9e0..d8c6bf3e2c6 100644 --- a/keyboards/crkbd/ssd1306.c +++ b/keyboards/crkbd/ssd1306.c @@ -24,12 +24,17 @@ static const unsigned char font[] PROGMEM; //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) { @@ -321,12 +326,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/crkbd/ssd1306.h b/keyboards/crkbd/ssd1306.h index 76dd6a2a72d..ea8c9232805 100644 --- a/keyboards/crkbd/ssd1306.h +++ b/keyboards/crkbd/ssd1306.h @@ -3,6 +3,7 @@ #include #include #include "pincontrol.h" +#include "action.h" enum ssd1306_cmds { DisplayOff = 0xAE, @@ -86,3 +87,5 @@ void matrix_write(struct CharacterMatrix *matrix, const char *data); void matrix_write_ln(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); \ No newline at end of file