From 3d175f2340c14250a71af78afec5a1e890d9f4e7 Mon Sep 17 00:00:00 2001 From: comaid Date: Sat, 27 Oct 2018 17:22:54 +0900 Subject: [PATCH 1/7] fix about screen off timer * Fix Up ScreenOffInterval exceeded uint16_t * Fix Up never waking up once screen off if in case of matrix are not dirty. --- keyboards/crkbd/.vscode/c_cpp_properties.json | 21 +++++++++++++++++++ keyboards/crkbd/crkbd.c | 6 ++++++ keyboards/crkbd/ssd1306.c | 16 ++++++++++++-- keyboards/crkbd/ssd1306.h | 3 +++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 keyboards/crkbd/.vscode/c_cpp_properties.json diff --git a/keyboards/crkbd/.vscode/c_cpp_properties.json b/keyboards/crkbd/.vscode/c_cpp_properties.json new file mode 100644 index 000000000000..46dce25eae22 --- /dev/null +++ b/keyboards/crkbd/.vscode/c_cpp_properties.json @@ -0,0 +1,21 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "windowsSdkVersion": "10.0.16299.0", + "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/bin/Hostx64/x64/cl.exe", + "cStandard": "c11", + "cppStandard": "c++17", + "intelliSenseMode": "msvc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/keyboards/crkbd/crkbd.c b/keyboards/crkbd/crkbd.c index 5e8ba8bacf48..0fd1564404eb 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 205ce67a9e00..33ffb7e29177 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 76dd6a2a72d3..71daf06ff489 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); From 8ca457fc254f5b2d52bb8aa5075401d331fb72ea Mon Sep 17 00:00:00 2001 From: comaid Date: Sat, 27 Oct 2018 19:09:19 +0900 Subject: [PATCH 2/7] Revert "fix about screen off timer" This reverts commit 3d175f2340c14250a71af78afec5a1e890d9f4e7. --- keyboards/crkbd/.vscode/c_cpp_properties.json | 21 ------------------- keyboards/crkbd/crkbd.c | 6 ------ keyboards/crkbd/ssd1306.c | 16 ++------------ keyboards/crkbd/ssd1306.h | 3 --- 4 files changed, 2 insertions(+), 44 deletions(-) delete mode 100644 keyboards/crkbd/.vscode/c_cpp_properties.json diff --git a/keyboards/crkbd/.vscode/c_cpp_properties.json b/keyboards/crkbd/.vscode/c_cpp_properties.json deleted file mode 100644 index 46dce25eae22..000000000000 --- a/keyboards/crkbd/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "configurations": [ - { - "name": "Win32", - "includePath": [ - "${workspaceFolder}/**" - ], - "defines": [ - "_DEBUG", - "UNICODE", - "_UNICODE" - ], - "windowsSdkVersion": "10.0.16299.0", - "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.13.26128/bin/Hostx64/x64/cl.exe", - "cStandard": "c11", - "cppStandard": "c++17", - "intelliSenseMode": "msvc-x64" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/keyboards/crkbd/crkbd.c b/keyboards/crkbd/crkbd.c index 0fd1564404eb..5e8ba8bacf48 100644 --- a/keyboards/crkbd/crkbd.c +++ b/keyboards/crkbd/crkbd.c @@ -1,7 +1 @@ #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 33ffb7e29177..205ce67a9e00 100644 --- a/keyboards/crkbd/ssd1306.c +++ b/keyboards/crkbd/ssd1306.c @@ -24,17 +24,12 @@ static const unsigned char font[] PROGMEM; //static uint16_t last_battery_update; //static uint32_t vbat; //#define BatteryUpdateInterval 10000 /* milliseconds */ - -// 'last_flush' is declared as uint16_t, -// so this must be less than 65535 -#define ScreenOffInterval 60000 /* milliseconds */ +#define ScreenOffInterval 300000 /* 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) { @@ -326,19 +321,12 @@ void iota_gfx_task_user(void) { void iota_gfx_task(void) { iota_gfx_task_user(); - if (display.dirty || force_dirty) { + if (display.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 71daf06ff489..76dd6a2a72d3 100644 --- a/keyboards/crkbd/ssd1306.h +++ b/keyboards/crkbd/ssd1306.h @@ -3,7 +3,6 @@ #include #include #include "pincontrol.h" -#include "action.h" enum ssd1306_cmds { DisplayOff = 0xAE, @@ -87,5 +86,3 @@ 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); From dd6aecba7aa98480c47e5f7825dd86054537f1fa Mon Sep 17 00:00:00 2001 From: comaid Date: Sat, 27 Oct 2018 19:21:32 +0900 Subject: [PATCH 3/7] 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 5e8ba8bacf48..0fd1564404eb 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 205ce67a9e00..d8c6bf3e2c6d 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 76dd6a2a72d3..ea8c9232805d 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 From f0efb82443a7dc34b75579359b0514e8bfa51100 Mon Sep 17 00:00:00 2001 From: comaid Date: Sun, 4 Nov 2018 20:08:43 +0900 Subject: [PATCH 4/7] 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 --- keyboards/helix/helix.c | 8 ++++++++ keyboards/helix/ssd1306.c | 17 +++++++++++++++-- keyboards/helix/ssd1306.h | 3 ++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/keyboards/helix/helix.c b/keyboards/helix/helix.c index 539abd534952..9c27702a7947 100644 --- a/keyboards/helix/helix.c +++ b/keyboards/helix/helix.c @@ -1 +1,9 @@ #include "helix.h" +#include "ssd1306.h" + +#ifdef OLED_ENABLED +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { + process_record_gfx(keycode,record); + return process_record_user(keycode, record); +} +#endif \ No newline at end of file diff --git a/keyboards/helix/ssd1306.c b/keyboards/helix/ssd1306.c index b3e55a67c201..dd3290ba0cc8 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 77ce7c211a04..9cf6983b7e43 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 From 877040de921c9051df5e85ae7316dd8c252e7958 Mon Sep 17 00:00:00 2001 From: comaid Date: Sun, 4 Nov 2018 20:15:03 +0900 Subject: [PATCH 5/7] Revert "Fix up screen off timer of helix" This reverts commit f0efb82443a7dc34b75579359b0514e8bfa51100. --- keyboards/helix/helix.c | 8 -------- keyboards/helix/ssd1306.c | 17 ++--------------- keyboards/helix/ssd1306.h | 3 +-- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/keyboards/helix/helix.c b/keyboards/helix/helix.c index 9c27702a7947..539abd534952 100644 --- a/keyboards/helix/helix.c +++ b/keyboards/helix/helix.c @@ -1,9 +1 @@ #include "helix.h" -#include "ssd1306.h" - -#ifdef OLED_ENABLED -bool process_record_kb(uint16_t keycode, keyrecord_t *record) { - process_record_gfx(keycode,record); - return process_record_user(keycode, record); -} -#endif \ No newline at end of file diff --git a/keyboards/helix/ssd1306.c b/keyboards/helix/ssd1306.c index dd3290ba0cc8..b3e55a67c201 100644 --- a/keyboards/helix/ssd1306.c +++ b/keyboards/helix/ssd1306.c @@ -1,4 +1,3 @@ - #ifdef SSD1306OLED #include "ssd1306.h" @@ -28,17 +27,12 @@ //static uint16_t last_battery_update; //static uint32_t vbat; //#define BatteryUpdateInterval 10000 /* milliseconds */ - -// 'last_flush' is declared as uint16_t, -// so this must be less than 65535 -#define ScreenOffInterval 60000 /* milliseconds */ +#define ScreenOffInterval 300000 /* 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) { @@ -324,19 +318,12 @@ void iota_gfx_task_user(void) { void iota_gfx_task(void) { iota_gfx_task_user(); - if (display.dirty|| force_dirty) { + if (display.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 9cf6983b7e43..77ce7c211a04 100644 --- a/keyboards/helix/ssd1306.h +++ b/keyboards/helix/ssd1306.h @@ -4,7 +4,6 @@ #include #include #include "pincontrol.h" -#include "action.h" enum ssd1306_cmds { DisplayOff = 0xAE, @@ -88,6 +87,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 From e47b5ed27f3cc68883e76dc544f1448e5761e96e Mon Sep 17 00:00:00 2001 From: comaid Date: Mon, 5 Nov 2018 08:16:20 +0900 Subject: [PATCH 6/7] Improve internal processing of process_record_kb() * Use the return value of process_record_gfx() --- keyboards/crkbd/crkbd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/keyboards/crkbd/crkbd.c b/keyboards/crkbd/crkbd.c index 0fd1564404eb..32f7af776ee0 100644 --- a/keyboards/crkbd/crkbd.c +++ b/keyboards/crkbd/crkbd.c @@ -2,6 +2,5 @@ #include "ssd1306.h" bool process_record_kb(uint16_t keycode, keyrecord_t *record) { - process_record_gfx(keycode,record); - return process_record_user(keycode, record); + return process_record_gfx(keycode,record) && process_record_user(keycode, record); } \ No newline at end of file From 5c2ed34568785c7b68b344fb45305cc62d846c22 Mon Sep 17 00:00:00 2001 From: comaid Date: Mon, 5 Nov 2018 09:42:14 +0900 Subject: [PATCH 7/7] Fix a indent Fix a indent --- keyboards/crkbd/ssd1306.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/crkbd/ssd1306.c b/keyboards/crkbd/ssd1306.c index d8c6bf3e2c6d..4330c8497db2 100644 --- a/keyboards/crkbd/ssd1306.c +++ b/keyboards/crkbd/ssd1306.c @@ -328,7 +328,7 @@ void iota_gfx_task(void) { if (display.dirty|| force_dirty) { iota_gfx_flush(); - force_dirty = false; + force_dirty = false; } if (timer_elapsed(last_flush) > ScreenOffInterval) {