From a8d0ec0749046b0ab89c18b1b7083b1e8674de2a Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Tue, 1 Dec 2020 12:04:42 -0600 Subject: [Split] Sync Timer feature (#10997) A timer that is kept in sync between the halves of a split keyboard --- tmk_core/common/keyboard.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 8c7bdc8b55..a1fbc01da6 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -23,6 +23,7 @@ along with this program. If not, see . #include "led.h" #include "keycode.h" #include "timer.h" +#include "sync_timer.h" #include "print.h" #include "debug.h" #include "command.h" @@ -255,6 +256,7 @@ __attribute__((weak)) void housekeeping_task_user(void) {} */ void keyboard_init(void) { timer_init(); + sync_timer_init(); matrix_init(); #ifdef VIA_ENABLE via_init(); -- cgit v1.2.3 From 79d1db332477963555416d9fff82ecac4399bd52 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Tue, 12 Jan 2021 19:48:24 +1100 Subject: Keep track of last matrix activity (#10730) * Allow recording of the last matrix activity time, to simplify implementation of display timeouts and the like. * Add requested changes from code review. * Simplify split matrix last changed. --- tmk_core/common/keyboard.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index a1fbc01da6..aea09169fb 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -97,6 +97,10 @@ along with this program. If not, see . # include "dip_switch.h" #endif +static uint32_t last_matrix_modification_time = 0; +uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; } +uint32_t last_matrix_activity_elapsed(void) { return timer_elapsed32(last_matrix_modification_time); } + // Only enable this if console is enabled to print to #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) static uint32_t matrix_timer = 0; @@ -338,11 +342,8 @@ void keyboard_task(void) { housekeeping_task_kb(); housekeeping_task_user(); -#if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT) - uint8_t ret = matrix_scan(); -#else - matrix_scan(); -#endif + uint8_t matrix_changed = matrix_scan(); + if (matrix_changed) last_matrix_modification_time = timer_read32(); if (should_process_keypress()) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { @@ -409,7 +410,7 @@ MATRIX_LOOP_END: oled_task(); # ifndef OLED_DISABLE_TIMEOUT // Wake up oled if user is using those fabulous keys! - if (ret) oled_on(); + if (matrix_changed) oled_on(); # endif #endif -- cgit v1.2.3 From ab375d3d075c105f09a1ddd0e155f178225518bc Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Fri, 15 Jan 2021 06:55:07 +1100 Subject: Revert "Keep track of last matrix activity (#10730)" This reverts commit 79d1db332477963555416d9fff82ecac4399bd52. --- tmk_core/common/keyboard.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index aea09169fb..a1fbc01da6 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -97,10 +97,6 @@ along with this program. If not, see . # include "dip_switch.h" #endif -static uint32_t last_matrix_modification_time = 0; -uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; } -uint32_t last_matrix_activity_elapsed(void) { return timer_elapsed32(last_matrix_modification_time); } - // Only enable this if console is enabled to print to #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) static uint32_t matrix_timer = 0; @@ -342,8 +338,11 @@ void keyboard_task(void) { housekeeping_task_kb(); housekeeping_task_user(); - uint8_t matrix_changed = matrix_scan(); - if (matrix_changed) last_matrix_modification_time = timer_read32(); +#if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT) + uint8_t ret = matrix_scan(); +#else + matrix_scan(); +#endif if (should_process_keypress()) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { @@ -410,7 +409,7 @@ MATRIX_LOOP_END: oled_task(); # ifndef OLED_DISABLE_TIMEOUT // Wake up oled if user is using those fabulous keys! - if (matrix_changed) oled_on(); + if (ret) oled_on(); # endif #endif -- cgit v1.2.3 From e702c7f1b4cfa8fe1579498ef2877994baa64056 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Mon, 18 Jan 2021 05:01:38 +1100 Subject: Keep track of last matrix activity. (#11552) Co-authored-by: Dasky Co-authored-by: Dasky --- tmk_core/common/keyboard.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index a1fbc01da6..aea09169fb 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -97,6 +97,10 @@ along with this program. If not, see . # include "dip_switch.h" #endif +static uint32_t last_matrix_modification_time = 0; +uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; } +uint32_t last_matrix_activity_elapsed(void) { return timer_elapsed32(last_matrix_modification_time); } + // Only enable this if console is enabled to print to #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) static uint32_t matrix_timer = 0; @@ -338,11 +342,8 @@ void keyboard_task(void) { housekeeping_task_kb(); housekeeping_task_user(); -#if defined(OLED_DRIVER_ENABLE) && !defined(OLED_DISABLE_TIMEOUT) - uint8_t ret = matrix_scan(); -#else - matrix_scan(); -#endif + uint8_t matrix_changed = matrix_scan(); + if (matrix_changed) last_matrix_modification_time = timer_read32(); if (should_process_keypress()) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { @@ -409,7 +410,7 @@ MATRIX_LOOP_END: oled_task(); # ifndef OLED_DISABLE_TIMEOUT // Wake up oled if user is using those fabulous keys! - if (ret) oled_on(); + if (matrix_changed) oled_on(); # endif #endif -- cgit v1.2.3 From 1108210f1bee89c29b1bcd6105d0a7b48a53ca04 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Thu, 21 Jan 2021 22:24:07 +1100 Subject: Keep track of encoder activity (#11595) * Keep track of encoder activity, provide API for either matrix/encoder. * Fixup build when no RGBLIGHT or Backlight enabled. --- tmk_core/common/keyboard.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index aea09169fb..0ca4546128 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -97,9 +97,19 @@ along with this program. If not, see . # include "dip_switch.h" #endif +static uint32_t last_input_modification_time = 0; +uint32_t last_input_activity_time(void) { return last_input_modification_time; } +uint32_t last_input_activity_elapsed(void) { return timer_elapsed32(last_input_modification_time); } + static uint32_t last_matrix_modification_time = 0; uint32_t last_matrix_activity_time(void) { return last_matrix_modification_time; } uint32_t last_matrix_activity_elapsed(void) { return timer_elapsed32(last_matrix_modification_time); } +void last_matrix_activity_trigger(void) { last_matrix_modification_time = last_input_modification_time = timer_read32(); } + +static uint32_t last_encoder_modification_time = 0; +uint32_t last_encoder_activity_time(void) { return last_encoder_modification_time; } +uint32_t last_encoder_activity_elapsed(void) { return timer_elapsed32(last_encoder_modification_time); } +void last_encoder_activity_trigger(void) { last_encoder_modification_time = last_input_modification_time = timer_read32(); } // Only enable this if console is enabled to print to #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) @@ -338,12 +348,15 @@ void keyboard_task(void) { #ifdef QMK_KEYS_PER_SCAN uint8_t keys_processed = 0; #endif +#ifdef ENCODER_ENABLE + bool encoders_changed = false; +#endif housekeeping_task_kb(); housekeeping_task_user(); uint8_t matrix_changed = matrix_scan(); - if (matrix_changed) last_matrix_modification_time = timer_read32(); + if (matrix_changed) last_matrix_activity_trigger(); if (should_process_keypress()) { for (uint8_t r = 0; r < MATRIX_ROWS; r++) { @@ -399,7 +412,8 @@ MATRIX_LOOP_END: #endif #ifdef ENCODER_ENABLE - encoder_read(); + encoders_changed = encoder_read(); + if (encoders_changed) last_encoder_activity_trigger(); #endif #ifdef QWIIC_ENABLE @@ -409,8 +423,12 @@ MATRIX_LOOP_END: #ifdef OLED_DRIVER_ENABLE oled_task(); # ifndef OLED_DISABLE_TIMEOUT - // Wake up oled if user is using those fabulous keys! + // Wake up oled if user is using those fabulous keys or spinning those encoders! +# ifdef ENCODER_ENABLE + if (matrix_changed || encoders_changed) oled_on(); +# else if (matrix_changed) oled_on(); +# endif # endif #endif -- cgit v1.2.3 From 7161d650705afb86b0874d95d72d15cf134f4148 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Tue, 9 Feb 2021 09:49:05 -0800 Subject: Remove FAUXCLICKY feature (deprecated) (#11829) --- tmk_core/common/keyboard.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 40989ca4c6..a6bde9df85 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -60,9 +60,6 @@ along with this program. If not, see . #ifdef STENO_ENABLE # include "process_steno.h" #endif -#ifdef FAUXCLICKY_ENABLE -# include "fauxclicky.h" -#endif #ifdef SERIAL_LINK_ENABLE # include "serial_link/system/serial_link.h" #endif @@ -312,9 +309,6 @@ void keyboard_init(void) { #ifdef STENO_ENABLE steno_init(); #endif -#ifdef FAUXCLICKY_ENABLE - fauxclicky_init(); -#endif #ifdef POINTING_DEVICE_ENABLE pointing_device_init(); #endif -- cgit v1.2.3 From 1f2fe2eab99548f4bde2a79b03e3303cc9b73214 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sun, 14 Feb 2021 01:44:22 +0000 Subject: Refactor platform logic within print.h (#11863) * Remove GCC check from debug * Remove platform logic from common.mk * Refactor platform logic within print.h * restore debug.c format * headers * Rename function pointer type * review comments * Update tmk_core/common/printf.c Co-authored-by: Nick Brassel * Format Co-authored-by: Nick Brassel --- tmk_core/common/keyboard.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index a6bde9df85..299bda2c12 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -229,6 +229,7 @@ void keyboard_setup(void) { #ifndef NO_JTAG_DISABLE disable_jtag(); #endif + print_set_sendchar(sendchar); matrix_setup(); keyboard_pre_init_kb(); } -- cgit v1.2.3 From d1806a26e4ad75fa0e0405283803eba22c1a49ba Mon Sep 17 00:00:00 2001 From: XScorpion2 Date: Mon, 15 Feb 2021 18:30:33 -0600 Subject: Split transport mirror (#11046) * Split transport mirror support * Updated RGB Matrix to respond to electrical events instead of key events * split matrix slave fix --- tmk_core/common/keyboard.c | 62 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 19 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 299bda2c12..34fed0caba 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -54,6 +54,9 @@ along with this program. If not, see . #ifdef RGBLIGHT_ENABLE # include "rgblight.h" #endif +#ifdef RGB_MATRIX_ENABLE +# include "rgb_matrix.h" +#endif #ifdef ENCODER_ENABLE # include "encoder.h" #endif @@ -304,6 +307,9 @@ void keyboard_init(void) { #ifdef RGBLIGHT_ENABLE rgblight_init(); #endif +#ifdef RGB_MATRIX_ENABLE + rgb_matrix_init(); +#endif #ifdef ENCODER_ENABLE encoder_init(); #endif @@ -328,6 +334,17 @@ void keyboard_init(void) { keyboard_post_init_kb(); /* Always keep this last */ } +/** \brief key_event_task + * + * This function is responsible for calling into other systems when they need to respond to electrical switch press events. + * This is differnet than keycode events as no layer processing, or filtering occurs. + */ +void switch_events(uint8_t row, uint8_t col, bool pressed) { +#if defined(RGB_MATRIX_ENABLE) + process_rgb_matrix(row, col, pressed); +#endif +} + /** \brief Keyboard task: Do keyboard routine jobs * * Do routine keyboard jobs: @@ -358,32 +375,35 @@ void keyboard_task(void) { uint8_t matrix_changed = matrix_scan(); if (matrix_changed) last_matrix_activity_trigger(); - if (should_process_keypress()) { - for (uint8_t r = 0; r < MATRIX_ROWS; r++) { - matrix_row = matrix_get_row(r); - matrix_change = matrix_row ^ matrix_prev[r]; - if (matrix_change) { + for (uint8_t r = 0; r < MATRIX_ROWS; r++) { + matrix_row = matrix_get_row(r); + matrix_change = matrix_row ^ matrix_prev[r]; + if (matrix_change) { #ifdef MATRIX_HAS_GHOST - if (has_ghost_in_row(r, matrix_row)) { - continue; - } + if (has_ghost_in_row(r, matrix_row)) { + continue; + } #endif - if (debug_matrix) matrix_print(); - matrix_row_t col_mask = 1; - for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) { - if (matrix_change & col_mask) { + if (debug_matrix) matrix_print(); + matrix_row_t col_mask = 1; + for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) { + if (matrix_change & col_mask) { + if (should_process_keypress()) { action_exec((keyevent_t){ .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & col_mask), .time = (timer_read() | 1) /* time should not be 0 */ }); - // record a processed key - matrix_prev[r] ^= col_mask; + } + // record a processed key + matrix_prev[r] ^= col_mask; + + switch_events(r, c, (matrix_row & col_mask)); + #ifdef QMK_KEYS_PER_SCAN - // only jump out if we have processed "enough" keys. - if (++keys_processed >= QMK_KEYS_PER_SCAN) + // only jump out if we have processed "enough" keys. + if (++keys_processed >= QMK_KEYS_PER_SCAN) #endif - // process a key per task call - goto MATRIX_LOOP_END; - } + // process a key per task call + goto MATRIX_LOOP_END; } } } @@ -405,6 +425,10 @@ MATRIX_LOOP_END: rgblight_task(); #endif +#ifdef RGB_MATRIX_ENABLE + rgb_matrix_task(); +#endif + #if defined(BACKLIGHT_ENABLE) # if defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS) backlight_task(); -- cgit v1.2.3 From abe189377cd7af09041b54a7b3b19775f9ce8647 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Fri, 26 Feb 2021 17:07:05 +1100 Subject: [BUG] Massdrop develop rgb fix (#12022) * Allow for disabling RGB_MATRIX on Massdrop boards. * Fixup init sequence. * Make some functions static as they've got very generic names. --- tmk_core/common/keyboard.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'tmk_core/common/keyboard.c') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 34fed0caba..ce3255c069 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -307,9 +307,6 @@ void keyboard_init(void) { #ifdef RGBLIGHT_ENABLE rgblight_init(); #endif -#ifdef RGB_MATRIX_ENABLE - rgb_matrix_init(); -#endif #ifdef ENCODER_ENABLE encoder_init(); #endif -- cgit v1.2.3