diff options
author | Akshay <[email protected]> | 2022-04-10 12:13:40 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2022-04-10 12:13:40 +0100 |
commit | dc90387ce7d8ba7b607d9c48540bf6d8b560f14d (patch) | |
tree | 4ccb8fa5886b66fa9d480edef74236c27f035e16 /keyboards/duck/tcv3/tcv3.c |
Diffstat (limited to 'keyboards/duck/tcv3/tcv3.c')
-rw-r--r-- | keyboards/duck/tcv3/tcv3.c | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/keyboards/duck/tcv3/tcv3.c b/keyboards/duck/tcv3/tcv3.c new file mode 100644 index 000000000..4d52d22c1 --- /dev/null +++ b/keyboards/duck/tcv3/tcv3.c | |||
@@ -0,0 +1,130 @@ | |||
1 | /* Copyright 2019 MechMerlin <[email protected]> | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | #include "tcv3.h" | ||
17 | #include "indicator_leds.h" | ||
18 | |||
19 | enum BACKLIGHT_AREAS { | ||
20 | BACKLIGHT_ALPHA = 0b0000001, | ||
21 | BACKLIGHT_FROW = 0b0000010, | ||
22 | BACKLIGHT_MOD = 0b0000100, | ||
23 | BACKLIGHT_MACRO = 0b0001000, | ||
24 | BACKLIGHT_SWITCH = 0b0001111 | ||
25 | }; | ||
26 | |||
27 | // uint8_t backlight_rgb_r = 255; | ||
28 | // uint8_t backlight_rgb_g = 0; | ||
29 | // uint8_t backlight_rgb_b = 0; | ||
30 | // uint8_t backlight_os_state = 0; | ||
31 | // uint32_t backlight_layer_state = 0; | ||
32 | |||
33 | // void backlight_toggle_rgb(bool enabled) | ||
34 | // { | ||
35 | // if(enabled) { | ||
36 | // uint8_t rgb[17][3] = { | ||
37 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
38 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
39 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
40 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
41 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
42 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
43 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
44 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
45 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
46 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
47 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
48 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
49 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
50 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
51 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
52 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b}, | ||
53 | // {backlight_rgb_r, backlight_rgb_g, backlight_rgb_b} | ||
54 | // }; | ||
55 | // backlight_set_rgb(rgb); | ||
56 | // } else { | ||
57 | // uint8_t rgb[17][3] = { | ||
58 | // {0, 0, 0}, | ||
59 | // {0, 0, 0}, | ||
60 | // {0, 0, 0}, | ||
61 | // {0, 0, 0}, | ||
62 | // {0, 0, 0}, | ||
63 | // {0, 0, 0}, | ||
64 | // {0, 0, 0}, | ||
65 | // {0, 0, 0}, | ||
66 | // {0, 0, 0}, | ||
67 | // {0, 0, 0}, | ||
68 | // {0, 0, 0}, | ||
69 | // {0, 0, 0}, | ||
70 | // {0, 0, 0}, | ||
71 | // {0, 0, 0}, | ||
72 | // {0, 0, 0}, | ||
73 | // {0, 0, 0}, | ||
74 | // {0, 0, 0} | ||
75 | // }; | ||
76 | // backlight_set_rgb(rgb); | ||
77 | // } | ||
78 | // } | ||
79 | |||
80 | // void backlight_set_rgb(uint8_t cfg[17][3]) | ||
81 | // { | ||
82 | // cli(); | ||
83 | // for(uint8_t i = 0; i < 17; ++i) { | ||
84 | // send_color(cfg[i][0], cfg[i][1], cfg[i][2], Device_PCBRGB); | ||
85 | // } | ||
86 | // sei(); | ||
87 | // show(); | ||
88 | // } | ||
89 | |||
90 | // Q5, Q6, Q7 is connected to B1 - alphas | ||
91 | // Q8, Q9 is connected to B2 - frow | ||
92 | // Q1, Q2, Q3 is connected to B3 - mods | ||
93 | // Q4 is connected to E6 - macro keys | ||
94 | |||
95 | void backlight_set(uint8_t level) { | ||
96 | level & BACKLIGHT_ALPHA ? (PORTB |= 0b00000010) : (PORTB &= ~0b00000010); | ||
97 | level & BACKLIGHT_FROW ? (PORTB |= 0b00000100) : (PORTB &= ~0b00000100); | ||
98 | level & BACKLIGHT_MOD ? (PORTB |= 0b00001000) : (PORTB &= ~0b00001000); | ||
99 | level & BACKLIGHT_MACRO ? (PORTE |= 0b01000000) : (PORTE &= ~0b01000000); | ||
100 | } | ||
101 | |||
102 | // // Port from backlight_update_state | ||
103 | // void led_set_kb(uint8_t usb_led) { | ||
104 | // bool status[7] = { | ||
105 | // backlight_os_state & (1<<USB_LED_CAPS_LOCK), | ||
106 | // backlight_os_state & (1<<USB_LED_SCROLL_LOCK), | ||
107 | // backlight_os_state & (1<<USB_LED_NUM_LOCK), | ||
108 | // backlight_layer_state & (1<<1), | ||
109 | // backlight_layer_state & (1<<2), | ||
110 | // backlight_layer_state & (1<<3), | ||
111 | // backlight_layer_state & (1<<4) | ||
112 | // }; | ||
113 | // indicator_leds_set(status); | ||
114 | // backlight_os_state & (1<<USB_LED_CAPS_LOCK) ? (PORTB &= ~0b00000001) : (PORTB |= 0b00000001); | ||
115 | // backlight_os_state & (1<<USB_LED_SCROLL_LOCK) ? (PORTB &= ~0b00010000) : (PORTB |= 0b00010000); | ||
116 | // } | ||
117 | |||
118 | // U5 Pin 1, 2, 3 connected to top left LEDs | ||
119 | |||
120 | // U6 Pin 1, 2, 3 connected to bottom right leds col of 3 | ||
121 | // U7 Pin 1 connected to row connected to bottom right leds solo LED | ||
122 | // U7 Pin 2, 3 connected to bottom right leds row of 2 | ||
123 | // U6 Pin 5 connected to U7 Pin 6 | ||
124 | |||
125 | // U5 pin 5 connected to U6 Pin 6 | ||
126 | |||
127 | // U5, U6, U7 Pin 8 VCC | ||
128 | // U5, U6, U7 Pin 4 GRND | ||
129 | |||
130 | // U5 Pin 6 connected to atmega32u4 D4 | ||