From 6e08944570dc4353dfcb04513a5ab656fab96ffe Mon Sep 17 00:00:00 2001 From: bwisn Date: Wed, 15 Sep 2021 09:29:07 +0200 Subject: [PATCH] annepro2: fix drashna's suggestions --- keyboards/annepro2/annepro2.h | 18 ++++++++++ keyboards/annepro2/c15/config.h | 60 --------------------------------- keyboards/annepro2/c15/rules.mk | 4 +-- keyboards/annepro2/c18/config.h | 52 ---------------------------- keyboards/annepro2/c18/rules.mk | 4 +-- keyboards/annepro2/matrix.c | 11 +++--- 6 files changed, 25 insertions(+), 124 deletions(-) diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index a6c984d75d4..449997241da 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -29,6 +29,24 @@ extern uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS]; extern ble_capslock_t BLECapsLock; +// Matrix keymap +// clang-format off +#define LAYOUT( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ + K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \ + K40, K42, K43, K46, K49, K4A, K4B, K4C \ +) { \ + /* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \ + /* ROW1 */ { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \ + /* ROW2 */ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ + /* ROW3 */ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, KC_NO}, \ + /* ROW4 */ { K30, KC_NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \ + /* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \ +} +// clang-format on + enum AP2KeyCodes { KC_AP2_BT1 = SAFE_RANGE, KC_AP2_BT2, diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index 947700f28b8..9c6516fbe65 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -39,23 +39,6 @@ // Number of supported layouts #define NUM_LAYOUTS 4 -// Matrix keymap -// clang-format off -#define LAYOUT( \ - K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ - K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ - K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ - K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \ - K40, K42, K43, K46, K49, K4A, K4B, K4C \ -) { \ - /* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \ - /* ROW1 */ { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \ - /* ROW2 */ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ - /* ROW3 */ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, KC_NO}, \ - /* ROW4 */ { K30, KC_NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \ - /* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \ -} -// clang-format on /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 @@ -105,49 +88,6 @@ * */ -/* key combination for magic key command */ -/* -#define IS_COMMAND() ( \ - keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ -) -*/ - -/* control how magic key switches layers */ -//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true -//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true -//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false - -/* override magic key keymap */ -//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS -//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS -//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM -//#define MAGIC_KEY_HELP1 H -//#define MAGIC_KEY_HELP2 SLASH -//#define MAGIC_KEY_DEBUG D -//#define MAGIC_KEY_DEBUG_MATRIX X -//#define MAGIC_KEY_DEBUG_KBD K -//#define MAGIC_KEY_DEBUG_MOUSE M -//#define MAGIC_KEY_VERSION V -//#define MAGIC_KEY_STATUS S -//#define MAGIC_KEY_CONSOLE C -//#define MAGIC_KEY_LAYER0_ALT1 ESC -//#define MAGIC_KEY_LAYER0_ALT2 GRAVE -//#define MAGIC_KEY_LAYER0 0 -//#define MAGIC_KEY_LAYER1 1 -//#define MAGIC_KEY_LAYER2 2 -//#define MAGIC_KEY_LAYER3 3 -//#define MAGIC_KEY_LAYER4 4 -//#define MAGIC_KEY_LAYER5 5 -//#define MAGIC_KEY_LAYER6 6 -//#define MAGIC_KEY_LAYER7 7 -//#define MAGIC_KEY_LAYER8 8 -//#define MAGIC_KEY_LAYER9 9 -//#define MAGIC_KEY_BOOTLOADER R -//#define MAGIC_KEY_LOCK CAPS -//#define MAGIC_KEY_EEPROM E -//#define MAGIC_KEY_NKRO N -//#define MAGIC_KEY_SLEEP_LED Z - /* * Feature disable options * These options are also useful to firmware size reduction. diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index 082e010abe8..da0de1e56ab 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -6,8 +6,6 @@ SRC = \ qmk_ap2_led.c \ protocol.c -LAYOUTS += - # MCU MCU = cortex-m0plus ARMV = 6 @@ -25,7 +23,7 @@ OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage # Options # Keys -CUSTOM_MATRIX = yes +CUSTOM_MATRIX = lite NKRO_ENABLE = no MOUSEKEY_ENABLE = no EXTRAKEY_ENABLE = yes diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index 4b1f8878ab2..800bf09d053 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -39,23 +39,6 @@ // Number of supported layouts #define NUM_LAYOUTS 4 -// Matrix keymap -// clang-format off -#define LAYOUT( \ - K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ - K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ - K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ - K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \ - K40, K42, K43, K46, K49, K4A, K4B, K4C \ -) { \ - /* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \ - /* ROW1 */ { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \ - /* ROW2 */ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ - /* ROW3 */ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, KC_NO}, \ - /* ROW4 */ { K30, KC_NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \ - /* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \ -} -// clang-format on /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 @@ -137,41 +120,6 @@ ) */ -/* control how magic key switches layers */ -//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true -//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true -//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false - -/* override magic key keymap */ -//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS -//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS -//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM -//#define MAGIC_KEY_HELP1 H -//#define MAGIC_KEY_HELP2 SLASH -//#define MAGIC_KEY_DEBUG D -//#define MAGIC_KEY_DEBUG_MATRIX X -//#define MAGIC_KEY_DEBUG_KBD K -//#define MAGIC_KEY_DEBUG_MOUSE M -//#define MAGIC_KEY_VERSION V -//#define MAGIC_KEY_STATUS S -//#define MAGIC_KEY_CONSOLE C -//#define MAGIC_KEY_LAYER0_ALT1 ESC -//#define MAGIC_KEY_LAYER0_ALT2 GRAVE -//#define MAGIC_KEY_LAYER0 0 -//#define MAGIC_KEY_LAYER1 1 -//#define MAGIC_KEY_LAYER2 2 -//#define MAGIC_KEY_LAYER3 3 -//#define MAGIC_KEY_LAYER4 4 -//#define MAGIC_KEY_LAYER5 5 -//#define MAGIC_KEY_LAYER6 6 -//#define MAGIC_KEY_LAYER7 7 -//#define MAGIC_KEY_LAYER8 8 -//#define MAGIC_KEY_LAYER9 9 -//#define MAGIC_KEY_BOOTLOADER R -//#define MAGIC_KEY_LOCK CAPS -//#define MAGIC_KEY_EEPROM E -//#define MAGIC_KEY_NKRO N -//#define MAGIC_KEY_SLEEP_LED Z /* * Feature disable options diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 17ff59c6e3f..532d6be8b80 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -6,8 +6,6 @@ SRC = \ qmk_ap2_led.c \ protocol.c -LAYOUTS += - # MCU MCU = cortex-m0plus ARMV = 6 @@ -25,7 +23,7 @@ OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage # Options # Keys -CUSTOM_MATRIX = yes +CUSTOM_MATRIX = lite NKRO_ENABLE = no MOUSEKEY_ENABLE = no EXTRAKEY_ENABLE = yes diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c index a723e523a73..86b3c48d88d 100644 --- a/keyboards/annepro2/matrix.c +++ b/keyboards/annepro2/matrix.c @@ -32,14 +32,14 @@ static uint32_t debounce_times[MATRIX_ROWS]; extern ioline_t row_list[MATRIX_ROWS]; extern ioline_t col_list[MATRIX_COLS]; -void matrix_init(void) { +void matrix_init_custom(void) { memset(matrix, 0, MATRIX_ROWS * sizeof(matrix_row_t)); memset(matrix_debouncing, 0, MATRIX_ROWS * sizeof(matrix_row_t)); memset(debounce_times, 0, MATRIX_ROWS * sizeof(uint32_t)); - matrix_init_quantum(); } -uint8_t matrix_scan(void) { +uint8_t matrix_scan_custom(void) { + bool matrix_has_changed = false; // cache of input ports for columns static uint16_t port_cache[4]; // scan each row @@ -75,11 +75,10 @@ uint8_t matrix_scan(void) { // when debouncing complete, update matrix matrix[row] = matrix_debouncing[row]; debounce_times[row] = 0; + matrix_has_changed = true; } } - matrix_scan_quantum(); - - return 1; + return matrix_has_changed; } bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & (1 << col)); }