From c48f372c8756fda10b5045c620da7a4c1f16584f Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Wed, 6 Mar 2024 17:02:52 +0000 Subject: [PATCH] Migrate annepro2 away from custom matrix (#23221) * Migrate annepro2 away from custom matrix * LTO --- keyboards/annepro2/c15/config.h | 15 -------- keyboards/annepro2/c15/info.json | 5 +++ keyboards/annepro2/c15/rules.mk | 4 -- keyboards/annepro2/c18/config.h | 13 ------- keyboards/annepro2/c18/info.json | 5 +++ keyboards/annepro2/c18/rules.mk | 4 -- keyboards/annepro2/info.json | 3 ++ keyboards/annepro2/matrix.c | 63 -------------------------------- 8 files changed, 13 insertions(+), 99 deletions(-) delete mode 100644 keyboards/annepro2/matrix.c diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index 9ffce91957..9745cf50cc 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -19,27 +19,12 @@ #include "pin_defs.h" -// key matrix size -#define MATRIX_ROWS 5 -#define MATRIX_COLS 14 -// layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 140 bytes - #define LINE_UART_TX B0 // Master TX, LED RX #define LINE_UART_RX B1 // Master RX, LED TX #define LINE_BT_UART_TX A4 // Master TX, BLE RX #define LINE_BT_UART_RX A5 // Master RX, BLE TX -// outputs (rows are pulled low) -#define MATRIX_ROW_PINS \ - { C2, C1, B5, B4, C3 } - -// inputs (columns are sampled) -// PORTA 12,13 conflict with SWD - -#define MATRIX_COL_PINS \ - { C4, C5, B10, B11, C0, A15, A8, A10, A11, A12, A13, A14, B2, B3 } - // Obins stock firmware has something similar to this already enabled, but disabled by default in QMK #define PERMISSIVE_HOLD diff --git a/keyboards/annepro2/c15/info.json b/keyboards/annepro2/c15/info.json index b92b446e4e..091d0b1c5b 100644 --- a/keyboards/annepro2/c15/info.json +++ b/keyboards/annepro2/c15/info.json @@ -10,6 +10,11 @@ "backing_size": 2048 } }, + "diode_direction": "COL2ROW", + "matrix_pins": { + "cols": ["C4", "C5", "B10", "B11", "C0", "A15", "A8", "A10", "A11", "A12", "A13", "A14", "B2", "B3"], + "rows": ["C2", "C1", "B5", "B4", "C3"] + }, "rgb_matrix": { "animations":{ "alphas_mods": true, diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index 374d844338..c3bf551e4b 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -26,12 +26,8 @@ NKRO_ENABLE = no # Enable N-Key Rollover # Custom RGB matrix handling RGB_MATRIX_ENABLE = yes -# Keys -CUSTOM_MATRIX = lite - # Anne Pro 2 SRC = \ - matrix.c \ annepro2_ble.c \ ap2_led.c \ protocol.c \ diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index 7010f19a3f..dfc550160c 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -19,25 +19,12 @@ #include "pin_defs.h" -// key matrix size -#define MATRIX_ROWS 5 -#define MATRIX_COLS 14 -// layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 140 bytes - #define LINE_UART_TX B0 #define LINE_UART_RX B1 #define LINE_BT_UART_TX A4 // Master TX, BLE RX #define LINE_BT_UART_RX A5 // Master RX, BLE TX -// outputs (rows are pulled low) -#define MATRIX_ROW_PINS \ - { B5, B4, B3, B2, D1 } - -// inputs (columns are sampled) -#define MATRIX_COL_PINS \ - { C4, C5, D0, B15, C11, A15, C12, C13, A8, A10, A11, A14, D2, D3 } - // Obins stock firmware has something similar to this already enabled, but disabled by default in QMK #define PERMISSIVE_HOLD diff --git a/keyboards/annepro2/c18/info.json b/keyboards/annepro2/c18/info.json index 390dd81941..8c765338a5 100644 --- a/keyboards/annepro2/c18/info.json +++ b/keyboards/annepro2/c18/info.json @@ -10,6 +10,11 @@ "backing_size": 2048 } }, + "diode_direction": "COL2ROW", + "matrix_pins": { + "cols": ["C4", "C5", "D0", "B15", "C11", "A15", "C12", "C13", "A8", "A10", "A11", "A14", "D2", "D3"], + "rows": ["B5", "B4", "B3", "B2", "D1"] + }, "rgb_matrix": { "animations":{ "alphas_mods": true, diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 2c9a9077da..484099b3ae 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -26,12 +26,8 @@ NKRO_ENABLE = no # Enable N-Key Rollover # Custom RGB matrix handling RGB_MATRIX_ENABLE = yes -# Keys -CUSTOM_MATRIX = lite - # Anne Pro 2 SRC = \ - matrix.c \ annepro2_ble.c \ ap2_led.c \ protocol.c \ diff --git a/keyboards/annepro2/info.json b/keyboards/annepro2/info.json index d06fe5bed4..f90edcfa83 100644 --- a/keyboards/annepro2/info.json +++ b/keyboards/annepro2/info.json @@ -6,6 +6,9 @@ "vid": "0xAC20", "device_version": "13.3.7" }, + "build": { + "lto": true + }, "layouts": { "LAYOUT_60_ansi": { "layout": [ diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c deleted file mode 100644 index a1585e4ddf..0000000000 --- a/keyboards/annepro2/matrix.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2018 Charlie Waters - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include "timer.h" -#include "wait.h" -#include "print.h" -#include "matrix.h" -#include "annepro2.h" - -pin_t row_list[MATRIX_ROWS] = MATRIX_ROW_PINS; -pin_t col_list[MATRIX_COLS] = MATRIX_COL_PINS; - -bool matrix_scan_custom(matrix_row_t current_matrix[]) { - bool matrix_has_changed = false; - // cache of input ports for columns - static uint16_t port_cache[4]; - // scan each row - for (int row = 0; row < MATRIX_ROWS; row++) { - palClearLine(row_list[row]); - __NOP(); - __NOP(); - __NOP(); - __NOP(); - // read i/o ports - port_cache[0] = palReadPort(IOPORTA); - port_cache[1] = palReadPort(IOPORTB); - port_cache[2] = palReadPort(IOPORTC); - port_cache[3] = palReadPort(IOPORTD); - palSetLine(row_list[row]); - - // get columns from ports - matrix_row_t data = 0; - for (int col = 0; col < MATRIX_COLS; ++col) { - pin_t line = col_list[col]; - uint16_t port = port_cache[HT32_PAL_IDX(PAL_PORT(line))]; - data |= (((port & (1 << PAL_PAD(line))) ? 0 : 1) << col); - } - - if (current_matrix[row] != data) { - current_matrix[row] = data; - matrix_has_changed = true; - } - } - return matrix_has_changed; -} \ No newline at end of file