From d27080f088e21c2a2f82d7fa992ad42ab7030e04 Mon Sep 17 00:00:00 2001 From: "Peter.Falken" Date: Sun, 11 Jun 2023 09:07:41 -0600 Subject: [PATCH 1/2] fix: allow planck/rev7 to be used with ENCODER_ENABLE = no --- keyboards/planck/rev7/matrix.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/keyboards/planck/rev7/matrix.c b/keyboards/planck/rev7/matrix.c index 6b45d618611f..831e45e7ccb6 100644 --- a/keyboards/planck/rev7/matrix.c +++ b/keyboards/planck/rev7/matrix.c @@ -67,29 +67,29 @@ void matrix_init_custom(void) { wdgStart(&WDGD1, &wdgcfg); } + +#ifdef ENCODER_ENABLE bool encoder_update(uint8_t index, uint8_t state) { bool changed = false; uint8_t i = index; - encoder_pulses[i] += encoder_LUT[state & 0xF]; +// Create function alias +#ifdef ENCODER_MAP_ENABLE + #define encoder_cntx_fn encoder_exec_mapping +#else // ENCODER_MAP_ENABLE + #define encoder_cntx_fn encoder_update_kb +#endif // ENCODER_MAP_ENABLE + encoder_pulses[i] += encoder_LUT[state & 0xF]; if (encoder_pulses[i] >= ENCODER_RESOLUTION) { encoder_value[index]++; changed = true; -#ifdef ENCODER_MAP_ENABLE - encoder_exec_mapping(index, false); -#else // ENCODER_MAP_ENABLE - encoder_update_kb(index, false); -#endif // ENCODER_MAP_ENABLE + encoder_cntx_fn(index, false); } if (encoder_pulses[i] <= -ENCODER_RESOLUTION) { encoder_value[index]--; changed = true; -#ifdef ENCODER_MAP_ENABLE - encoder_exec_mapping(index, true); -#else // ENCODER_MAP_ENABLE - encoder_update_kb(index, true); -#endif // ENCODER_MAP_ENABLE + encoder_update_fn(index, true); } encoder_pulses[i] %= ENCODER_RESOLUTION; #ifdef ENCODER_DEFAULT_POS @@ -97,6 +97,7 @@ bool encoder_update(uint8_t index, uint8_t state) { #endif return changed; } +#endif // ENCODER_ENABLE bool matrix_scan_custom(matrix_row_t current_matrix[]) { // reset watchdog @@ -136,8 +137,8 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { changed |= old != current_matrix[row]; } +#ifdef ENCODER_ENABLE // ENCODER_ENABLE // encoder-matrix functionality - // set up C/rows for encoder read for (int i = 0; i < MATRIX_ROWS; i++) { setPinOutput(matrix_row_pins[i]); @@ -168,6 +169,7 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { for (int i = 0; i < MATRIX_ROWS; i++) { setPinInputLow(matrix_row_pins[i]); } +#endif // ENCODER_ENABLE return changed; } From 5a61934fd8254f616a9587fdb6d590f907e1e56d Mon Sep 17 00:00:00 2001 From: Luis Garcia Date: Sun, 11 Jun 2023 17:39:38 -0600 Subject: [PATCH 2/2] chore: update function name on all cases. --- keyboards/planck/rev7/matrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/planck/rev7/matrix.c b/keyboards/planck/rev7/matrix.c index 831e45e7ccb6..2701fc0b3fe9 100644 --- a/keyboards/planck/rev7/matrix.c +++ b/keyboards/planck/rev7/matrix.c @@ -89,7 +89,7 @@ bool encoder_update(uint8_t index, uint8_t state) { if (encoder_pulses[i] <= -ENCODER_RESOLUTION) { encoder_value[index]--; changed = true; - encoder_update_fn(index, true); + encoder_cntx_fn(index, true); } encoder_pulses[i] %= ENCODER_RESOLUTION; #ifdef ENCODER_DEFAULT_POS