]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/clueboard/66/rev3/rev3.c
Clueboard refresh (#4902)
[qmk_firmware.git] / keyboards / clueboard / 66 / rev3 / rev3.c
1 #include "rev3.h"
2 #include <avr/io.h>
3 #include "backlight.h"
4 #include "print.h"
5
6 void matrix_init_kb(void) {
7     // put your keyboard start-up code here
8     // runs once when the firmware starts up
9     matrix_init_user();
10     led_init_ports();
11 }
12
13
14 void matrix_scan_kb(void) {
15     matrix_scan_user();
16 }
17
18 void backlight_init_ports(void) {
19     print("init_backlight_pin()\n");
20     // Set our LED pins as output
21     DDRD |= (1<<6); // Esc
22     DDRB |= (1<<7); // Page Up
23     DDRD |= (1<<4); // Arrows
24
25     // Set our LED pins low
26     PORTD &= ~(1<<6); // Esc
27     PORTB &= ~(1<<7); // Page Up
28     PORTD &= ~(1<<4); // Arrows
29 }
30
31 void backlight_set(uint8_t level) {
32     if ( level == 0 ) {
33         // Turn off light
34         PORTD |= (1<<6); // Esc
35         PORTB |= (1<<7); // Page Up
36         PORTD |= (1<<4); // Arrows
37     } else {
38         // Turn on light
39         PORTD &= ~(1<<6); // Esc
40         PORTB &= ~(1<<7); // Page Up
41         PORTD &= ~(1<<4); // Arrows
42     }
43 }
44
45 void led_init_ports() {
46     // * Set our LED pins as output
47     DDRB |= (1<<4);
48 }
49
50 void led_set_kb(uint8_t usb_led) {
51     DDRB |= (1<<4);
52     if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
53         // Turn capslock on
54         PORTB |= (1<<4);
55     } else {
56         // Turn capslock off
57         PORTB &= ~(1<<4);
58     }
59 }