2 Copyright 2016 Jun Wako <wakojun@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 __attribute__ ((weak))
22 uint8_t matrix_rows(void)
27 __attribute__ ((weak))
28 uint8_t matrix_cols(void)
33 __attribute__ ((weak))
34 void matrix_clear(void)
38 __attribute__ ((weak))
39 void matrix_setup(void) {}
41 __attribute__ ((weak))
42 bool matrix_is_on(uint8_t row, uint8_t col)
44 return (matrix_get_row(row) & (1<<col));
47 __attribute__ ((weak))
48 void matrix_print(void)
50 #if (MATRIX_COLS <= 8)
51 print("r/c 01234567\n");
52 #elif (MATRIX_COLS <= 16)
53 print("r/c 0123456789ABCDEF\n");
54 #elif (MATRIX_COLS <= 32)
55 print("r/c 0123456789ABCDEF0123456789ABCDEF\n");
58 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
60 #if (MATRIX_COLS <= 8)
61 xprintf("%02X: %08b%s\n", row, bitrev(matrix_get_row(row)),
62 #elif (MATRIX_COLS <= 16)
63 xprintf("%02X: %016b%s\n", row, bitrev16(matrix_get_row(row)),
64 #elif (MATRIX_COLS <= 32)
65 xprintf("%02X: %032b%s\n", row, bitrev32(matrix_get_row(row)),
67 #ifdef MATRIX_HAS_GHOST
68 matrix_has_ghost_in_row(row) ? " <ghost" : ""
76 #ifdef MATRIX_HAS_GHOST
77 __attribute__ ((weak))
78 bool matrix_has_ghost_in_row(uint8_t row)
80 matrix_row_t matrix_row = matrix_get_row(row);
81 // No ghost exists when less than 2 keys are down on the row
82 if (((matrix_row - 1) & matrix_row) == 0)
85 // Ghost occurs when the row shares column line with other row
86 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
87 if (i != row && (matrix_get_row(i) & matrix_row))
94 __attribute__ ((weak)) void matrix_power_up(void) {}
95 __attribute__ ((weak)) void matrix_power_down(void) {}