]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/dumbpad/dumbpad.c
[Keymap] dumbpad updates, new keymap (#6481)
[qmk_firmware.git] / keyboards / dumbpad / dumbpad.c
1 /* Copyright 2019 Chip
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 "dumbpad.h"
17
18 void keyboard_pre_init_kb(void) {
19   // Set the layer LED IO as outputs
20   setPinOutput(LAYER_INDICATOR_LED_0);
21   setPinOutput(LAYER_INDICATOR_LED_1);
22   
23   keyboard_pre_init_user();
24 }
25
26 void shutdown_user() {
27   // Shutdown the layer LEDs
28   writePinLow(LAYER_INDICATOR_LED_0);
29   writePinLow(LAYER_INDICATOR_LED_1);
30 }
31
32 layer_state_t layer_state_set_kb(layer_state_t state) {
33   // Layer LEDs act as binary indication of current layer
34   uint8_t layer = biton32(state);
35   writePin(LAYER_INDICATOR_LED_0, layer & 0b1);
36   writePin(LAYER_INDICATOR_LED_1, (layer >> 1) & 0b1);
37   return layer_state_set_user(state);
38 }
39
40 // Optional override functions below.
41 // You can leave any or all of these undefined.
42 // These are only required if you want to perform custom actions.
43
44 void matrix_init_kb(void) {
45   // put your keyboard start-up code here
46   // runs once when the firmware starts up
47   for (int i = 0; i < 2; i++) {
48     writePin(LAYER_INDICATOR_LED_0, true);
49     writePin(LAYER_INDICATOR_LED_1, false);
50     wait_ms(100);
51     writePin(LAYER_INDICATOR_LED_0, true);
52     writePin(LAYER_INDICATOR_LED_1, true);
53     wait_ms(100);
54     writePin(LAYER_INDICATOR_LED_0, false);
55     writePin(LAYER_INDICATOR_LED_1, true);
56     wait_ms(100);
57     writePin(LAYER_INDICATOR_LED_0, false);
58     writePin(LAYER_INDICATOR_LED_1, false);
59     wait_ms(100);
60   }
61
62   matrix_init_user();
63 }
64
65 void matrix_scan_kb(void) {
66   // put your looping keyboard code here
67   // runs every cycle (a lot)
68
69   matrix_scan_user();
70 }
71
72 bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
73   // put your per-action keyboard code here
74   // runs for every action, just before processing by the firmware
75
76   return process_record_user(keycode, record);
77 }
78
79 void led_set_kb(uint8_t usb_led) {
80   // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
81
82   led_set_user(usb_led);
83 }