]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/tmo50/tmo50.c
Add user-overridable callback for cancelling UCIS input (#5564)
[qmk_firmware.git] / keyboards / tmo50 / tmo50.c
1 /* Copyright 2019 funderburker
2  *
3  * This program is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16 #include "tmo50.h"
17
18 void matrix_init_kb(void) {
19         // put your keyboard start-up code here
20         // runs once when the firmware starts up
21
22   DDRB |= (1 << PB0); //init B0
23   PORTB &= ~(1 << PB0); //turn on B0
24   DDRB |= (1 << PB1);
25   PORTB |= (1<<PB1); //turn off B1
26   DDRB |= (1 << PB2);
27   PORTB |= (1<<PB2);
28   DDRB |= (1 << PB3);
29   PORTB |= (1<<PB3);
30
31         matrix_init_user();
32 }
33
34 void matrix_scan_kb(void) {
35         // put your looping keyboard code here
36         // runs every cycle (a lot)
37
38         matrix_scan_user();
39 }
40
41 bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
42         // put your per-action keyboard code here
43         // runs for every action, just before processing by the firmware
44
45         return process_record_user(keycode, record);
46 }
47
48 void led_set_kb(uint8_t usb_led) {
49         // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
50
51         led_set_user(usb_led);
52 }
53
54 uint32_t layer_state_set_user(uint32_t state)
55 {
56   // if on layer 0, turn on B0 LED, otherwise off.
57     if (biton32(state) == 0) {
58         PORTB &= ~(1<<PB0);
59     } else {
60         PORTB |= (1<<PB0);
61     }
62
63   // if on layer 1, turn on B1 LED, otherwise off.
64     if (biton32(state) == 1) {
65         PORTB &= ~(1<<PB1);
66     } else {
67         PORTB |= (1<<PB1);
68     }
69   // if on layer 2, turn on B2 LED, otherwise off.
70     if (biton32(state) == 2) {
71         PORTB &= ~(1<<PB2);
72     } else {
73         PORTB |= (1<<PB2);
74     }
75
76   // if on layer 3, turn on B3 LED, otherwise off.
77     if (biton32(state) == 3) {
78         PORTB &= ~(1<<PB3);
79     } else {
80         PORTB |= (1<<PB3);
81     }
82
83     return state;
84 }