]> git.gir.st - tmk_keyboard.git/blob - common/matrix.h
Update other_projects.md - added TMK/Ergodox
[tmk_keyboard.git] / common / matrix.h
1 /*
2 Copyright 2011 Jun Wako <wakojun@gmail.com>
3
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.
8
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.
13
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/>.
16 */
17
18 #ifndef MATRIX_H
19 #define MATRIX_H
20
21 #include <stdint.h>
22 #include <stdbool.h>
23
24
25 #if (MATRIX_COLS <= 8)
26 typedef uint8_t matrix_row_t;
27 #elif (MATRIX_COLS <= 16)
28 typedef uint16_t matrix_row_t;
29 #elif (MATRIX_COLS <= 32)
30 typedef uint32_t matrix_row_t;
31 #else
32 #error "MATRIX_COLS: invalid value"
33 #endif
34
35 #define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1<<col))
36
37
38 /* number of matrix rows */
39 uint8_t matrix_rows(void);
40 /* number of matrix columns */
41 uint8_t matrix_cols(void);
42 /* intialize matrix for scaning. should be called once. */
43 void matrix_init(void);
44 /* scan all key states on matrix */
45 uint8_t matrix_scan(void);
46 /* whether modified from previous scan. used after matrix_scan. */
47 bool matrix_is_modified(void) __attribute__ ((deprecated));
48 /* whether a swtich is on */
49 bool matrix_is_on(uint8_t row, uint8_t col);
50 /* matrix state on row */
51 matrix_row_t matrix_get_row(uint8_t row);
52 /* print matrix for debug */
53 void matrix_print(void);
54
55
56 /* power control */
57 void matrix_power_up(void);
58 void matrix_power_down(void);
59
60
61 #endif
Imprint / Impressum