aboutsummaryrefslogtreecommitdiff
path: root/common/matrix.h
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2012-10-06 02:23:12 +0900
committertmk <nobody@nowhere>2012-10-17 15:55:37 +0900
commit4ae979f6ef8dbf9e1d1f35be15322ad6d02e2958 (patch)
tree9f5132005c27ef04ae793b77d4699cb285479466 /common/matrix.h
parent93e33fb8f694c9685accd72ed0458a2cf3d3f04a (diff)
downloadqmk_firmware-4ae979f6ef8dbf9e1d1f35be15322ad6d02e2958.tar.gz
qmk_firmware-4ae979f6ef8dbf9e1d1f35be15322ad6d02e2958.zip
Initial version of new code for layer switch is added.
Diffstat (limited to 'common/matrix.h')
-rw-r--r--common/matrix.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/common/matrix.h b/common/matrix.h
index c4b2cab51..b3332d5ff 100644
--- a/common/matrix.h
+++ b/common/matrix.h
@@ -18,8 +18,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18#ifndef MATRIX_H 18#ifndef MATRIX_H
19#define MATRIX_H 19#define MATRIX_H
20 20
21#include <stdint.h>
21#include <stdbool.h> 22#include <stdbool.h>
22 23
24
25#if (MATRIX_COLS <= 8)
26typedef uint8_t matrix_row_t;
27#elif (MATRIX_COLS <= 16)
28typedef uint16_t matrix_row_t;
29#elif (MATRIX_COLS <= 32)
30typedef 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
23/* number of matrix rows */ 38/* number of matrix rows */
24uint8_t matrix_rows(void); 39uint8_t matrix_rows(void);
25/* number of matrix columns */ 40/* number of matrix columns */
@@ -35,11 +50,7 @@ bool matrix_has_ghost(void);
35/* whether a swtich is on */ 50/* whether a swtich is on */
36bool matrix_is_on(uint8_t row, uint8_t col); 51bool matrix_is_on(uint8_t row, uint8_t col);
37/* matrix state on row */ 52/* matrix state on row */
38#if (MATRIX_COLS <= 8) 53matrix_row_t matrix_get_row(uint8_t row);
39uint8_t matrix_get_row(uint8_t row);
40#else
41uint16_t matrix_get_row(uint8_t row);
42#endif
43/* count keys pressed */ 54/* count keys pressed */
44uint8_t matrix_key_count(void); 55uint8_t matrix_key_count(void);
45/* print matrix for debug */ 56/* print matrix for debug */