aboutsummaryrefslogtreecommitdiff
path: root/keyboards/duck/octagon/v1/v1.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/duck/octagon/v1/v1.c')
-rw-r--r--keyboards/duck/octagon/v1/v1.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/keyboards/duck/octagon/v1/v1.c b/keyboards/duck/octagon/v1/v1.c
new file mode 100644
index 000000000..e9e88c70d
--- /dev/null
+++ b/keyboards/duck/octagon/v1/v1.c
@@ -0,0 +1,46 @@
1/* Copyright 2017 MechMerlin <[email protected]>
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 "v1.h"
17
18enum BACKLIGHT_AREAS {
19 BACKLIGHT_ALPHA = 0b0000001,
20 BACKLIGHT_EXTRA = 0b0000010,
21 BACKLIGHT_MODNUM = 0b0000100,
22 BACKLIGHT_FROW = 0b0001000,
23 BACKLIGHT_RGB = 0b0010000,
24 BACKLIGHT_RGBRED = 0b0010000,
25 BACKLIGHT_RGBGREEN = 0b0100000,
26 BACKLIGHT_RGBBLUE = 0b1000000,
27 BACKLIGHT_SWITCH = 0b0001111
28};
29
30uint8_t backlight_os_state = 0;
31uint32_t backlight_layer_state = 0;
32
33void backlight_set(uint8_t level) {
34 level & BACKLIGHT_ALPHA ? (PORTB |= 0b00000010) : (PORTB &= ~0b00000010);
35 level & BACKLIGHT_EXTRA ? (PORTB |= 0b00000100) : (PORTB &= ~0b00000100);
36 level & BACKLIGHT_MODNUM ? (PORTB |= 0b00001000) : (PORTB &= ~0b00001000);
37 level & BACKLIGHT_FROW ? (PORTE |= 0b01000000) : (PORTE &= ~0b01000000);
38 level & BACKLIGHT_RGBRED ? (PORTD |= 0b01000000) : (PORTD &= ~0b01000000);
39 level & BACKLIGHT_RGBGREEN ? (PORTD |= 0b10000000) : (PORTD &= ~0b10000000);
40 level & BACKLIGHT_RGBBLUE ? (PORTD |= 0b00010000) : (PORTD &= ~0b00010000);
41}
42
43void led_set_kb(uint8_t usb_led) {
44 backlight_os_state & (1<<USB_LED_CAPS_LOCK) ? (PORTB &= ~0b00000001) : (PORTB |= 0b00000001);
45 backlight_os_state & (1<<USB_LED_SCROLL_LOCK) ? (PORTB &= ~0b00010000) : (PORTB |= 0b00010000);
46}