diff options
author | Joel Challis <git@zvecr.com> | 2021-02-07 23:16:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-07 23:16:15 +0000 |
commit | 99bffc2a21ebed07fd767ad2a9a7e1aadd491ef3 (patch) | |
tree | 499edfaa4b2a180047f7ca5f6bc882e77f5262fa /quantum/matrix.h | |
parent | 7e828795534f7351df54d2c0545b2ed159b1bfde (diff) | |
download | qmk_firmware-99bffc2a21ebed07fd767ad2a9a7e1aadd491ef3.tar.gz qmk_firmware-99bffc2a21ebed07fd767ad2a9a7e1aadd491ef3.zip |
Migrate some tmk_core files to quantum (#11791)
* Migrate some tmk_core files to quantum
* Fix build errors
Diffstat (limited to 'quantum/matrix.h')
-rw-r--r-- | quantum/matrix.h | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/quantum/matrix.h b/quantum/matrix.h new file mode 100644 index 000000000..b570227a3 --- /dev/null +++ b/quantum/matrix.h | |||
@@ -0,0 +1,76 @@ | |||
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 | #pragma once | ||
19 | |||
20 | #include <stdint.h> | ||
21 | #include <stdbool.h> | ||
22 | |||
23 | #if (MATRIX_COLS <= 8) | ||
24 | typedef uint8_t matrix_row_t; | ||
25 | #elif (MATRIX_COLS <= 16) | ||
26 | typedef uint16_t matrix_row_t; | ||
27 | #elif (MATRIX_COLS <= 32) | ||
28 | typedef uint32_t matrix_row_t; | ||
29 | #else | ||
30 | # error "MATRIX_COLS: invalid value" | ||
31 | #endif | ||
32 | |||
33 | #define MATRIX_ROW_SHIFTER ((matrix_row_t)1) | ||
34 | |||
35 | #ifdef __cplusplus | ||
36 | extern "C" { | ||
37 | #endif | ||
38 | |||
39 | /* number of matrix rows */ | ||
40 | uint8_t matrix_rows(void); | ||
41 | /* number of matrix columns */ | ||
42 | uint8_t matrix_cols(void); | ||
43 | /* should be called at early stage of startup before matrix_init.(optional) */ | ||
44 | void matrix_setup(void); | ||
45 | /* intialize matrix for scaning. */ | ||
46 | void matrix_init(void); | ||
47 | /* scan all key states on matrix */ | ||
48 | uint8_t matrix_scan(void); | ||
49 | /* whether modified from previous scan. used after matrix_scan. */ | ||
50 | bool matrix_is_modified(void) __attribute__((deprecated)); | ||
51 | /* whether a switch is on */ | ||
52 | bool matrix_is_on(uint8_t row, uint8_t col); | ||
53 | /* matrix state on row */ | ||
54 | matrix_row_t matrix_get_row(uint8_t row); | ||
55 | /* print matrix for debug */ | ||
56 | void matrix_print(void); | ||
57 | /* delay between changing matrix pin state and reading values */ | ||
58 | void matrix_io_delay(void); | ||
59 | |||
60 | /* power control */ | ||
61 | void matrix_power_up(void); | ||
62 | void matrix_power_down(void); | ||
63 | |||
64 | /* executes code for Quantum */ | ||
65 | void matrix_init_quantum(void); | ||
66 | void matrix_scan_quantum(void); | ||
67 | |||
68 | void matrix_init_kb(void); | ||
69 | void matrix_scan_kb(void); | ||
70 | |||
71 | void matrix_init_user(void); | ||
72 | void matrix_scan_user(void); | ||
73 | |||
74 | #ifdef __cplusplus | ||
75 | } | ||
76 | #endif | ||