aboutsummaryrefslogtreecommitdiff
path: root/keyboards/planck/rev6/matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/planck/rev6/matrix.c')
-rw-r--r--keyboards/planck/rev6/matrix.c29
1 files changed, 0 insertions, 29 deletions
diff --git a/keyboards/planck/rev6/matrix.c b/keyboards/planck/rev6/matrix.c
index e4ebe48ac..2df588cef 100644
--- a/keyboards/planck/rev6/matrix.c
+++ b/keyboards/planck/rev6/matrix.c
@@ -21,10 +21,6 @@ static matrix_row_t matrix_debouncing[MATRIX_COLS];
21static bool debouncing = false; 21static bool debouncing = false;
22static uint16_t debouncing_time = 0; 22static uint16_t debouncing_time = 0;
23 23
24static uint8_t encoder_state = 0;
25static int8_t encoder_value = 0;
26static int8_t encoder_LUT[] = { 0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0 };
27
28static bool dip_switch[4] = {0, 0, 0, 0}; 24static bool dip_switch[4] = {0, 0, 0, 0};
29 25
30__attribute__ ((weak)) 26__attribute__ ((weak))
@@ -53,12 +49,6 @@ void matrix_init(void) {
53 palSetPadMode(GPIOA, 10, PAL_MODE_INPUT_PULLUP); 49 palSetPadMode(GPIOA, 10, PAL_MODE_INPUT_PULLUP);
54 palSetPadMode(GPIOB, 9, PAL_MODE_INPUT_PULLUP); 50 palSetPadMode(GPIOB, 9, PAL_MODE_INPUT_PULLUP);
55 51
56 // encoder setup
57 palSetPadMode(GPIOB, 12, PAL_MODE_INPUT_PULLUP);
58 palSetPadMode(GPIOB, 13, PAL_MODE_INPUT_PULLUP);
59
60 encoder_state = (palReadPad(GPIOB, 12) << 0) | (palReadPad(GPIOB, 13) << 1);
61
62 // actual matrix setup 52 // actual matrix setup
63 palSetPadMode(GPIOB, 11, PAL_MODE_OUTPUT_PUSHPULL); 53 palSetPadMode(GPIOB, 11, PAL_MODE_OUTPUT_PUSHPULL);
64 palSetPadMode(GPIOB, 10, PAL_MODE_OUTPUT_PUSHPULL); 54 palSetPadMode(GPIOB, 10, PAL_MODE_OUTPUT_PUSHPULL);
@@ -87,15 +77,8 @@ void matrix_init(void) {
87__attribute__ ((weak)) 77__attribute__ ((weak))
88void dip_update(uint8_t index, bool active) { } 78void dip_update(uint8_t index, bool active) { }
89 79
90__attribute__ ((weak))
91void encoder_update(bool clockwise) { }
92
93bool last_dip_switch[4] = {0}; 80bool last_dip_switch[4] = {0};
94 81
95#ifndef ENCODER_RESOLUTION
96 #define ENCODER_RESOLUTION 4
97#endif
98
99uint8_t matrix_scan(void) { 82uint8_t matrix_scan(void) {
100 // dip switch 83 // dip switch
101 dip_switch[0] = !palReadPad(GPIOB, 14); 84 dip_switch[0] = !palReadPad(GPIOB, 14);
@@ -108,18 +91,6 @@ uint8_t matrix_scan(void) {
108 } 91 }
109 memcpy(last_dip_switch, dip_switch, sizeof(&dip_switch)); 92 memcpy(last_dip_switch, dip_switch, sizeof(&dip_switch));
110 93
111 // encoder on B12 and B13
112 encoder_state <<= 2;
113 encoder_state |= (palReadPad(GPIOB, 12) << 0) | (palReadPad(GPIOB, 13) << 1);
114 encoder_value += encoder_LUT[encoder_state & 0xF];
115 if (encoder_value >= ENCODER_RESOLUTION) {
116 encoder_update(0);
117 }
118 if (encoder_value <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise
119 encoder_update(1);
120 }
121 encoder_value %= ENCODER_RESOLUTION;
122
123 // actual matrix 94 // actual matrix
124 for (int col = 0; col < MATRIX_COLS; col++) { 95 for (int col = 0; col < MATRIX_COLS; col++) {
125 matrix_row_t data = 0; 96 matrix_row_t data = 0;