]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/clueboard2/clueboard2.c
Backlight abstraction and other changes (#439)
[qmk_firmware.git] / keyboards / clueboard2 / clueboard2.c
1 #include "clueboard2.h"
2
3 void matrix_init_kb(void) {
4         // put your keyboard start-up code here
5         // runs once when the firmware starts up
6         matrix_init_user();
7         led_init_ports();
8
9     // JTAG disable for PORT F. write JTD bit twice within four cycles.
10     MCUCR |= (1<<JTD);
11     MCUCR |= (1<<JTD);
12 };
13
14 void led_init_ports() {
15     // * Set our LED pins as output
16     DDRB |= (1<<4);
17 }
18
19 void led_set_kb(uint8_t usb_led) {
20     if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
21         // Turn capslock on
22         PORTB |= (1<<4);
23     } else {
24         // Turn capslock off
25         PORTB &= ~(1<<4);
26     }
27 }
28
29 /* Clueboard 2.0 LED locations:
30  *
31  * Capslock: B4, pull high to turn on
32  * LCtrl: Shared with Capslock, DO NOT INSTALL LED'S IN BOTH
33  * Page Up: B7, pull high to turn on
34  * Escape: D6, pull high to turn on
35  * Arrows: D4, pull high to turn on
36  */
37
38 void backlight_init_ports(void) {
39     print("init_backlight_pin()\n");
40     // Set our LED pins as output
41     DDRD |= (1<<6); // Esc
42     DDRB |= (1<<7); // Page Up
43     DDRD |= (1<<4); // Arrows
44
45     // Set our LED pins low
46     PORTD &= ~(1<<6); // Esc
47     PORTB &= ~(1<<7); // Page Up
48     PORTD &= ~(1<<4); // Arrows
49 }
50
51 void backlight_set(uint8_t level) {
52     if ( level == 0 ) {
53         // Turn off light
54         PORTD |= (1<<6); // Esc
55         PORTB |= (1<<7); // Page Up
56         PORTD |= (1<<4); // Arrows
57     } else {
58         // Turn on light
59         PORTD &= ~(1<<6); // Esc
60         PORTB &= ~(1<<7); // Page Up
61         PORTD &= ~(1<<4); // Arrows
62     }
63 }