diff options
69 files changed, 81 insertions, 1782 deletions
| diff --git a/keyboards/bfake/bfake.c b/keyboards/bfake/bfake.c index f7d006576..9039fe546 100644 --- a/keyboards/bfake/bfake.c +++ b/keyboards/bfake/bfake.c @@ -17,9 +17,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "bfake.h" -__attribute__ ((weak)) -void matrix_scan_user(void) {} -  void backlight_init_ports(void) {  	setPinOutput(D0);  	setPinOutput(D1); diff --git a/keyboards/bfake/config.h b/keyboards/bfake/config.h index 0a8911b09..65f1f3a75 100644 --- a/keyboards/bfake/config.h +++ b/keyboards/bfake/config.h @@ -32,7 +32,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #define MATRIX_COLS 11  #define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } -#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6} +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5 }  #define UNUSED_PINS  #define DIODE_DIRECTION COL2ROW diff --git a/keyboards/bfake/matrix.c b/keyboards/bfake/matrix.c deleted file mode 100644 index 57aa36b5f..000000000 --- a/keyboards/bfake/matrix.c +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" - -#ifndef DEBOUNCE -#define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    DDRD &= ~(1<<PIND7); -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    PORTD |= (1<<PIND7); - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } -} - -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ) | ( -            // col 14, PORTD 7 -            ((~PIND) & (1 << PIND7)) << 7 -        ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } - -    matrix_scan_user(); - -    return 1; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/bfake/rules.mk b/keyboards/bfake/rules.mk index 5963c9810..107bb4fa9 100644 --- a/keyboards/bfake/rules.mk +++ b/keyboards/bfake/rules.mk @@ -22,7 +22,3 @@ RGBLIGHT_ENABLE = no  WS2812_DRIVER = i2c  OPT_DEFS = -DDEBUG_LEVEL=0 - -# custom matrix setup -CUSTOM_MATRIX = yes -SRC = matrix.c diff --git a/keyboards/coseyfannitutti/discipad/discipad.c b/keyboards/coseyfannitutti/discipad/discipad.c index c8f6e0a17..4bdb1c6c2 100644 --- a/keyboards/coseyfannitutti/discipad/discipad.c +++ b/keyboards/coseyfannitutti/discipad/discipad.c @@ -14,11 +14,3 @@   * along with this program.  If not, see <http://www.gnu.org/licenses/>.   */  #include "discipad.h" - - -void matrix_init_kb(void) { -	// put your keyboard start-up code here -	// runs once when the firmware starts up - -	matrix_init_user(); -} diff --git a/keyboards/coseyfannitutti/discipline/discipline.c b/keyboards/coseyfannitutti/discipline/discipline.c index 6a788ce0e..50ba0bae5 100644 --- a/keyboards/coseyfannitutti/discipline/discipline.c +++ b/keyboards/coseyfannitutti/discipline/discipline.c @@ -14,11 +14,3 @@   * along with this program.  If not, see <http://www.gnu.org/licenses/>.   */  #include "discipline.h" - - -void matrix_init_kb(void) { -	// put your keyboard start-up code here -	// runs once when the firmware starts up - -	matrix_init_user(); -} diff --git a/keyboards/exclusive/e6v2/le_bmc/keymaps/default/keymap.c b/keyboards/exclusive/e6v2/le_bmc/keymaps/default/keymap.c index 730041917..6d9209e48 100644 --- a/keyboards/exclusive/e6v2/le_bmc/keymaps/default/keymap.c +++ b/keyboards/exclusive/e6v2/le_bmc/keymaps/default/keymap.c @@ -60,15 +60,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {    }    return true;  } - -void matrix_init_user(void) { - -} - -void matrix_scan_user(void) { - -} - -void led_set_user(uint8_t usb_led) { - -} diff --git a/keyboards/exclusive/e6v2/oe_bmc/keymaps/default/keymap.c b/keyboards/exclusive/e6v2/oe_bmc/keymaps/default/keymap.c index 730041917..6d9209e48 100644 --- a/keyboards/exclusive/e6v2/oe_bmc/keymaps/default/keymap.c +++ b/keyboards/exclusive/e6v2/oe_bmc/keymaps/default/keymap.c @@ -60,15 +60,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {    }    return true;  } - -void matrix_init_user(void) { - -} - -void matrix_scan_user(void) { - -} - -void led_set_user(uint8_t usb_led) { - -} diff --git a/keyboards/ft/mars80/keymaps/default/keymap.c b/keyboards/ft/mars80/keymaps/default/keymap.c index ba7ef83d9..010102d72 100644 --- a/keyboards/ft/mars80/keymaps/default/keymap.c +++ b/keyboards/ft/mars80/keymaps/default/keymap.c @@ -61,15 +61,3 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {    }    return true;  } - -void matrix_init_user(void) { - -} - -void matrix_scan_user(void) { - -} - -void led_set_user(uint8_t usb_led) { - -} diff --git a/keyboards/jc65/v32a/config.h b/keyboards/jc65/v32a/config.h index 444ebad07..5439dbe39 100644 --- a/keyboards/jc65/v32a/config.h +++ b/keyboards/jc65/v32a/config.h @@ -26,8 +26,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #define PRODUCT         JC65 PS2AVRGB  /* matrix size */ -#define MATRIX_ROWS 8 -#define MATRIX_COLS 16 +#define MATRIX_ROWS 7 +#define MATRIX_COLS 15 +#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B6, B7 } +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } +#define DIODE_DIRECTION COL2ROW  #define BACKLIGHT_LEVELS 1  #define RGBLED_NUM 16 diff --git a/keyboards/jc65/v32a/matrix.c b/keyboards/jc65/v32a/matrix.c deleted file mode 100644 index 57aa36b5f..000000000 --- a/keyboards/jc65/v32a/matrix.c +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" - -#ifndef DEBOUNCE -#define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    DDRD &= ~(1<<PIND7); -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    PORTD |= (1<<PIND7); - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } -} - -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ) | ( -            // col 14, PORTD 7 -            ((~PIND) & (1 << PIND7)) << 7 -        ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } - -    matrix_scan_user(); - -    return 1; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/jc65/v32a/rules.mk b/keyboards/jc65/v32a/rules.mk index 18e7f1de9..a8fea7efa 100644 --- a/keyboards/jc65/v32a/rules.mk +++ b/keyboards/jc65/v32a/rules.mk @@ -22,7 +22,3 @@ RGBLIGHT_ENABLE = yes  WS2812_DRIVER = i2c  OPT_DEFS = -DDEBUG_LEVEL=0 - -# custom matrix setup -CUSTOM_MATRIX = yes -SRC = matrix.c diff --git a/keyboards/jc65/v32a/v32a.c b/keyboards/jc65/v32a/v32a.c index 9b1e07274..2a289872f 100644 --- a/keyboards/jc65/v32a/v32a.c +++ b/keyboards/jc65/v32a/v32a.c @@ -17,9 +17,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "v32a.h" -__attribute__ ((weak)) -void matrix_scan_user(void) {} -  #ifdef BACKLIGHT_ENABLE  void backlight_init_ports(void) {  	setPinOutput(D0); diff --git a/keyboards/jc65/v32a/v32a.h b/keyboards/jc65/v32a/v32a.h index ba91d80a6..b319ba80a 100644 --- a/keyboards/jc65/v32a/v32a.h +++ b/keyboards/jc65/v32a/v32a.h @@ -27,14 +27,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.    K01,K30,K11,K21,K31,K41,K51,K46,KE6,KE7,K47,KA1,    KB1,K86,K77, \    K00,K10,K20,    K40,K56,K50,            K57,KB0,KC0,K96,K76,K66  \  ){ \ -  {   K00,  K10,  K20,  K30,  K40,  K50,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,  KB0,  KC0,  KD0,KC_NO,KC_NO }, \ -  {   K01,  K11,  K21,  K31,  K41,  K51,KC_NO,KC_NO,KC_NO,KC_NO,  KA1,  KB1,KC_NO,KC_NO,KC_NO,KC_NO }, \ -  {   K02,  K12,  K22,  K32,  K42,  K52,KC_NO,KC_NO,KC_NO,KC_NO,  KA2,  KB2,  KC2,  KD2,KC_NO,KC_NO }, \ -  {   K03,  K13,  K23,  K33,  K43,  K53,KC_NO,KC_NO,KC_NO,KC_NO,  KA3,  KB3,  KC3,  KD3,KC_NO,KC_NO }, \ -  {   K04,  K14,  K24,  K34,  K44,  K54,KC_NO,KC_NO,KC_NO,KC_NO,  KA4,  KB4,  KC4,  KD4,  KE4,KC_NO }, \ -  { KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO }, \ -  { KC_NO,  K16,  K26,  K36,  K46,  K56,  K66,  K76,  K86,  K96,KC_NO,  KB6,  KC6,  KD6,  KE6,KC_NO }, \ -  { KC_NO,  K17,  K27,  K37,  K47,  K57,  K67,  K77,  K87,KC_NO,KC_NO,  KB7,  KC7,  KD7,  KE7,KC_NO }  \ +  {   K00,  K10,  K20,  K30,  K40,  K50,KC_NO,KC_NO,KC_NO,KC_NO,KC_NO,  KB0,  KC0,  KD0,KC_NO }, \ +  {   K01,  K11,  K21,  K31,  K41,  K51,KC_NO,KC_NO,KC_NO,KC_NO,  KA1,  KB1,KC_NO,KC_NO,KC_NO }, \ +  {   K02,  K12,  K22,  K32,  K42,  K52,KC_NO,KC_NO,KC_NO,KC_NO,  KA2,  KB2,  KC2,  KD2,KC_NO }, \ +  {   K03,  K13,  K23,  K33,  K43,  K53,KC_NO,KC_NO,KC_NO,KC_NO,  KA3,  KB3,  KC3,  KD3,KC_NO }, \ +  {   K04,  K14,  K24,  K34,  K44,  K54,KC_NO,KC_NO,KC_NO,KC_NO,  KA4,  KB4,  KC4,  KD4,  KE4 }, \ +  { KC_NO,  K16,  K26,  K36,  K46,  K56,  K66,  K76,  K86,  K96,KC_NO,  KB6,  KC6,  KD6,  KE6 }, \ +  { KC_NO,  K17,  K27,  K37,  K47,  K57,  K67,  K77,  K87,KC_NO,KC_NO,  KB7,  KC7,  KD7,  KE7 }  \  }  #define LAYOUT_kc( \ @@ -45,14 +44,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.    K00,K10,K20,    K40,K56,K50,            K57,KB0,KC0,K96,K76,K66  \  ) \  { \ -  { KC_##K00,KC_##K10,KC_##K20,KC_##K30,KC_##K40,KC_##K50,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,KC_##KB0,KC_##KC0,KC_##KD0,   KC_NO,KC_NO }, \ -  { KC_##K01,KC_##K11,KC_##K21,KC_##K31,KC_##K41,KC_##K51,   KC_NO,   KC_NO,   KC_NO,   KC_NO,KC_##KA1,KC_##KB1,   KC_NO,   KC_NO,   KC_NO,KC_NO }, \ -  { KC_##K02,KC_##K12,KC_##K22,KC_##K32,KC_##K42,KC_##K52,   KC_NO,   KC_NO,   KC_NO,   KC_NO,KC_##KA2,KC_##KB2,KC_##KC2,KC_##KD2,   KC_NO,KC_NO }, \ -  { KC_##K03,KC_##K13,KC_##K23,KC_##K33,KC_##K43,KC_##K53,   KC_NO,   KC_NO,   KC_NO,   KC_NO,KC_##KA3,KC_##KB3,KC_##KC3,KC_##KD3,   KC_NO,KC_NO }, \ -  { KC_##K04,KC_##K14,KC_##K24,KC_##K34,KC_##K44,KC_##K54,   KC_NO,   KC_NO,   KC_NO,   KC_NO,KC_##KA4,KC_##KB4,KC_##KC4,KC_##KD4,KC_##KE4,KC_NO }, \ -  {    KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,KC_NO }, \ -  {    KC_NO,KC_##K16,KC_##K26,KC_##K36,KC_##K46,KC_##K56,KC_##K66,KC_##K76,KC_##K86,KC_##K96,   KC_NO,KC_##KB6,KC_##KC6,KC_##KD6,KC_##KE6,KC_NO }, \ -  {    KC_NO,KC_##K17,KC_##K27,KC_##K37,KC_##K47,KC_##K57,KC_##K67,KC_##K77,KC_##K87,   KC_NO,   KC_NO,KC_##KB7,KC_##KC7,KC_##KD7,KC_##KE7,KC_NO }  \ +  { KC_##K00,KC_##K10,KC_##K20,KC_##K30,KC_##K40,KC_##K50,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,KC_##KB0,KC_##KC0,KC_##KD0,   KC_NO }, \ +  { KC_##K01,KC_##K11,KC_##K21,KC_##K31,KC_##K41,KC_##K51,   KC_NO,   KC_NO,   KC_NO,   KC_NO,KC_##KA1,KC_##KB1,   KC_NO,   KC_NO,   KC_NO }, \ +  { KC_##K02,KC_##K12,KC_##K22,KC_##K32,KC_##K42,KC_##K52,   KC_NO,   KC_NO,   KC_NO,   KC_NO,KC_##KA2,KC_##KB2,KC_##KC2,KC_##KD2,   KC_NO }, \ +  { KC_##K03,KC_##K13,KC_##K23,KC_##K33,KC_##K43,KC_##K53,   KC_NO,   KC_NO,   KC_NO,   KC_NO,KC_##KA3,KC_##KB3,KC_##KC3,KC_##KD3,   KC_NO }, \ +  { KC_##K04,KC_##K14,KC_##K24,KC_##K34,KC_##K44,KC_##K54,   KC_NO,   KC_NO,   KC_NO,   KC_NO,KC_##KA4,KC_##KB4,KC_##KC4,KC_##KD4,KC_##KE4 }, \ +  {    KC_NO,KC_##K16,KC_##K26,KC_##K36,KC_##K46,KC_##K56,KC_##K66,KC_##K76,KC_##K86,KC_##K96,   KC_NO,KC_##KB6,KC_##KC6,KC_##KD6,KC_##KE6 }, \ +  {    KC_NO,KC_##K17,KC_##K27,KC_##K37,KC_##K47,KC_##K57,KC_##K67,KC_##K77,KC_##K87,   KC_NO,   KC_NO,KC_##KB7,KC_##KC7,KC_##KD7,KC_##KE7 }  \  }  #endif diff --git a/keyboards/jj40/rules.mk b/keyboards/jj40/rules.mk index 8e0e8c864..c53a6804c 100644 --- a/keyboards/jj40/rules.mk +++ b/keyboards/jj40/rules.mk @@ -1,18 +1,3 @@ -# Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> -# -# 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 <http://www.gnu.org/licenses/>. -  # MCU name  MCU = atmega32a diff --git a/keyboards/jj50/config.h b/keyboards/jj50/config.h index dfd8a4a8f..884a28d50 100644 --- a/keyboards/jj50/config.h +++ b/keyboards/jj50/config.h @@ -32,9 +32,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #define DESCRIPTION     Preonic-like clone  /* matrix size */ -#define MATRIX_ROWS 8 -#define MATRIX_COLS 15 -#define DIODE_DIRECTION ROW2COL +#define MATRIX_ROWS 5 +#define MATRIX_COLS 12 +#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4 } +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4 } +#define DIODE_DIRECTION COL2ROW  //#define BACKLIGHT_PIN D4  #define BACKLIGHT_LEVELS 12 diff --git a/keyboards/jj50/jj50.c b/keyboards/jj50/jj50.c index 7c3cee95d..a302adf40 100644 --- a/keyboards/jj50/jj50.c +++ b/keyboards/jj50/jj50.c @@ -20,16 +20,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "backlight.h"  #include "backlight_custom.h" -void matrix_init_kb(void) { matrix_init_user(); } - -__attribute__ ((weak)) -void matrix_init_user(void) {} - -void matrix_scan_kb(void) { matrix_scan_user(); } - -__attribute__ ((weak)) -void matrix_scan_user(void) {} -  #ifdef BACKLIGHT_ENABLE  void backlight_init_ports(void) {      b_led_init_ports(); diff --git a/keyboards/jj50/jj50.h b/keyboards/jj50/jj50.h index 8a904897e..6b1c7eacf 100644 --- a/keyboards/jj50/jj50.h +++ b/keyboards/jj50/jj50.h @@ -25,8 +25,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "keycode.h"  #include "action.h" -void matrix_init_user(void); -  #define LAYOUT_ortho_5x12( \      K011, K010, K009, K008, K004, K005, K006, K007, K003, K002, K201, K000, \      K111, K110, K109, K108, K104, K105, K106, K107, K103, K102, K001, K100, \ diff --git a/keyboards/jj50/matrix.c b/keyboards/jj50/matrix.c deleted file mode 100644 index 95c6057e7..000000000 --- a/keyboards/jj50/matrix.c +++ /dev/null @@ -1,107 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> -Modified 2018 by Wayne K Jones <github.com/WarmCatUK> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" - -#ifndef DEBOUNCE -#   define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    //----> DDRD &= ~(1<<PIND7); -    // Port D not used on this keyboard -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    //PORTD |= (1<<PIND7); -    // Port D not used on this keyboard - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } -    matrix_init_quantum();  // missing from original port by Luiz -} - -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } -    matrix_scan_quantum();  // also missing in original PS2AVRGB implementation -    //matrix_scan_user(); - -    return 1; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/jj50/rules.mk b/keyboards/jj50/rules.mk index 40473e6ec..62b21e4df 100644 --- a/keyboards/jj50/rules.mk +++ b/keyboards/jj50/rules.mk @@ -29,8 +29,6 @@ SLEEP_LED_ENABLE = no    # Breathing sleep LED during USB suspend  #OPT_DEFS = -DDEBUG_LEVEL=0 -# custom matrix setup -CUSTOM_MATRIX = yes -SRC = matrix.c backlight.c +SRC = backlight.c  LAYOUTS = ortho_5x12 diff --git a/keyboards/leeku/finger65/config.h b/keyboards/leeku/finger65/config.h index 3e6eebb32..584db4ad3 100644 --- a/keyboards/leeku/finger65/config.h +++ b/keyboards/leeku/finger65/config.h @@ -37,6 +37,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #define MATRIX_ROW_PINS { C3, C4, C5, C6, C7 }  #define UNUSED_PINS +#define DIODE_DIRECTION COL2ROW +  /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */  #define DEBOUNCE 5 diff --git a/keyboards/mechmini/v1/config.h b/keyboards/mechmini/v1/config.h index 9355a6dc3..eb15a368a 100644 --- a/keyboards/mechmini/v1/config.h +++ b/keyboards/mechmini/v1/config.h @@ -30,8 +30,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #define DESCRIPTION     40% modular keyboard  /* matrix size */ -#define MATRIX_ROWS 8 -#define MATRIX_COLS 15 +#define MATRIX_ROWS 4 +#define MATRIX_COLS 12 +#define MATRIX_ROW_PINS { B0, B1, B2, B3 } +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4 } +#define DIODE_DIRECTION COL2ROW  #define NO_UART 1 diff --git a/keyboards/mechmini/v1/matrix.c b/keyboards/mechmini/v1/matrix.c deleted file mode 100644 index 245813dfd..000000000 --- a/keyboards/mechmini/v1/matrix.c +++ /dev/null @@ -1,112 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" - -#ifndef DEBOUNCE -#   define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -void matrix_set_row_status(uint8_t row); -uint8_t bit_reverse(uint8_t x); - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    DDRD &= ~(1<<PIND7); -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    PORTD |= (1<<PIND7); - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } - -    matrix_init_quantum(); -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ) | ( -            // col 14, PORTD 7 -            ((~PIND) & (1 << PIND7)) << 7 -        ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } - -    matrix_scan_quantum(); - -    return 1; -} - -// declarations -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/mechmini/v1/rules.mk b/keyboards/mechmini/v1/rules.mk index ee023b43b..1c6252c59 100644 --- a/keyboards/mechmini/v1/rules.mk +++ b/keyboards/mechmini/v1/rules.mk @@ -22,7 +22,3 @@ RGBLIGHT_ENABLE = yes  WS2812_DRIVER = i2c  OPT_DEFS = -DDEBUG_LEVEL=0 - -# custom matrix setup -CUSTOM_MATRIX = yes -SRC = matrix.c diff --git a/keyboards/mechmini/v1/v1.c b/keyboards/mechmini/v1/v1.c index 2c910d965..ba0e09520 100644 --- a/keyboards/mechmini/v1/v1.c +++ b/keyboards/mechmini/v1/v1.c @@ -16,13 +16,3 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */  #include "v1.h" - -void matrix_init_kb(void) { matrix_init_user(); } - -__attribute__ ((weak)) -void matrix_init_user(void) {} - -void matrix_scan_kb(void) { matrix_scan_user(); } - -__attribute__ ((weak)) -void matrix_scan_user(void) {} diff --git a/keyboards/mechmini/v1/v1.h b/keyboards/mechmini/v1/v1.h index 1e392b353..acdad5c6d 100644 --- a/keyboards/mechmini/v1/v1.h +++ b/keyboards/mechmini/v1/v1.h @@ -30,14 +30,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.      K00, K10, K20,      K56, K57, KB0,           KC0, K66  \  ) \  { \ -    { K00, K10, K20, K56, KC_NO,    K57,    KC_NO, KC_NO,    KB0, KC0, K66, KC_NO,    KC_NO,    KC_NO,    KC_NO }, \ -    { K01, K11, K21, K31, K41, K51, K46, KE6, KE7, K47, KA1, KC_NO,    KC_NO,    KC_NO,    KC_NO }, \ -    { K02, K12, K22, K32, K42, K52, K36, KD6, KD7, K37, KA2, KC_NO,    KC_NO,    KC_NO,    KC_NO }, \ -    { K03, K13, K23, K33, K43, K53, K26, KC6, KC7, K27, KA3, KB3, KC_NO,    KC_NO,    KC_NO }, \ -    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO }, \ -    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO }, \ -    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO }, \ -    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO } \ +    { K00, K10, K20, K56, KC_NO, K57, KC_NO, KC_NO, KB0, KC0, K66, KC_NO }, \ +    { K01, K11, K21, K31, K41,   K51, K46,   KE6,   KE7, K47, KA1, KC_NO }, \ +    { K02, K12, K22, K32, K42,   K52, K36,   KD6,   KD7, K37, KA2, KC_NO }, \ +    { K03, K13, K23, K33, K43,   K53, K26,   KC6,   KC7, K27, KA3, KB3   } \  }  #define LAYOUT_split_space( \ @@ -47,14 +43,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.      K00, K10, K20,      K56, K57, KB0,           KC0, K66  \  ) \  { \ -    { K00, K10, K20, K56, KC_NO,    KC_NO,    K57, KC_NO,    KB0, KC0, K66, KC_NO,    KC_NO,    KC_NO,    KC_NO }, \ -    { K01, K11, K21, K31, K41, K51, K46, KE6, KE7, K47, KA1, KC_NO,    KC_NO,    KC_NO,    KC_NO }, \ -    { K02, K12, K22, K32, K42, K52, K36, KD6, KD7, K37, KA2, KC_NO,    KC_NO,    KC_NO,    KC_NO }, \ -    { K03, K13, K23, K33, K43, K53, K26, KC6, KC7, K27, KA3, KB3, KC_NO,    KC_NO,    KC_NO }, \ -    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO }, \ -    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO }, \ -    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO }, \ -    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO } \ +    { K00, K10, K20, K56, KC_NO, KC_NO, K57, KC_NO, KB0, KC0, K66, KC_NO }, \ +    { K01, K11, K21, K31, K41,   K51,   K46, KE6,   KE7, K47, KA1, KC_NO }, \ +    { K02, K12, K22, K32, K42,   K52,   K36, KD6,   KD7, K37, KA2, KC_NO }, \ +    { K03, K13, K23, K33, K43,   K53,   K26, KC6,   KC7, K27, KA3, KB3   } \  }  #endif diff --git a/keyboards/mehkee96/config.h b/keyboards/mehkee96/config.h index 4adfcc86b..d506626d1 100644 --- a/keyboards/mehkee96/config.h +++ b/keyboards/mehkee96/config.h @@ -12,6 +12,9 @@  /* matrix size */  #define MATRIX_ROWS 8  #define MATRIX_COLS 15 +#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } +#define DIODE_DIRECTION COL2ROW  #define RGBLED_NUM 16  #define RGBLIGHT_ANIMATIONS diff --git a/keyboards/mehkee96/keymaps/default/keymap.c b/keyboards/mehkee96/keymaps/default/keymap.c index cd69fb2fe..46ee4d19c 100644 --- a/keyboards/mehkee96/keymaps/default/keymap.c +++ b/keyboards/mehkee96/keymaps/default/keymap.c @@ -68,13 +68,3 @@ BL_TOGG, BL_DEC, BL_INC changes the in-switch LEDs      _______         , _______, _______, BL_DEC,  BL_TOGG, BL_INC,  _______, _______, _______, _______, _______, _______,          _______, _______, _______, _______, _______,      _______, _______, _______,                            _______,                            _______, _______, _______, _______, _______, _______, _______, _______, _______),  }; - -void matrix_init_user(void) { -} - -void matrix_scan_user(void) { -} - -bool process_record_user(uint16_t keycode, keyrecord_t *record) { -	return true; -} diff --git a/keyboards/mehkee96/matrix.c b/keyboards/mehkee96/matrix.c deleted file mode 100644 index bbb84e52e..000000000 --- a/keyboards/mehkee96/matrix.c +++ /dev/null @@ -1,130 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" - -#ifndef DEBOUNCE -#   define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -void matrix_set_row_status(uint8_t row); -uint8_t bit_reverse(uint8_t x); - -__attribute__ ((weak)) -void matrix_init_kb(void) { -    matrix_init_user(); -} - -__attribute__ ((weak)) -void matrix_scan_kb(void) { -    matrix_scan_user(); -} - -__attribute__ ((weak)) -void matrix_init_user(void) { -} - -__attribute__ ((weak)) -void matrix_scan_user(void) { -} - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    DDRD &= ~(1<<PIND7); -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    PORTD |= (1<<PIND7); - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } - -    matrix_init_quantum(); -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ) | ( -            // col 14, PORTD 7 -            ((~PIND) & (1 << PIND7)) << 7 -        ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } - -    matrix_scan_quantum(); - -    return 1; -} - -// declarations -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/mehkee96/mehkee96.c b/keyboards/mehkee96/mehkee96.c index 46427ec93..d9e2bac7a 100644 --- a/keyboards/mehkee96/mehkee96.c +++ b/keyboards/mehkee96/mehkee96.c @@ -16,13 +16,3 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */  #include "mehkee96.h" - -void matrix_init_kb(void) { matrix_init_user(); } - -__attribute__ ((weak)) -void matrix_init_user(void) {} - -void matrix_scan_kb(void) { matrix_scan_user(); } - -__attribute__ ((weak)) -void matrix_scan_user(void) {} diff --git a/keyboards/mehkee96/rules.mk b/keyboards/mehkee96/rules.mk index 1cbd02948..a7d36548f 100644 --- a/keyboards/mehkee96/rules.mk +++ b/keyboards/mehkee96/rules.mk @@ -24,7 +24,3 @@ RGBLIGHT_ENABLE = yes  WS2812_DRIVER = i2c  OPT_DEFS = -DDEBUG_LEVEL=0 - -# custom matrix setup -CUSTOM_MATRIX = yes -SRC = matrix.c diff --git a/keyboards/mt40/config.h b/keyboards/mt40/config.h index 48f707f71..f5038fb54 100644 --- a/keyboards/mt40/config.h +++ b/keyboards/mt40/config.h @@ -32,7 +32,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #define DESCRIPTION     A Planck clone  /* key matrix size */ -#define MATRIX_ROWS 8 +#define MATRIX_ROWS 7  #define MATRIX_COLS 15  #define NO_UART 1 @@ -55,12 +55,12 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  /* #define CB6 0x37 // B7 */  /* #define CC7 0x62 // C2 */ -#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } -#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C2, C3, C4, C5, C6, C7, D7 } +#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B6, B7 } +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 }  /* #define UNUSED_PINS */  /* COL2ROW, ROW2COL*/ -/* #define DIODE_DIRECTION COL2ROW */ +#define DIODE_DIRECTION COL2ROW  #define BACKLIGHT_PIN D2 diff --git a/keyboards/mt40/matrix.c b/keyboards/mt40/matrix.c deleted file mode 100644 index d75fcc221..000000000 --- a/keyboards/mt40/matrix.c +++ /dev/null @@ -1,128 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" -#include "config.h" - -#ifndef DEBOUNCE -#   define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -__attribute__ ((weak)) -void matrix_init_kb(void) { -    matrix_init_user(); -} - -__attribute__ ((weak)) -void matrix_scan_kb(void) { -    matrix_scan_user(); -} - -__attribute__ ((weak)) -void matrix_init_user(void) { -} - -__attribute__ ((weak)) -void matrix_scan_user(void) { -} - - - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    DDRD &= ~(1<<PIND7); -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    PORTD |= (1<<PIND7); - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } -    matrix_init_kb(); -} - -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ) | ( -            // col 14, PORTD 7 -            ((~PIND) & (1 << PIND7)) << 7 -        ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } - -    matrix_scan_kb(); - -    return 1; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/mt40/mt40.h b/keyboards/mt40/mt40.h index a53957708..3ff9c89d0 100644 --- a/keyboards/mt40/mt40.h +++ b/keyboards/mt40/mt40.h @@ -34,7 +34,6 @@      { K30,   K11,   K12,   K13,   K14,   K15,   KC_NO, KC_NO, KC_NO, KC_NO, K1A,   K1B,   KC_NO, KC_NO, KC_NO }, \      { K10,   K01,   K02,   K03,   K04,   K05,   KC_NO, KC_NO, KC_NO, KC_NO, K0A,   KC_NO, KC_NO, KC_NO, KC_NO }, \      { K00,   KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K0B   }, \ -    { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \      { KC_NO, KC_NO, K06,   K16,   K26,   K35,   K38,   K3A,   K39,   K3B,   KC_NO, KC_NO, K07,   K17,   K27   }, \      { KC_NO, KC_NO, K09,   K19,   K29,   KC_NO, K2B,   KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K08,   K18,   K28   }  \  } diff --git a/keyboards/mt40/rules.mk b/keyboards/mt40/rules.mk index 0cbf90c67..338a83cc7 100644 --- a/keyboards/mt40/rules.mk +++ b/keyboards/mt40/rules.mk @@ -29,9 +29,5 @@ TAP_DANCE_ENABLE = no  OPT_DEFS = -DDEBUG_LEVEL=0 -# custom matrix setup -CUSTOM_MATRIX = yes -SRC = matrix.c -  LAYOUTS = planck_mit  LAYOUTS_HAS_RGB = no diff --git a/keyboards/percent/canoe/canoe.c b/keyboards/percent/canoe/canoe.c index e59b0dd7b..79c6330fe 100644 --- a/keyboards/percent/canoe/canoe.c +++ b/keyboards/percent/canoe/canoe.c @@ -17,16 +17,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "canoe.h" -void matrix_init_kb(void) { matrix_init_user(); } - -__attribute__ ((weak)) -void matrix_init_user(void) {} - -void matrix_scan_kb(void) { matrix_scan_user(); } - -__attribute__ ((weak)) -void matrix_scan_user(void) {} -  #ifdef BACKLIGHT_ENABLE  void backlight_set(uint8_t level) {  	if (level == 0) { diff --git a/keyboards/percent/canoe/canoe.h b/keyboards/percent/canoe/canoe.h index 9e1e3e3d6..83d7c08bb 100644 --- a/keyboards/percent/canoe/canoe.h +++ b/keyboards/percent/canoe/canoe.h @@ -32,10 +32,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.    { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E }, \    { _x_, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E }, \    { K30, _x_, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E }, \ -  { K40, _x_, K42, K43, K44, _x_, _x_, _x_, K48, _x_, K4A, K4B, K4C, K4D, K4E }, \ -  { _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }, \ -  { _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }, \ -  { _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }  \ +  { K40, _x_, K42, K43, K44, _x_, _x_, _x_, K48, _x_, K4A, K4B, K4C, K4D, K4E }  \  }  #define LAYOUT_65_ansi_blocker( \ @@ -49,10 +46,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.    { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E }, \    { _x_, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E }, \    { K30, _x_, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E }, \ -  { K40, _x_, K42, K43, K44, _x_, _x_, _x_, K48, _x_, _x_, K4B, K4C, K4D, K4E }, \ -  { _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }, \ -  { _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }, \ -  { _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_, _x_ }  \ +  { K40, _x_, K42, K43, K44, _x_, _x_, _x_, K48, _x_, _x_, K4B, K4C, K4D, K4E }  \  }  #define LAYOUT LAYOUT_65_ansi_blocker // added to not break existing checked in keymaps diff --git a/keyboards/percent/canoe/config.h b/keyboards/percent/canoe/config.h index bae6ed20f..950e0806e 100644 --- a/keyboards/percent/canoe/config.h +++ b/keyboards/percent/canoe/config.h @@ -28,11 +28,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #define RGBLED_NUM 2 -#define MATRIX_ROWS 8 +#define MATRIX_ROWS 5  #define MATRIX_COLS 15 -#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } -#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, C1 } +#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4 } +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 }  #define UNUSED_PINS  #define DIODE_DIRECTION COL2ROW diff --git a/keyboards/percent/canoe/matrix.c b/keyboards/percent/canoe/matrix.c deleted file mode 100644 index 245813dfd..000000000 --- a/keyboards/percent/canoe/matrix.c +++ /dev/null @@ -1,112 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" - -#ifndef DEBOUNCE -#   define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -void matrix_set_row_status(uint8_t row); -uint8_t bit_reverse(uint8_t x); - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    DDRD &= ~(1<<PIND7); -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    PORTD |= (1<<PIND7); - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } - -    matrix_init_quantum(); -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ) | ( -            // col 14, PORTD 7 -            ((~PIND) & (1 << PIND7)) << 7 -        ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } - -    matrix_scan_quantum(); - -    return 1; -} - -// declarations -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/percent/canoe/rules.mk b/keyboards/percent/canoe/rules.mk index f2f6ee4e5..6340c8122 100644 --- a/keyboards/percent/canoe/rules.mk +++ b/keyboards/percent/canoe/rules.mk @@ -23,8 +23,4 @@ WS2812_DRIVER = i2c  OPT_DEFS = -DDEBUG_LEVEL=0 -# custom matrix setup -CUSTOM_MATRIX = yes -SRC = matrix.c -  LAYOUTS = 65_ansi_blocker 65_iso_blocker diff --git a/keyboards/percent/skog/config.h b/keyboards/percent/skog/config.h index 7c68d797d..7a0c703ec 100644 --- a/keyboards/percent/skog/config.h +++ b/keyboards/percent/skog/config.h @@ -26,9 +26,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #define PRODUCT         Skog TKL  /* matrix size */ -#define MATRIX_ROWS 8 +#define MATRIX_ROWS 7  #define MATRIX_COLS 14 +#define MATRIX_ROW_PINS { B0, B1, B2, B3, B5, B6, B7 } +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2 } +#define DIODE_DIRECTION COL2ROW +  #define RGBLED_NUM 2  #define RGBLIGHT_ANIMATIONS diff --git a/keyboards/percent/skog/keymaps/default/keymap.c b/keyboards/percent/skog/keymaps/default/keymap.c index eefc24cb0..282ce39a5 100644 --- a/keyboards/percent/skog/keymaps/default/keymap.c +++ b/keyboards/percent/skog/keymaps/default/keymap.c @@ -27,11 +27,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {        KC_LCTL, KC_LGUI, KC_LALT,                   KC_SPC,                                      KC_RALT,  KC_RGUI,    KC_MENU,    KC_RCTL,                 KC_LEFT, KC_DOWN, KC_RGHT      )  }; - -void matrix_init_user(void) { - -} - -void matrix_scan_user(void) { - -} diff --git a/keyboards/percent/skog/matrix.c b/keyboards/percent/skog/matrix.c deleted file mode 100644 index 245813dfd..000000000 --- a/keyboards/percent/skog/matrix.c +++ /dev/null @@ -1,112 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" - -#ifndef DEBOUNCE -#   define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -void matrix_set_row_status(uint8_t row); -uint8_t bit_reverse(uint8_t x); - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    DDRD &= ~(1<<PIND7); -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    PORTD |= (1<<PIND7); - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } - -    matrix_init_quantum(); -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ) | ( -            // col 14, PORTD 7 -            ((~PIND) & (1 << PIND7)) << 7 -        ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } - -    matrix_scan_quantum(); - -    return 1; -} - -// declarations -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/percent/skog/skog.c b/keyboards/percent/skog/skog.c index 8678d483a..1c26c550e 100644 --- a/keyboards/percent/skog/skog.c +++ b/keyboards/percent/skog/skog.c @@ -22,16 +22,6 @@ ps2avrGB support code by Kenneth A. (bminiex/.[ch])  #include "backlight.h"  #include "backlight_custom.h" -void matrix_init_kb(void) { matrix_init_user(); } - -__attribute__ ((weak)) -void matrix_init_user(void) {} - -void matrix_scan_kb(void) { matrix_scan_user(); } - -__attribute__ ((weak)) -void matrix_scan_user(void) {} -  #ifdef BACKLIGHT_ENABLE  /// Overrides functions in `quantum.c`  void backlight_init_ports(void) { diff --git a/keyboards/percent/skog/skog.h b/keyboards/percent/skog/skog.h index 17be94621..c04a765b2 100644 --- a/keyboards/percent/skog/skog.h +++ b/keyboards/percent/skog/skog.h @@ -32,7 +32,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.    { K01,   K11,   K21,   K31,   K41,   K51,   K61,   KC_NO, K81,   K91,   KA1,   KB1,   KC1,   KD1   }, \    { K02,   K12,   K22,   K32,   K42,   K52,   K62,   K72,   K82,   K92,   KA2,   KB2,   KC2,   KD2   }, \    { K03,   K13,   K23,   K33,   K43,   K53,   K63,   K73,   K83,   K93,   KA3,   KB3,   KC3,   KD3   }, \ -  { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \    { K05,   K15,   K25,   K35,   K45,   K55,   K65,   K75,   K85,   K95,   KA5,   KB5,   KC5,   KC_NO }, \    { K06,   K16,   K26,   K36,   K46,   K56,   K66,   K76,   K86,   K96,   KA6,   KB6,   KC6,   KD6   }, \    { K07,   K17,   K27,   K37,   KC_NO, K57,   KC_NO, KC_NO, K87,   K97,   KA7,   KB7,   KC7,   KD7   }  \ diff --git a/keyboards/winkeyless/bface/config.h b/keyboards/winkeyless/bface/config.h index 9d90e16a3..95d44557a 100644 --- a/keyboards/winkeyless/bface/config.h +++ b/keyboards/winkeyless/bface/config.h @@ -35,6 +35,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7}  #define UNUSED_PINS +#define DIODE_DIRECTION COL2ROW +  #define RGBLED_NUM 16  #define RGBLIGHT_ANIMATIONS diff --git a/keyboards/winkeyless/bmini/bmini.c b/keyboards/winkeyless/bmini/bmini.c index 87a31d052..f44fd36a8 100644 --- a/keyboards/winkeyless/bmini/bmini.c +++ b/keyboards/winkeyless/bmini/bmini.c @@ -16,6 +16,3 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */  #include "bmini.h" - -__attribute__ ((weak)) -void matrix_scan_user(void) {} diff --git a/keyboards/winkeyless/bmini/config.h b/keyboards/winkeyless/bmini/config.h index 37df80f80..f8a26e4f0 100644 --- a/keyboards/winkeyless/bmini/config.h +++ b/keyboards/winkeyless/bmini/config.h @@ -31,6 +31,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  /* matrix size */  #define MATRIX_ROWS 8  #define MATRIX_COLS 15 +#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } +#define DIODE_DIRECTION COL2ROW  #define RGBLIGHT_ANIMATIONS diff --git a/keyboards/winkeyless/bmini/matrix.c b/keyboards/winkeyless/bmini/matrix.c deleted file mode 100644 index 57aa36b5f..000000000 --- a/keyboards/winkeyless/bmini/matrix.c +++ /dev/null @@ -1,106 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" - -#ifndef DEBOUNCE -#define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    DDRD &= ~(1<<PIND7); -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    PORTD |= (1<<PIND7); - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } -} - -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ) | ( -            // col 14, PORTD 7 -            ((~PIND) & (1 << PIND7)) << 7 -        ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } - -    matrix_scan_user(); - -    return 1; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/winkeyless/bmini/rules.mk b/keyboards/winkeyless/bmini/rules.mk index 7822bd830..530e8ea32 100644 --- a/keyboards/winkeyless/bmini/rules.mk +++ b/keyboards/winkeyless/bmini/rules.mk @@ -22,7 +22,3 @@ RGBLIGHT_ENABLE = yes  WS2812_DRIVER = i2c  OPT_DEFS = -DDEBUG_LEVEL=0 - -# custom matrix setup -CUSTOM_MATRIX = yes -SRC = matrix.c diff --git a/keyboards/winkeyless/bminiex/config.h b/keyboards/winkeyless/bminiex/config.h index 35c8ce933..037ca0028 100644 --- a/keyboards/winkeyless/bminiex/config.h +++ b/keyboards/winkeyless/bminiex/config.h @@ -30,6 +30,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  /* matrix size */  #define MATRIX_ROWS 8  #define MATRIX_COLS 15 +#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } +#define DIODE_DIRECTION COL2ROW  #define RGBLIGHT_ANIMATIONS diff --git a/keyboards/winkeyless/bminiex/matrix.c b/keyboards/winkeyless/bminiex/matrix.c deleted file mode 100644 index 8faaed8ac..000000000 --- a/keyboards/winkeyless/bminiex/matrix.c +++ /dev/null @@ -1,122 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" -#include "backlight.h" - -#ifndef DEBOUNCE -#define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -__attribute__ ((weak)) -void matrix_init_user(void) {} -__attribute__ ((weak)) -void matrix_scan_user(void) {} -__attribute__ ((weak)) -void matrix_init_kb(void) { -  matrix_init_user(); -} -__attribute__ ((weak)) -void matrix_scan_kb(void) { -  matrix_scan_user(); -} - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    DDRD &= ~(1<<PIND7); -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    PORTD |= (1<<PIND7); - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } -     -    matrix_init_quantum(); -} - -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ) | ( -            // col 14, PORTD 7 -            ((~PIND) & (1 << PIND7)) << 7 -        ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } - -    matrix_scan_quantum(); - -    return 1; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/winkeyless/bminiex/rules.mk b/keyboards/winkeyless/bminiex/rules.mk index 39a77bda1..2c999dcbf 100644 --- a/keyboards/winkeyless/bminiex/rules.mk +++ b/keyboards/winkeyless/bminiex/rules.mk @@ -29,6 +29,4 @@ SLEEP_LED_ENABLE = no    # Breathing sleep LED during USB suspend  OPT_DEFS = -DDEBUG_LEVEL=0 -# custom matrix setup -CUSTOM_MATRIX = yes -SRC = matrix.c backlight.c +SRC += backlight.c diff --git a/keyboards/ymd75/config.h b/keyboards/ymd75/config.h index a56a1b54b..00f6bd292 100644 --- a/keyboards/ymd75/config.h +++ b/keyboards/ymd75/config.h @@ -35,7 +35,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  /* matrix size */  #define MATRIX_ROWS 8  #define MATRIX_COLS 15 -#define DIODE_DIRECTION ROW2COL +#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 } +#define DIODE_DIRECTION COL2ROW  #define BACKLIGHT_LEVELS 12 diff --git a/keyboards/ymd75/matrix.c b/keyboards/ymd75/matrix.c deleted file mode 100644 index a726ee889..000000000 --- a/keyboards/ymd75/matrix.c +++ /dev/null @@ -1,108 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> -Modified 2018 by Wayne K Jones <github.com/WarmCatUK> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" - -#ifndef DEBOUNCE -#   define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    DDRD &= ~(1<<PIND7); -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    PORTD |= (1<<PIND7); - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } -    matrix_init_quantum();  // missing from original port by Luiz -} - -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ) | ( -                  // col 14, PORTD 7 -                  ((~PIND) & (1 << PIND7)) << 7 -                  ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } -    matrix_scan_quantum();  // also missing in original PS2AVRGB implementation -    //matrix_scan_user(); - -    return 1; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/ymd75/rules.mk b/keyboards/ymd75/rules.mk index 0c1c9110c..eb41e19cf 100644 --- a/keyboards/ymd75/rules.mk +++ b/keyboards/ymd75/rules.mk @@ -33,6 +33,4 @@ SLEEP_LED_ENABLE = no    # Breathing sleep LED during USB suspend  #OPT_DEFS = -DDEBUG_LEVEL=0 -# custom matrix setup -CUSTOM_MATRIX = yes -SRC = matrix.c backlight.c +SRC = backlight.c diff --git a/keyboards/ymd75/ymd75.c b/keyboards/ymd75/ymd75.c index 74f7c6a49..e32a745bf 100644 --- a/keyboards/ymd75/ymd75.c +++ b/keyboards/ymd75/ymd75.c @@ -20,16 +20,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "backlight.h"  #include "backlight_custom.h" -void matrix_init_kb(void) { matrix_init_user(); } - -__attribute__ ((weak)) -void matrix_init_user(void) {} - -void matrix_scan_kb(void) { matrix_scan_user(); } - -__attribute__ ((weak)) -void matrix_scan_user(void) {} -  #ifdef BACKLIGHT_ENABLE  /// Overrides functions in `quantum.c`  void backlight_init_ports(void) { diff --git a/keyboards/ymd75/ymd75.h b/keyboards/ymd75/ymd75.h index e17dedeb3..0c9fff58c 100644 --- a/keyboards/ymd75/ymd75.h +++ b/keyboards/ymd75/ymd75.h @@ -25,8 +25,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "keycode.h"  #include "action.h" -void matrix_init_user(void); -  #define LAYOUT( \  K05, K25, K35, K45, K55, K06, KA6, KA7, K07, KB5, KC5, KD5, KE5, KD1, KE1, KE2, \  K04, K14, K24, K34, K44, K54, K16, KB6, KB7, K17, KA4, KB4, KC4, KE4,      KD0, \ diff --git a/keyboards/ymd96/config.h b/keyboards/ymd96/config.h index 5c496d8d2..1232f90c2 100644 --- a/keyboards/ymd96/config.h +++ b/keyboards/ymd96/config.h @@ -31,7 +31,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  /* matrix size */  #define MATRIX_ROWS 8  #define MATRIX_COLS 15 -//#define DIODE_DIRECTION ROW2COL +#define MATRIX_ROW_PINS { B0, B1, B2, B3, B4, B5, B6, B7 } +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7 }  //#define RGB_DI_PIN C4  /* COL2ROW or ROW2COL */ diff --git a/keyboards/ymd96/matrix.c b/keyboards/ymd96/matrix.c deleted file mode 100644 index 2932976dd..000000000 --- a/keyboards/ymd96/matrix.c +++ /dev/null @@ -1,112 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" - -#ifndef DEBOUNCE -#   define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -void matrix_set_row_status(uint8_t row); -uint8_t bit_reverse(uint8_t x); - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    DDRD &= ~(1<<PIND7); -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    PORTD |= (1<<PIND7); - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } - -    matrix_init_quantum();  // missing from original port by Luiz -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ) | ( -            // col 14, PORTD 7 -            ((~PIND) & (1 << PIND7)) << 7 -        ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } - -    matrix_scan_quantum();  // also missing in original PS2AVRGB implementation - -    return 1; -} - -// declarations -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/ymd96/rules.mk b/keyboards/ymd96/rules.mk index 19d9fd81a..3c892daab 100644 --- a/keyboards/ymd96/rules.mk +++ b/keyboards/ymd96/rules.mk @@ -31,6 +31,4 @@ SLEEP_LED_ENABLE = no    # Breathing sleep LED during USB suspend  OPT_DEFS = -DDEBUG_LEVEL=0 -# custom matrix setup -CUSTOM_MATRIX = yes -SRC = matrix.c backlight.c +SRC = backlight.c diff --git a/keyboards/ymd96/ymd96.c b/keyboards/ymd96/ymd96.c index 546a4c6e3..eae84ade1 100644 --- a/keyboards/ymd96/ymd96.c +++ b/keyboards/ymd96/ymd96.c @@ -21,16 +21,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "backlight.h"  #include "backlight_custom.h" -void matrix_init_kb(void) { matrix_init_user(); } - -__attribute__ ((weak)) -void matrix_init_user(void) {} - -void matrix_scan_kb(void) { matrix_scan_user(); } - -__attribute__ ((weak)) -void matrix_scan_user(void) {} -  #ifdef BACKLIGHT_ENABLE  /// Overrides functions in `quantum.c`  void backlight_init_ports(void) { diff --git a/keyboards/ymd96/ymd96.h b/keyboards/ymd96/ymd96.h index a516297c1..c89be7168 100644 --- a/keyboards/ymd96/ymd96.h +++ b/keyboards/ymd96/ymd96.h @@ -20,8 +20,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "quantum.h" -void matrix_init_user(void);  // TODO port this to other PS2AVRGB boards -  #define LAYOUT_default( \      K50, K52, K53, K54, K55, K60, K6A, K7A, K70, K5B, K5C, K5D, K5E, K1D, K2E,   K0D, K76, K79, K78, \      K40, K41, K42, K43, K44, K45, K61, K6B, K7B, K71, K4A, K4B, K4C,      K4E,   K46, K47, K48, K49, \ diff --git a/keyboards/ymdk/bface/config.h b/keyboards/ymdk/bface/config.h index 9e5a9134f..2273b7e84 100644 --- a/keyboards/ymdk/bface/config.h +++ b/keyboards/ymdk/bface/config.h @@ -34,6 +34,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, D7}  #define UNUSED_PINS +#define DIODE_DIRECTION COL2ROW +  #define NO_UART 1  #define BACKLIGHT_PIN       D4 diff --git a/keyboards/ymdk/bface/rules.mk b/keyboards/ymdk/bface/rules.mk index 7b829530b..f6f026cf3 100644 --- a/keyboards/ymdk/bface/rules.mk +++ b/keyboards/ymdk/bface/rules.mk @@ -1,18 +1,3 @@ -# Copyright 2019 Ethan Durrant (emdarcher) -# -# 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 <http://www.gnu.org/licenses/>. -  # MCU name  MCU = atmega32a diff --git a/keyboards/ymdk_np21/config.h b/keyboards/ymdk_np21/config.h index 4a846f5e9..60c527776 100644 --- a/keyboards/ymdk_np21/config.h +++ b/keyboards/ymdk_np21/config.h @@ -29,8 +29,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #define PRODUCT         np21  /* matrix size */ -#define MATRIX_ROWS 8 -#define MATRIX_COLS 15 +#define MATRIX_ROWS 4 +#define MATRIX_COLS 6 +#define MATRIX_ROW_PINS { B0, B1, B2, B3 } +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5 }  /* COL2ROW or ROW2COL */  #define DIODE_DIRECTION COL2ROW diff --git a/keyboards/ymdk_np21/matrix.c b/keyboards/ymdk_np21/matrix.c deleted file mode 100644 index b2bfb2f0b..000000000 --- a/keyboards/ymdk_np21/matrix.c +++ /dev/null @@ -1,129 +0,0 @@ -/* -Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> - -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 <http://www.gnu.org/licenses/>. -*/ - -#include <avr/io.h> -#include <util/delay.h> - -#include "matrix.h" - -#ifndef DEBOUNCE -#   define DEBOUNCE	5 -#endif - -static uint8_t debouncing = DEBOUNCE; - -static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; - -void matrix_set_row_status(uint8_t row); -uint8_t bit_reverse(uint8_t x); - -void matrix_init(void) { -    // all outputs for rows high -    DDRB = 0xFF; -    PORTB = 0xFF; -    // all inputs for columns -    DDRA = 0x00; -    DDRC &= ~(0x111111<<2); -    DDRD &= ~(1<<PIND7); -    // all columns are pulled-up -    PORTA = 0xFF; -    PORTC |= (0b111111<<2); -    PORTD |= (1<<PIND7); - -    // initialize matrix state: all keys off -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix[row] = 0x00; -        matrix_debouncing[row] = 0x00; -    } - -    matrix_init_quantum();  // missing from original port by Luiz -} - -uint8_t matrix_scan(void) { -    for (uint8_t row = 0; row < MATRIX_ROWS; row++) { -        matrix_set_row_status(row); -        _delay_us(5); - -        matrix_row_t cols = ( -            // cols 0..7, PORTA 0 -> 7 -            (~PINA) & 0xFF -        ) | ( -            // cols 8..13, PORTC 7 -> 0 -            bit_reverse((~PINC) & 0xFF) << 8 -        ) | ( -            // col 14, PORTD 7 -            ((~PIND) & (1 << PIND7)) << 7 -        ); - -        if (matrix_debouncing[row] != cols) { -            matrix_debouncing[row] = cols; -            debouncing = DEBOUNCE; -        } -    } - -    if (debouncing) { -        if (--debouncing) { -            _delay_ms(1); -        } else { -            for (uint8_t i = 0; i < MATRIX_ROWS; i++) { -                matrix[i] = matrix_debouncing[i]; -            } -        } -    } - -    matrix_scan_quantum();  // also missing in original PS2AVRGB implementation - -    return 1; -} - -__attribute__ ((weak)) -void matrix_scan_user(void) {}; - -__attribute__ ((weak)) -void matrix_scan_kb(void) { -  // Looping keyboard code goes here -  // This runs every cycle (a lot) -  matrix_scan_user(); -}; - -__attribute__ ((weak)) -void matrix_init_user(void) {}; - -__attribute__ ((weak)) -void matrix_init_kb(void) { -  matrix_init_user(); -} -// declarations -void matrix_set_row_status(uint8_t row) { -    DDRB = (1 << row); -    PORTB = ~(1 << row); -} - -uint8_t bit_reverse(uint8_t x) { -    x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); -    x = ((x >> 2) & 0x33) | ((x << 2) & 0xcc); -    x = ((x >> 4) & 0x0f) | ((x << 4) & 0xf0); -    return x; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { -    return matrix[row]; -} - -void matrix_print(void) { -} diff --git a/keyboards/ymdk_np21/rules.mk b/keyboards/ymdk_np21/rules.mk index 2bab3043e..772bee928 100644 --- a/keyboards/ymdk_np21/rules.mk +++ b/keyboards/ymdk_np21/rules.mk @@ -31,6 +31,4 @@ SLEEP_LED_ENABLE = no    # Breathing sleep LED during USB suspend  OPT_DEFS = -DDEBUG_LEVEL=0 -# custom matrix setup -CUSTOM_MATRIX = yes -SRC = matrix.c backlight.c +SRC = backlight.c diff --git a/keyboards/ymdk_np21/ymdk_np21.h b/keyboards/ymdk_np21/ymdk_np21.h index 728406d6e..2cd2d13c2 100644 --- a/keyboards/ymdk_np21/ymdk_np21.h +++ b/keyboards/ymdk_np21/ymdk_np21.h @@ -23,8 +23,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #include "keycode.h"  #include "action.h" -void matrix_init_user(void);  // TODO port this to other PS2AVRGB boards -  #define LAYOUT( \      K01, K02, K03, K04, K05, K06, \      K11, K12, K13, K14, K15, K16, \ | 
