diff options
Diffstat (limited to 'keyboards/kmac/kmac.c')
-rw-r--r-- | keyboards/kmac/kmac.c | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/keyboards/kmac/kmac.c b/keyboards/kmac/kmac.c index 6b54294b4..dcbbc2f17 100644 --- a/keyboards/kmac/kmac.c +++ b/keyboards/kmac/kmac.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* Copyright 2017 Mathias Andersson <wraul@dbox.se> | 1 | /* Copyright 2017-2019 Mathias Andersson <wraul@dbox.se> |
2 | * | 2 | * |
3 | * This program is free software: you can redistribute it and/or modify | 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 | 4 | * it under the terms of the GNU General Public License as published by |
@@ -15,61 +15,68 @@ | |||
15 | */ | 15 | */ |
16 | #include "kmac.h" | 16 | #include "kmac.h" |
17 | 17 | ||
18 | #define CAPS_PIN B0 | ||
19 | #define SCROLL_PIN E6 | ||
20 | #define F_ROW_MASK 0b01 | ||
21 | #define WASD_MASK 0b10 | ||
22 | |||
23 | // Optional override functions below. | ||
24 | // You can leave any or all of these undefined. | ||
25 | // These are only required if you want to perform custom actions. | ||
26 | |||
18 | void matrix_init_kb(void) { | 27 | void matrix_init_kb(void) { |
19 | // put your keyboard start-up code here | 28 | // put your keyboard start-up code here |
20 | // runs once when the firmware starts up | 29 | // runs once when the firmware starts up |
21 | led_init_ports(); | 30 | setPinOutput(CAPS_PIN); |
31 | setPinOutput(SCROLL_PIN); | ||
32 | |||
22 | matrix_init_user(); | 33 | matrix_init_user(); |
23 | } | 34 | } |
24 | 35 | ||
36 | /* | ||
37 | |||
25 | void matrix_scan_kb(void) { | 38 | void matrix_scan_kb(void) { |
26 | // put your looping keyboard code here | 39 | // put your looping keyboard code here |
27 | // runs every cycle (a lot) | 40 | // runs every cycle (a lot) |
28 | 41 | ||
29 | matrix_scan_user(); | 42 | matrix_scan_user(); |
30 | } | 43 | } |
31 | 44 | ||
32 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | 45 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { |
33 | // put your per-action keyboard code here | 46 | // put your per-action keyboard code here |
34 | // runs for every action, just before processing by the firmware | 47 | // runs for every action, just before processing by the firmware |
35 | 48 | ||
36 | return process_record_user(keycode, record); | 49 | return process_record_user(keycode, record); |
37 | } | 50 | } |
38 | 51 | ||
39 | void led_init_ports(void) { | 52 | */ |
40 | DDRB |= (1<<0); // OUT | ||
41 | DDRE |= (1<<6); // OUT | ||
42 | } | ||
43 | 53 | ||
44 | /* LED pin configuration | 54 | /* LED pin configuration |
45 | * Scroll Lock: Low PE6 | 55 | * Scroll Lock: Low PE6 |
46 | * Caps Lock: Low PB0 | 56 | * Caps Lock: Low PB0 |
47 | */ | 57 | */ |
48 | void led_set_kb(uint8_t usb_led) { | 58 | void led_set_kb(uint8_t usb_led) { |
49 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) | 59 | if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) { |
50 | { | 60 | writePinLow(CAPS_PIN); |
51 | PORTB &= ~(1<<0); // LO | 61 | } else { |
52 | } | 62 | writePinHigh(CAPS_PIN); |
53 | else | ||
54 | { | ||
55 | PORTB |= (1<<0); // HI | ||
56 | } | 63 | } |
57 | 64 | ||
58 | if (usb_led & (1<<USB_LED_SCROLL_LOCK)) | 65 | if (IS_LED_ON(usb_led, USB_LED_SCROLL_LOCK)) { |
59 | { | 66 | writePinLow(SCROLL_PIN); |
60 | PORTE &= ~(1<<6); // LO | 67 | } else { |
61 | } | 68 | writePinHigh(SCROLL_PIN); |
62 | else | ||
63 | { | ||
64 | PORTE |= (1<<6); // HI | ||
65 | } | 69 | } |
66 | 70 | ||
67 | led_set_user(usb_led); | 71 | led_set_user(usb_led); |
68 | } | 72 | } |
69 | 73 | ||
70 | void backlight_init_ports(void) { | 74 | void backlight_init_ports(void) { |
71 | DDRB |= (1<<1) | (1<<2) | (1<<3) | (1<<4); // OUT | 75 | setPinOutput(B1); |
72 | DDRD |= (1<<7); // OUT | 76 | setPinOutput(B2); |
77 | setPinOutput(B3); | ||
78 | setPinOutput(B4); | ||
79 | setPinOutput(D7); | ||
73 | } | 80 | } |
74 | 81 | ||
75 | /* Backlight pin configuration | 82 | /* Backlight pin configuration |
@@ -79,31 +86,24 @@ void backlight_init_ports(void) { | |||
79 | * S: Low PB3 | 86 | * S: Low PB3 |
80 | * D: Low PD7 | 87 | * D: Low PD7 |
81 | */ | 88 | */ |
82 | void backlight_set(uint8_t level) | 89 | void backlight_set(uint8_t level) { |
83 | { | ||
84 | // F-row | 90 | // F-row |
85 | if(level & (1<<0)) | 91 | if (level & F_ROW_MASK) { |
86 | { | 92 | writePinHigh(B1); |
87 | PORTB |= (1<<1); // HI | 93 | } else { |
88 | } | 94 | writePinLow(B1); |
89 | else | ||
90 | { | ||
91 | PORTB &= ~(1<<1); // LO | ||
92 | } | 95 | } |
93 | 96 | ||
94 | // WASD | 97 | // WASD |
95 | if(level & (1<<1)) | 98 | if (level & WASD_MASK) { |
96 | { | 99 | writePinLow(B2); |
97 | PORTB &= ~(1<<4); // LO | 100 | writePinLow(B3); |
98 | PORTB &= ~(1<<2); // LO | 101 | writePinLow(B4); |
99 | PORTB &= ~(1<<3); // LO | 102 | writePinLow(D7); |
100 | PORTD &= ~(1<<7); // LO | 103 | } else { |
101 | } | 104 | writePinHigh(B2); |
102 | else | 105 | writePinHigh(B3); |
103 | { | 106 | writePinHigh(B4); |
104 | PORTB |= (1<<4); // HI | 107 | writePinHigh(D7); |
105 | PORTB |= (1<<2); // HI | ||
106 | PORTB |= (1<<3); // HI | ||
107 | PORTD |= (1<<7); // HI | ||
108 | } | 108 | } |
109 | } | 109 | } |