Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow planck/rev7 to be used with ENCODER_ENABLE = no #21213

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions keyboards/planck/rev7/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,36 +67,37 @@ 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_cntx_fn(index, true);
}
encoder_pulses[i] %= ENCODER_RESOLUTION;
#ifdef ENCODER_DEFAULT_POS
encoder_pulses[i] = 0;
#endif
return changed;
}
#endif // ENCODER_ENABLE

bool matrix_scan_custom(matrix_row_t current_matrix[]) {
// reset watchdog
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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;
}