diff options
| author | tmk <nobody@nowhere> | 2012-10-06 02:23:12 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2012-10-17 15:55:37 +0900 |
| commit | 4ae979f6ef8dbf9e1d1f35be15322ad6d02e2958 (patch) | |
| tree | 9f5132005c27ef04ae793b77d4699cb285479466 /common/matrix.h | |
| parent | 93e33fb8f694c9685accd72ed0458a2cf3d3f04a (diff) | |
| download | qmk_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.h | 21 |
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) | ||
| 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 | |||
| 23 | /* number of matrix rows */ | 38 | /* number of matrix rows */ |
| 24 | uint8_t matrix_rows(void); | 39 | uint8_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 */ |
| 36 | bool matrix_is_on(uint8_t row, uint8_t col); | 51 | bool matrix_is_on(uint8_t row, uint8_t col); |
| 37 | /* matrix state on row */ | 52 | /* matrix state on row */ |
| 38 | #if (MATRIX_COLS <= 8) | 53 | matrix_row_t matrix_get_row(uint8_t row); |
| 39 | uint8_t matrix_get_row(uint8_t row); | ||
| 40 | #else | ||
| 41 | uint16_t matrix_get_row(uint8_t row); | ||
| 42 | #endif | ||
| 43 | /* count keys pressed */ | 54 | /* count keys pressed */ |
| 44 | uint8_t matrix_key_count(void); | 55 | uint8_t matrix_key_count(void); |
| 45 | /* print matrix for debug */ | 56 | /* print matrix for debug */ |
