]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/handwired/xealous/matrix.c
[Keyboard] Add QMK configurator JSON for Alice PCB (#6397)
[qmk_firmware.git] / keyboards / handwired / xealous / matrix.c
1 /*
2 Copyright 2012 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 /*
19  * scan matrix
20  */
21 #include <stdint.h>
22 #include <stdbool.h>
23 #include <avr/io.h>
24 #include "wait.h"
25 #include "print.h"
26 #include "debug.h"
27 #include "util.h"
28 #include "matrix.h"
29 #include "split_util.h"
30 #include "pro_micro.h"
31 #include "config.h"
32 #include "timer.h"
33 #ifdef DEBUG_MATRIX_SCAN_RATE
34     #include "matrix_scanrate.h"
35 #endif
36
37 void matrix_scan_user(void)
38 {    
39 #ifdef DEBUG_MATRIX_SCAN_RATE
40     matrix_check_scan_rate();
41     matrix_time_between_scans();
42 #endif        
43     
44 }
45
46 // Copy this code to split_common/matrix.c,
47 // and call it instead of the unoptimized col_reader. Scan-rate jumps from 1200->1920
48 // Also remove the sleep_us(30), not necessary for this keyboard.
49 // In usb_descriptor.c, set .PollingIntervalMS      = 0x01
50 #define ROW_SHIFTER ((uint8_t)1)
51 inline static matrix_row_t optimized_col_reader(void) {
52     //MATRIX_COL_PINS { B6, B2, B3, B1, F7, F6, F5, F4 }
53     return (PINB & (1 << 6) ? 0 : (ROW_SHIFTER << 0)) |
54           (PINB & (1 << 2) ? 0 : (ROW_SHIFTER << 1)) |
55           (PINB & (1 << 3) ? 0 : (ROW_SHIFTER << 2)) |
56           (PINB & (1 << 1) ? 0 : (ROW_SHIFTER << 3)) |
57           (PINF & (1 << 7) ? 0 : (ROW_SHIFTER << 4)) |
58           (PINF & (1 << 6) ? 0 : (ROW_SHIFTER << 5)) |
59           (PINF & (1 << 5) ? 0 : (ROW_SHIFTER << 6)) |
60           (PINF & (1 << 4) ? 0 : (ROW_SHIFTER << 7));
61 }
62
63