diff options
| author | XScorpion2 <rcalt2vt@gmail.com> | 2021-09-19 15:18:32 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-20 06:18:32 +1000 |
| commit | 4dbeeaa0d685ee7449010d2dc2a930a5921c8a8c (patch) | |
| tree | f83fb993ad8391043b759dc2015a00944db2114c | |
| parent | 121ca7eca9a53727733645d9c4c90a206df02258 (diff) | |
| download | qmk_firmware-4dbeeaa0d685ee7449010d2dc2a930a5921c8a8c.tar.gz qmk_firmware-4dbeeaa0d685ee7449010d2dc2a930a5921c8a8c.zip | |
Doc Fixes & Custom Matrix Fix (#14526)
| -rw-r--r-- | docs/custom_quantum_functions.md | 4 | ||||
| -rw-r--r-- | keyboards/rgbkb/mun/keymaps/xulkal2/keymap.c | 24 | ||||
| -rw-r--r-- | keyboards/rgbkb/mun/keymaps/xulkal2/rules.mk | 3 | ||||
| -rw-r--r-- | keyboards/rgbkb/mun/matrix.c | 32 | ||||
| -rw-r--r-- | keyboards/rgbkb/mun/rules.mk | 4 |
5 files changed, 41 insertions, 26 deletions
diff --git a/docs/custom_quantum_functions.md b/docs/custom_quantum_functions.md index 494e76996..b0ed0f588 100644 --- a/docs/custom_quantum_functions.md +++ b/docs/custom_quantum_functions.md | |||
| @@ -148,8 +148,8 @@ This is useful for setting up stuff that you may need elsewhere, but isn't hardw | |||
| 148 | 148 | ||
| 149 | * GPIO pin initialisation: `void matrix_init_pins(void)` | 149 | * GPIO pin initialisation: `void matrix_init_pins(void)` |
| 150 | * This needs to perform the low-level initialisation of all row and column pins. By default this will initialise the input/output state of each of the GPIO pins listed in `MATRIX_ROW_PINS` and `MATRIX_COL_PINS`, based on whether or not the keyboard is set up for `ROW2COL`, `COL2ROW`, or `DIRECT_PINS`. Should the keyboard designer override this function, no initialisation of pin state will occur within QMK itself, instead deferring to the keyboard's override. | 150 | * This needs to perform the low-level initialisation of all row and column pins. By default this will initialise the input/output state of each of the GPIO pins listed in `MATRIX_ROW_PINS` and `MATRIX_COL_PINS`, based on whether or not the keyboard is set up for `ROW2COL`, `COL2ROW`, or `DIRECT_PINS`. Should the keyboard designer override this function, no initialisation of pin state will occur within QMK itself, instead deferring to the keyboard's override. |
| 151 | * `COL2ROW`-based row reads: `void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)` | 151 | * `COL2ROW`-based row reads: `void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)` |
| 152 | * `ROW2COL`-based column reads: `void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)` | 152 | * `ROW2COL`-based column reads: `void matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)` |
| 153 | * `DIRECT_PINS`-based reads: `void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)` | 153 | * `DIRECT_PINS`-based reads: `void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)` |
| 154 | * These three functions need to perform the low-level retrieval of matrix state of relevant input pins, based on the matrix type. Only one of the functions should be implemented, if needed. By default this will iterate through `MATRIX_ROW_PINS` and `MATRIX_COL_PINS`, configuring the inputs and outputs based on whether or not the keyboard is set up for `ROW2COL`, `COL2ROW`, or `DIRECT_PINS`. Should the keyboard designer override this function, no manipulation of matrix GPIO pin state will occur within QMK itself, instead deferring to the keyboard's override. | 154 | * These three functions need to perform the low-level retrieval of matrix state of relevant input pins, based on the matrix type. Only one of the functions should be implemented, if needed. By default this will iterate through `MATRIX_ROW_PINS` and `MATRIX_COL_PINS`, configuring the inputs and outputs based on whether or not the keyboard is set up for `ROW2COL`, `COL2ROW`, or `DIRECT_PINS`. Should the keyboard designer override this function, no manipulation of matrix GPIO pin state will occur within QMK itself, instead deferring to the keyboard's override. |
| 155 | 155 | ||
diff --git a/keyboards/rgbkb/mun/keymaps/xulkal2/keymap.c b/keyboards/rgbkb/mun/keymaps/xulkal2/keymap.c index 2de5888f1..cd1eec751 100644 --- a/keyboards/rgbkb/mun/keymaps/xulkal2/keymap.c +++ b/keyboards/rgbkb/mun/keymaps/xulkal2/keymap.c | |||
| @@ -159,6 +159,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 159 | } | 159 | } |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | //#define MATRIX_SCAN_DEBUG | ||
| 163 | #if !defined(MATRIX_SCAN_DEBUG) | ||
| 162 | static void render_layer(void) { | 164 | static void render_layer(void) { |
| 163 | // Host Keyboard Layer Status | 165 | // Host Keyboard Layer Status |
| 164 | oled_write_P(PSTR("Layer"), false); | 166 | oled_write_P(PSTR("Layer"), false); |
| @@ -190,8 +192,8 @@ static void render_touch(void) | |||
| 190 | oled_write_P(!touch_encoder_toggled() ? PSTR("TOUCH") : PSTR(" "), false); | 192 | oled_write_P(!touch_encoder_toggled() ? PSTR("TOUCH") : PSTR(" "), false); |
| 191 | oled_write_P(touch_encoder_calibrating() ? PSTR("CLBRT") : PSTR(" "), false); | 193 | oled_write_P(touch_encoder_calibrating() ? PSTR("CLBRT") : PSTR(" "), false); |
| 192 | } | 194 | } |
| 193 | 195 | #else | |
| 194 | /*static uint32_t scan_counter = 0; | 196 | static uint32_t scan_counter = 0; |
| 195 | static uint32_t scan_value = 0; | 197 | static uint32_t scan_value = 0; |
| 196 | static uint16_t scan_timer = 1000; | 198 | static uint16_t scan_timer = 1000; |
| 197 | 199 | ||
| @@ -218,27 +220,27 @@ void render_debug_scan(void) { | |||
| 218 | static char buffer[6] = {0}; | 220 | static char buffer[6] = {0}; |
| 219 | snprintf(buffer, sizeof(buffer), "%5d", scan_value); | 221 | snprintf(buffer, sizeof(buffer), "%5d", scan_value); |
| 220 | oled_write_ln_P(buffer, false); | 222 | oled_write_ln_P(buffer, false); |
| 221 | }*/ | 223 | } |
| 224 | #endif | ||
| 222 | 225 | ||
| 223 | void oled_task_user(void) { | 226 | void oled_task_user(void) { |
| 227 | #if !defined(MATRIX_SCAN_DEBUG) | ||
| 224 | if (is_keyboard_left()) { | 228 | if (is_keyboard_left()) { |
| 225 | render_layer(); | 229 | render_layer(); |
| 226 | oled_write_P(PSTR(" "), false); | 230 | oled_write_P(PSTR(" "), false); |
| 227 | render_leds(); | 231 | render_leds(); |
| 228 | oled_write_P(PSTR(" "), false); | 232 | oled_write_P(PSTR(" "), false); |
| 229 | render_touch(); | 233 | render_touch(); |
| 230 | //oled_write_P(PSTR(" "), false); | ||
| 231 | //render_debug_scan(); | ||
| 232 | oled_set_cursor(0, 12); | ||
| 233 | render_icon(); | ||
| 234 | } | 234 | } |
| 235 | else { | 235 | else { |
| 236 | render_rgb_menu(); | 236 | render_rgb_menu(); |
| 237 | //oled_write_P(PSTR(" "), false); | ||
| 238 | //render_debug_scan(); | ||
| 239 | oled_set_cursor(0, 12); | ||
| 240 | render_icon(); | ||
| 241 | } | 237 | } |
| 238 | #else | ||
| 239 | oled_write_P(PSTR(" "), false); | ||
| 240 | render_debug_scan(); | ||
| 241 | #endif | ||
| 242 | oled_set_cursor(0, 12); | ||
| 243 | render_icon(); | ||
| 242 | } | 244 | } |
| 243 | 245 | ||
| 244 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { | 246 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { |
diff --git a/keyboards/rgbkb/mun/keymaps/xulkal2/rules.mk b/keyboards/rgbkb/mun/keymaps/xulkal2/rules.mk index e35ec125e..a087f669d 100644 --- a/keyboards/rgbkb/mun/keymaps/xulkal2/rules.mk +++ b/keyboards/rgbkb/mun/keymaps/xulkal2/rules.mk | |||
| @@ -1,4 +1,3 @@ | |||
| 1 | MOUSEKEY_ENABLE = yes # using for mouse wheel up and down, more granular than page up/down | 1 | MOUSEKEY_ENABLE = yes # using for mouse wheel up and down, more granular than page up/down |
| 2 | 2 | ||
| 3 | OPT_DEFS += -DRGB_UNLIMITED_POWER | 3 | OPT_DEFS += -DRGB_UNLIMITED_POWER \ No newline at end of file |
| 4 | #DEBOUNCE_TYPE = sym_eager_pk \ No newline at end of file | ||
diff --git a/keyboards/rgbkb/mun/matrix.c b/keyboards/rgbkb/mun/matrix.c index b859847f1..2472d217c 100644 --- a/keyboards/rgbkb/mun/matrix.c +++ b/keyboards/rgbkb/mun/matrix.c | |||
| @@ -11,7 +11,19 @@ | |||
| 11 | #include "atomic_util.h" | 11 | #include "atomic_util.h" |
| 12 | #include "gpio.h" | 12 | #include "gpio.h" |
| 13 | 13 | ||
| 14 | static pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | 14 | #define ROWS_PER_HAND (MATRIX_ROWS / 2) |
| 15 | static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; | ||
| 16 | static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | ||
| 17 | |||
| 18 | void matrix_init_pins(void) { | ||
| 19 | for (size_t i = 0; i < MATRIX_COLS; i++) { | ||
| 20 | setPinInputHigh(col_pins[i]); | ||
| 21 | } | ||
| 22 | for (size_t i = 0; i < ROWS_PER_HAND; i++) { | ||
| 23 | setPinOutput(row_pins[i]); | ||
| 24 | writePinHigh(row_pins[i]); | ||
| 25 | } | ||
| 26 | } | ||
| 15 | 27 | ||
| 16 | void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { | 28 | void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { |
| 17 | /* Drive row pin low. */ | 29 | /* Drive row pin low. */ |
| @@ -22,15 +34,17 @@ void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | |||
| 22 | uint16_t porta = palReadPort(GPIOA); | 34 | uint16_t porta = palReadPort(GPIOA); |
| 23 | uint16_t portb = palReadPort(GPIOB); | 35 | uint16_t portb = palReadPort(GPIOB); |
| 24 | 36 | ||
| 37 | // clang-format off | ||
| 25 | /* Order of pins on the mun is: A0, B11, B0, B10, B12, B2, A8 | 38 | /* Order of pins on the mun is: A0, B11, B0, B10, B12, B2, A8 |
| 26 | Pin is active low, therefore we have to invert the result. */ | 39 | Pin is active low, therefore we have to invert the result. */ |
| 27 | matrix_row_t cols = ~(((porta & (0x1 << 0)) >> 0) // A0 (0) | 40 | matrix_row_t cols = ~(((porta & (0x1 << 0)) >> 0) // A0 (0) |
| 28 | | ((portb & (0x1 << 11)) >> 10) // B11 (1) | 41 | | ((portb & (0x1 << 11)) >> 10) // B11 (1) |
| 29 | | ((portb & (0x1 << 0)) << 2) // B0 (2) | 42 | | ((portb & (0x1 << 0)) << 2) // B0 (2) |
| 30 | | ((portb & (0x1 << 10)) >> 7) // B10 (3) | 43 | | ((portb & (0x1 << 10)) >> 7) // B10 (3) |
| 31 | | ((portb & (0x1 << 12)) >> 8) // B12 (4) | 44 | | ((portb & (0x1 << 12)) >> 8) // B12 (4) |
| 32 | | ((portb & (0x1 << 2)) << 3) // B2 (5) | 45 | | ((portb & (0x1 << 2)) << 3) // B2 (5) |
| 33 | | ((porta & (0x1 << 8)) >> 2)); // A8 (6) | 46 | | ((porta & (0x1 << 8)) >> 2)); // A8 (6) |
| 47 | // clang-format on | ||
| 34 | 48 | ||
| 35 | /* Reverse the order of columns for left hand as the board is flipped. */ | 49 | /* Reverse the order of columns for left hand as the board is flipped. */ |
| 36 | // if (isLeftHand) { | 50 | // if (isLeftHand) { |
| @@ -50,7 +64,7 @@ void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | |||
| 50 | 64 | ||
| 51 | /* Drive row pin high again. */ | 65 | /* Drive row pin high again. */ |
| 52 | ATOMIC_BLOCK_FORCEON { writePinHigh(row_pins[current_row]); } | 66 | ATOMIC_BLOCK_FORCEON { writePinHigh(row_pins[current_row]); } |
| 53 | matrix_output_unselect_delay(current_row, row_pins[current_row] != 0); | 67 | matrix_output_unselect_delay(current_row, cols != 0); |
| 54 | } | 68 | } |
| 55 | 69 | ||
| 56 | #if defined(BUSY_WAIT) | 70 | #if defined(BUSY_WAIT) |
diff --git a/keyboards/rgbkb/mun/rules.mk b/keyboards/rgbkb/mun/rules.mk index 145d9d4aa..e81196f9e 100644 --- a/keyboards/rgbkb/mun/rules.mk +++ b/keyboards/rgbkb/mun/rules.mk | |||
| @@ -39,7 +39,7 @@ OPT = 3 | |||
| 39 | OPT_DEFS += -DOLED_FONT_H=\"../common/glcdfont.c\" | 39 | OPT_DEFS += -DOLED_FONT_H=\"../common/glcdfont.c\" |
| 40 | OPT_DEFS += -Ikeyboards/rgbkb/common | 40 | OPT_DEFS += -Ikeyboards/rgbkb/common |
| 41 | 41 | ||
| 42 | # matrix optimisations (broken, will fix later) | 42 | # matrix optimisations |
| 43 | #SRC += matrix.c | 43 | SRC += matrix.c |
| 44 | 44 | ||
| 45 | DEFAULT_FOLDER = rgbkb/mun/rev1 | 45 | DEFAULT_FOLDER = rgbkb/mun/rev1 |
