Merge pull request #1171 from ishtob/master
[jackhill/qmk/firmware.git] / keyboards / cluecard / cluecard.c
CommitLineData
adad05c3 1#include "cluecard.h"
2#define BL_RED OCR1B
3#define BL_GREEN OCR1A
4#define BL_BLUE OCR1C
5
6void matrix_init_kb(void) {
7 // put your keyboard start-up code here
8 // runs once when the firmware starts up
9
10 matrix_init_user();
11}
12
13void matrix_scan_kb(void) {
14 // put your looping keyboard code here
15 // runs every cycle (a lot)
16
17 matrix_scan_user();
18}
19
20bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
21 // put your per-action keyboard code here
22 // runs for every action, just before processing by the firmware
23
24 return process_record_user(keycode, record);
25}
26
27void led_set_kb(uint8_t usb_led) {
28 // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
29
30 led_set_user(usb_led);
31}
32
33void backlight_init_ports(void)
34{
35 // Set B5, B6, and B7 as output
36 DDRB |= (1<<7)|(1<<6)|(1<<5);
37
38 // Setup PWM
39 ICR1 = 0xFFFF;
40 TCCR1A = 0b10101010;
41 TCCR1B = 0b00011001;
42
43 BL_RED = 0xFFFF;
44 BL_GREEN = 0xFFFF;
45 BL_BLUE = 0xFFFF;
46}
47
48void backlight_set(uint8_t level)
49{
50 // Set the RGB color
51 switch (level)
52 {
53 case 0:
54 // Off
55 BL_RED = 0xFFFF;
56 BL_GREEN = 0xFFFF;
57 BL_BLUE = 0xFFFF;
58 break;
59 case 1:
60 // Red
61 BL_RED = 0x0000;
62 BL_GREEN = 0xFFFF;
63 BL_BLUE = 0xFFFF;
64 break;
65 case 2:
66 // Green
67 BL_RED = 0xFFFF;
68 BL_GREEN = 0x0000;
69 BL_BLUE = 0xFFFF;
70 break;
71 case 3:
72 // Blue
73 BL_RED = 0xFFFF;
74 BL_GREEN = 0xFFFF;
75 BL_BLUE = 0x0000;
76 break;
77 case 4:
78 // Magenta
79 BL_RED = 0x4000;
80 BL_GREEN = 0x4000;
81 BL_BLUE = 0x4000;
82 break;
83 case 5:
84 // Purple
85 BL_RED = 0x0000;
86 BL_GREEN = 0xFFFF;
87 BL_BLUE = 0x0000;
88 break;
89 case 6:
90 // Yellow
91 BL_RED = 0x0000;
92 BL_GREEN = 0x0000;
93 BL_BLUE = 0xFFFF;
94 break;
95 default:
96 xprintf("Unknown level: %d\n", level);
97 }
98}