]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/clueboard_17/clueboard_17.c
Clueboard 60% support (#1746)
[qmk_firmware.git] / keyboards / clueboard_17 / clueboard_17.c
1 #include "clueboard_17.h"
2
3 int pwm_level;
4
5 void matrix_init_kb(void) {
6     // put your keyboard start-up code here
7     // runs once when the firmware starts up
8     matrix_init_user();
9
10     // JTAG disable for PORT F. write JTD bit twice within four cycles.
11     MCUCR |= (1<<JTD);
12     MCUCR |= (1<<JTD);
13 };
14
15 void led_set_kb(uint8_t usb_led)
16 {
17     print("led_set\n");
18 }
19
20 void backlight_init_ports(void)
21 {
22     // Set C7 to output
23     DDRC |= (1<<7);
24
25     // Initialize the timer
26     TC4H = 0x03;
27     OCR4C = 0xFF;
28     TCCR4A = 0b10000010;
29     TCCR4B = 0b00000001;
30 }
31
32 void backlight_set(uint8_t level)
33 {
34     // Determine the PWM level
35     switch (level)
36     {
37         case 0:
38             // 33%
39             pwm_level = 0x54;
40             break;
41         case 1:
42             // 66%
43             pwm_level = 0xA8;
44             break;
45         case 2:
46             // 100%
47             pwm_level = 0xFF;
48             break;
49         case 3:
50             // 0%
51             pwm_level = 0x00;
52             break;
53         default:
54             xprintf("Unknown level: %d\n", level);
55     }
56
57     // Write the PWM level to the timer
58     TC4H = pwm_level >> 8;
59     OCR4A = 0xFF & pwm_level;
60 }