diff options
Diffstat (limited to 'keyboards/planck/rev6/matrix.c')
-rw-r--r-- | keyboards/planck/rev6/matrix.c | 29 |
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]; | |||
21 | static bool debouncing = false; | 21 | static bool debouncing = false; |
22 | static uint16_t debouncing_time = 0; | 22 | static uint16_t debouncing_time = 0; |
23 | 23 | ||
24 | static uint8_t encoder_state = 0; | ||
25 | static int8_t encoder_value = 0; | ||
26 | static int8_t encoder_LUT[] = { 0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0 }; | ||
27 | |||
28 | static bool dip_switch[4] = {0, 0, 0, 0}; | 24 | static 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)) |
88 | void dip_update(uint8_t index, bool active) { } | 78 | void dip_update(uint8_t index, bool active) { } |
89 | 79 | ||
90 | __attribute__ ((weak)) | ||
91 | void encoder_update(bool clockwise) { } | ||
92 | |||
93 | bool last_dip_switch[4] = {0}; | 80 | bool last_dip_switch[4] = {0}; |
94 | 81 | ||
95 | #ifndef ENCODER_RESOLUTION | ||
96 | #define ENCODER_RESOLUTION 4 | ||
97 | #endif | ||
98 | |||
99 | uint8_t matrix_scan(void) { | 82 | uint8_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; |