]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboard/nerd/backlight.c
Added NerD 60% support
[qmk_firmware.git] / keyboard / nerd / backlight.c
1 /*
2 Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
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 #include <avr/io.h>
19 #include "backlight.h"
20
21 void backlight_init_ports()
22 {
23     DDRB |= 0b11100000; // PB7 (switch), PB6 (pcb), PB5 (caps)
24 }
25
26 void backlight_set(uint8_t level)
27 {
28     (level & BACKLIGHT_SWITCH) ? backlight_switch_enable() : backlight_switch_disable();
29     (level & BACKLIGHT_PCB) ? backlight_pcb_enable() : backlight_pcb_disable();
30 }
31
32 void backlight_switch_enable()
33 {
34     PORTB |= 0b10000000;
35 }
36
37 void backlight_switch_disable()
38 {
39     PORTB &= ~0b10000000;
40 }
41
42 void backlight_switch_invert()
43 {
44     PORTB ^= 0b10000000;
45 }
46
47 void backlight_pcb_enable()
48 {
49     PORTB |= 0b01000000;
50 }
51
52 void backlight_pcb_disable()
53 {
54     PORTB &= ~0b01000000;
55 }
56
57 void backlight_pcb_invert()
58 {
59     PORTB ^= 0b01000000;
60 }
61
62 void backlight_caps_enable()
63 {
64     PORTB |= 0b00100000;
65 }
66
67 void backlight_caps_disable()
68 {
69     PORTB &= ~0b00100000;
70 }
71
72 void backlight_caps_invert()
73 {
74     PORTB ^= 0b00100000;
75 }