diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/keymap.h | 4 | ||||
-rwxr-xr-x | quantum/light_ws2812.c | 143 | ||||
-rwxr-xr-x | quantum/light_ws2812.h | 7 | ||||
-rw-r--r-- | quantum/process_keycode/process_printer.c | 254 | ||||
-rw-r--r-- | quantum/process_keycode/process_printer.h | 8 | ||||
-rw-r--r-- | quantum/process_keycode/process_printer_bb.c | 260 | ||||
-rw-r--r-- | quantum/quantum.c | 2 | ||||
-rw-r--r-- | quantum/quantum.h | 4 | ||||
-rw-r--r-- | quantum/rgblight.c | 18 | ||||
-rw-r--r-- | quantum/rgblight.h | 1 |
10 files changed, 696 insertions, 5 deletions
diff --git a/quantum/keymap.h b/quantum/keymap.h index a01bbfbd1..ae56d16c7 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h | |||
@@ -178,6 +178,10 @@ enum quantum_keycodes { | |||
178 | // Right shift, close paren | 178 | // Right shift, close paren |
179 | KC_RSPC, | 179 | KC_RSPC, |
180 | 180 | ||
181 | // Printing | ||
182 | PRINT_ON, | ||
183 | PRINT_OFF, | ||
184 | |||
181 | // always leave at the end | 185 | // always leave at the end |
182 | SAFE_RANGE | 186 | SAFE_RANGE |
183 | }; | 187 | }; |
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c index 401845e85..497543339 100755 --- a/quantum/light_ws2812.c +++ b/quantum/light_ws2812.c | |||
@@ -16,6 +16,122 @@ | |||
16 | #include <util/delay.h> | 16 | #include <util/delay.h> |
17 | #include "debug.h" | 17 | #include "debug.h" |
18 | 18 | ||
19 | #define RGBW_BB_TWI 1 | ||
20 | |||
21 | #ifdef RGBW_BB_TWI | ||
22 | |||
23 | // Port for the I2C | ||
24 | #define I2C_DDR DDRD | ||
25 | #define I2C_PIN PIND | ||
26 | #define I2C_PORT PORTD | ||
27 | |||
28 | // Pins to be used in the bit banging | ||
29 | #define I2C_CLK 0 | ||
30 | #define I2C_DAT 1 | ||
31 | |||
32 | #define I2C_DATA_HI()\ | ||
33 | I2C_DDR &= ~ (1 << I2C_DAT);\ | ||
34 | I2C_PORT |= (1 << I2C_DAT); | ||
35 | #define I2C_DATA_LO()\ | ||
36 | I2C_DDR |= (1 << I2C_DAT);\ | ||
37 | I2C_PORT &= ~ (1 << I2C_DAT); | ||
38 | |||
39 | #define I2C_CLOCK_HI()\ | ||
40 | I2C_DDR &= ~ (1 << I2C_CLK);\ | ||
41 | I2C_PORT |= (1 << I2C_CLK); | ||
42 | #define I2C_CLOCK_LO()\ | ||
43 | I2C_DDR |= (1 << I2C_CLK);\ | ||
44 | I2C_PORT &= ~ (1 << I2C_CLK); | ||
45 | |||
46 | #define I2C_DELAY 1 | ||
47 | |||
48 | void I2C_WriteBit(unsigned char c) | ||
49 | { | ||
50 | if (c > 0) | ||
51 | { | ||
52 | I2C_DATA_HI(); | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | I2C_DATA_LO(); | ||
57 | } | ||
58 | |||
59 | I2C_CLOCK_HI(); | ||
60 | _delay_us(I2C_DELAY); | ||
61 | |||
62 | I2C_CLOCK_LO(); | ||
63 | _delay_us(I2C_DELAY); | ||
64 | |||
65 | if (c > 0) | ||
66 | { | ||
67 | I2C_DATA_LO(); | ||
68 | } | ||
69 | |||
70 | _delay_us(I2C_DELAY); | ||
71 | } | ||
72 | |||
73 | // Inits bitbanging port, must be called before using the functions below | ||
74 | // | ||
75 | void I2C_Init() | ||
76 | { | ||
77 | I2C_PORT &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK)); | ||
78 | |||
79 | I2C_CLOCK_HI(); | ||
80 | I2C_DATA_HI(); | ||
81 | |||
82 | _delay_us(I2C_DELAY); | ||
83 | } | ||
84 | |||
85 | // Send a START Condition | ||
86 | // | ||
87 | void I2C_Start() | ||
88 | { | ||
89 | // set both to high at the same time | ||
90 | I2C_DDR &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK)); | ||
91 | _delay_us(I2C_DELAY); | ||
92 | |||
93 | I2C_DATA_LO(); | ||
94 | _delay_us(I2C_DELAY); | ||
95 | |||
96 | I2C_CLOCK_LO(); | ||
97 | _delay_us(I2C_DELAY); | ||
98 | } | ||
99 | |||
100 | // Send a STOP Condition | ||
101 | // | ||
102 | void I2C_Stop() | ||
103 | { | ||
104 | I2C_CLOCK_HI(); | ||
105 | _delay_us(I2C_DELAY); | ||
106 | |||
107 | I2C_DATA_HI(); | ||
108 | _delay_us(I2C_DELAY); | ||
109 | } | ||
110 | |||
111 | // write a byte to the I2C slave device | ||
112 | // | ||
113 | unsigned char I2C_Write(unsigned char c) | ||
114 | { | ||
115 | for (char i = 0; i < 8; i++) | ||
116 | { | ||
117 | I2C_WriteBit(c & 128); | ||
118 | |||
119 | c <<= 1; | ||
120 | } | ||
121 | |||
122 | |||
123 | I2C_WriteBit(0); | ||
124 | _delay_us(I2C_DELAY); | ||
125 | _delay_us(I2C_DELAY); | ||
126 | |||
127 | // _delay_us(I2C_DELAY); | ||
128 | //return I2C_ReadBit(); | ||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | |||
133 | #endif | ||
134 | |||
19 | // Setleds for standard RGB | 135 | // Setleds for standard RGB |
20 | void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) | 136 | void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds) |
21 | { | 137 | { |
@@ -36,12 +152,35 @@ void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pin | |||
36 | // Setleds for SK6812RGBW | 152 | // Setleds for SK6812RGBW |
37 | void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) | 153 | void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds) |
38 | { | 154 | { |
155 | |||
156 | #ifdef RGBW_BB_TWI | ||
157 | cli(); | ||
158 | TWCR = 0; | ||
159 | I2C_Init(); | ||
160 | I2C_Start(); | ||
161 | I2C_Write(0x84); | ||
162 | uint16_t datlen = leds<<2; | ||
163 | uint8_t curbyte; | ||
164 | uint8_t * data = (uint8_t*)ledarray; | ||
165 | while (datlen--) { | ||
166 | curbyte=*data++; | ||
167 | I2C_Write(curbyte); | ||
168 | } | ||
169 | I2C_Stop(); | ||
170 | sei(); | ||
171 | #else | ||
172 | _delay_us(80); | ||
173 | #endif | ||
174 | |||
175 | |||
39 | // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR | 176 | // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR |
40 | // new universal format (DDR) | 177 | // new universal format (DDR) |
41 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF); | 178 | _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF); |
42 | 179 | ||
43 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); | 180 | ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF)); |
44 | _delay_us(80); | 181 | |
182 | |||
183 | |||
45 | } | 184 | } |
46 | 185 | ||
47 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) | 186 | void ws2812_sendarray(uint8_t *data,uint16_t datlen) |
@@ -123,7 +262,7 @@ void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi) | |||
123 | cli(); | 262 | cli(); |
124 | 263 | ||
125 | while (datlen--) { | 264 | while (datlen--) { |
126 | curbyte=*data++; | 265 | curbyte=(*data++); |
127 | 266 | ||
128 | asm volatile( | 267 | asm volatile( |
129 | " ldi %0,8 \n\t" | 268 | " ldi %0,8 \n\t" |
diff --git a/quantum/light_ws2812.h b/quantum/light_ws2812.h index 54eef22d9..576c3bc48 100755 --- a/quantum/light_ws2812.h +++ b/quantum/light_ws2812.h | |||
@@ -16,6 +16,13 @@ | |||
16 | #include <avr/io.h> | 16 | #include <avr/io.h> |
17 | #include <avr/interrupt.h> | 17 | #include <avr/interrupt.h> |
18 | //#include "ws2812_config.h" | 18 | //#include "ws2812_config.h" |
19 | #include "i2cmaster.h" | ||
20 | |||
21 | #define LIGHT_I2C 1 | ||
22 | #define LIGHT_I2C_ADDR 0x84 | ||
23 | #define LIGHT_I2C_ADDR_WRITE ( (LIGHT_I2C_ADDR<<1) | I2C_WRITE ) | ||
24 | #define LIGHT_I2C_ADDR_READ ( (LIGHT_I2C_ADDR<<1) | I2C_READ ) | ||
25 | |||
19 | 26 | ||
20 | /* | 27 | /* |
21 | * Structure of the LED array | 28 | * Structure of the LED array |
diff --git a/quantum/process_keycode/process_printer.c b/quantum/process_keycode/process_printer.c new file mode 100644 index 000000000..2e11dd366 --- /dev/null +++ b/quantum/process_keycode/process_printer.c | |||
@@ -0,0 +1,254 @@ | |||
1 | #include "process_printer.h" | ||
2 | #include "action_util.h" | ||
3 | |||
4 | bool printing_enabled = false; | ||
5 | uint8_t character_shift = 0; | ||
6 | |||
7 | void enabled_printing() { | ||
8 | printing_enabled = true; | ||
9 | serial_init(); | ||
10 | } | ||
11 | |||
12 | void disable_printing() { | ||
13 | printing_enabled = false; | ||
14 | } | ||
15 | |||
16 | uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; | ||
17 | |||
18 | // uint8_t keycode_to_ascii[0xFF][2]; | ||
19 | |||
20 | // keycode_to_ascii[KC_MINS] = {0x2D, 0x5F}; | ||
21 | |||
22 | void print_char(char c) { | ||
23 | USB_Disable(); | ||
24 | serial_send(c); | ||
25 | USB_Init(); | ||
26 | } | ||
27 | |||
28 | void print_box_string(uint8_t text[]) { | ||
29 | uint8_t len = strlen(text); | ||
30 | uint8_t out[len * 3 + 8]; | ||
31 | out[0] = 0xDA; | ||
32 | for (uint8_t i = 0; i < len; i++) { | ||
33 | out[i+1] = 0xC4; | ||
34 | } | ||
35 | out[len + 1] = 0xBF; | ||
36 | out[len + 2] = '\n'; | ||
37 | |||
38 | out[len + 3] = 0xB3; | ||
39 | for (uint8_t i = 0; i < len; i++) { | ||
40 | out[len + 4 + i] = text[i]; | ||
41 | } | ||
42 | out[len * 2 + 4] = 0xB3; | ||
43 | out[len * 2 + 5] = '\n'; | ||
44 | |||
45 | |||
46 | out[len * 2 + 6] = 0xC0; | ||
47 | for (uint8_t i = 0; i < len; i++) { | ||
48 | out[len * 2 + 7 + i] = 0xC4; | ||
49 | } | ||
50 | out[len * 3 + 7] = 0xD9; | ||
51 | out[len * 3 + 8] = '\n'; | ||
52 | |||
53 | print_string(out); | ||
54 | } | ||
55 | |||
56 | void print_string(char c[]) { | ||
57 | for(uint8_t i = 0; i < strlen(c); i++) | ||
58 | print_char(c[i]); | ||
59 | } | ||
60 | |||
61 | bool process_printer(uint16_t keycode, keyrecord_t *record) { | ||
62 | if (keycode == PRINT_ON) { | ||
63 | enabled_printing(); | ||
64 | return false; | ||
65 | } | ||
66 | if (keycode == PRINT_OFF) { | ||
67 | disable_printing(); | ||
68 | return false; | ||
69 | } | ||
70 | |||
71 | if (printing_enabled) { | ||
72 | switch(keycode) { | ||
73 | case KC_EXLM ... KC_RPRN: | ||
74 | case KC_UNDS: | ||
75 | case KC_PLUS: | ||
76 | case KC_LCBR: | ||
77 | case KC_RCBR: | ||
78 | case KC_PIPE: | ||
79 | case KC_TILD: | ||
80 | keycode &= 0xFF; | ||
81 | case KC_LSFT: | ||
82 | case KC_RSFT: | ||
83 | if (record->event.pressed) { | ||
84 | character_shift++; | ||
85 | } else { | ||
86 | character_shift--; | ||
87 | } | ||
88 | return false; | ||
89 | break; | ||
90 | } | ||
91 | |||
92 | switch(keycode) { | ||
93 | case KC_F1: | ||
94 | if (record->event.pressed) { | ||
95 | print_box_string("This is a line of text!"); | ||
96 | } | ||
97 | return false; | ||
98 | case KC_ESC: | ||
99 | if (record->event.pressed) { | ||
100 | print_char(0x1B); | ||
101 | } | ||
102 | return false; | ||
103 | break; | ||
104 | case KC_SPC: | ||
105 | if (record->event.pressed) { | ||
106 | print_char(0x20); | ||
107 | } | ||
108 | return false; | ||
109 | break; | ||
110 | case KC_A ... KC_Z: | ||
111 | if (record->event.pressed) { | ||
112 | if (character_shift) { | ||
113 | print_char(0x41 + (keycode - KC_A)); | ||
114 | } else { | ||
115 | print_char(0x61 + (keycode - KC_A)); | ||
116 | } | ||
117 | } | ||
118 | return false; | ||
119 | break; | ||
120 | case KC_1 ... KC_0: | ||
121 | if (record->event.pressed) { | ||
122 | if (character_shift) { | ||
123 | print_char(shifted_numbers[keycode - KC_1]); | ||
124 | } else { | ||
125 | print_char(0x30 + ((keycode - KC_1 + 1) % 10)); | ||
126 | } | ||
127 | } | ||
128 | return false; | ||
129 | break; | ||
130 | case KC_ENT: | ||
131 | if (record->event.pressed) { | ||
132 | if (character_shift) { | ||
133 | print_char(0x0C); | ||
134 | } else { | ||
135 | print_char(0x0A); | ||
136 | } | ||
137 | } | ||
138 | return false; | ||
139 | break; | ||
140 | case KC_BSPC: | ||
141 | if (record->event.pressed) { | ||
142 | if (character_shift) { | ||
143 | print_char(0x18); | ||
144 | } else { | ||
145 | print_char(0x1A); | ||
146 | } | ||
147 | } | ||
148 | return false; | ||
149 | break; | ||
150 | case KC_DOT: | ||
151 | if (record->event.pressed) { | ||
152 | if (character_shift) { | ||
153 | print_char(0x3E); | ||
154 | } else { | ||
155 | print_char(0x2E); | ||
156 | } | ||
157 | } | ||
158 | return false; | ||
159 | break; | ||
160 | case KC_COMM: | ||
161 | if (record->event.pressed) { | ||
162 | if (character_shift) { | ||
163 | print_char(0x3C); | ||
164 | } else { | ||
165 | print_char(0x2C); | ||
166 | } | ||
167 | } | ||
168 | return false; | ||
169 | break; | ||
170 | case KC_SLSH: | ||
171 | if (record->event.pressed) { | ||
172 | if (character_shift) { | ||
173 | print_char(0x3F); | ||
174 | } else { | ||
175 | print_char(0x2F); | ||
176 | } | ||
177 | } | ||
178 | return false; | ||
179 | break; | ||
180 | case KC_QUOT: | ||
181 | if (record->event.pressed) { | ||
182 | if (character_shift) { | ||
183 | print_char(0x22); | ||
184 | } else { | ||
185 | print_char(0x27); | ||
186 | } | ||
187 | } | ||
188 | return false; | ||
189 | break; | ||
190 | case KC_GRV: | ||
191 | if (record->event.pressed) { | ||
192 | if (character_shift) { | ||
193 | print_char(0x7E); | ||
194 | } else { | ||
195 | print_char(0x60); | ||
196 | } | ||
197 | } | ||
198 | return false; | ||
199 | break; | ||
200 | case KC_MINS: | ||
201 | if (record->event.pressed) { | ||
202 | if (character_shift) { | ||
203 | print_char(0x5F); | ||
204 | } else { | ||
205 | print_char(0x2D); | ||
206 | } | ||
207 | } | ||
208 | return false; | ||
209 | break; | ||
210 | case KC_EQL: | ||
211 | if (record->event.pressed) { | ||
212 | if (character_shift) { | ||
213 | print_char(0x2B); | ||
214 | } else { | ||
215 | print_char(0x3D); | ||
216 | } | ||
217 | } | ||
218 | return false; | ||
219 | break; | ||
220 | case KC_LBRC: | ||
221 | if (record->event.pressed) { | ||
222 | if (character_shift) { | ||
223 | print_char(0x7B); | ||
224 | } else { | ||
225 | print_char(0x5B); | ||
226 | } | ||
227 | } | ||
228 | return false; | ||
229 | break; | ||
230 | case KC_RBRC: | ||
231 | if (record->event.pressed) { | ||
232 | if (character_shift) { | ||
233 | print_char(0x7D); | ||
234 | } else { | ||
235 | print_char(0x5D); | ||
236 | } | ||
237 | } | ||
238 | return false; | ||
239 | break; | ||
240 | case KC_BSLS: | ||
241 | if (record->event.pressed) { | ||
242 | if (character_shift) { | ||
243 | print_char(0x7C); | ||
244 | } else { | ||
245 | print_char(0x5C); | ||
246 | } | ||
247 | } | ||
248 | return false; | ||
249 | break; | ||
250 | } | ||
251 | } | ||
252 | return true; | ||
253 | |||
254 | } \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_printer.h b/quantum/process_keycode/process_printer.h new file mode 100644 index 000000000..fdd36d75a --- /dev/null +++ b/quantum/process_keycode/process_printer.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef PROCESS_PRINTER_H | ||
2 | #define PROCESS_PRINTER_H | ||
3 | |||
4 | #include "quantum.h" | ||
5 | |||
6 | #include "protocol/serial.h" | ||
7 | |||
8 | #endif \ No newline at end of file | ||
diff --git a/quantum/process_keycode/process_printer_bb.c b/quantum/process_keycode/process_printer_bb.c new file mode 100644 index 000000000..1924d0377 --- /dev/null +++ b/quantum/process_keycode/process_printer_bb.c | |||
@@ -0,0 +1,260 @@ | |||
1 | #include "process_printer.h" | ||
2 | #include "action_util.h" | ||
3 | |||
4 | bool printing_enabled = false; | ||
5 | uint8_t character_shift = 0; | ||
6 | |||
7 | #define SERIAL_PIN_DDR DDRD | ||
8 | #define SERIAL_PIN_PORT PORTD | ||
9 | #define SERIAL_PIN_MASK _BV(PD3) | ||
10 | #define SERIAL_DELAY 52 | ||
11 | |||
12 | inline static | ||
13 | void serial_delay(void) { | ||
14 | _delay_us(SERIAL_DELAY); | ||
15 | } | ||
16 | |||
17 | inline static | ||
18 | void serial_high(void) { | ||
19 | SERIAL_PIN_PORT |= SERIAL_PIN_MASK; | ||
20 | } | ||
21 | |||
22 | inline static | ||
23 | void serial_low(void) { | ||
24 | SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; | ||
25 | } | ||
26 | |||
27 | inline static | ||
28 | void serial_output(void) { | ||
29 | SERIAL_PIN_DDR |= SERIAL_PIN_MASK; | ||
30 | } | ||
31 | |||
32 | |||
33 | void enabled_printing() { | ||
34 | printing_enabled = true; | ||
35 | serial_output(); | ||
36 | serial_high(); | ||
37 | } | ||
38 | |||
39 | void disable_printing() { | ||
40 | printing_enabled = false; | ||
41 | } | ||
42 | |||
43 | uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29}; | ||
44 | |||
45 | // uint8_t keycode_to_ascii[0xFF][2]; | ||
46 | |||
47 | // keycode_to_ascii[KC_MINS] = {0x2D, 0x5F}; | ||
48 | |||
49 | void print_char(char c) { | ||
50 | uint8_t b = 8; | ||
51 | serial_output(); | ||
52 | while( b-- ) { | ||
53 | if(c & (1 << b)) { | ||
54 | serial_high(); | ||
55 | } else { | ||
56 | serial_low(); | ||
57 | } | ||
58 | serial_delay(); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | void print_string(char c[]) { | ||
63 | for(uint8_t i = 0; i < strlen(c); i++) | ||
64 | print_char(c[i]); | ||
65 | } | ||
66 | |||
67 | bool process_printer(uint16_t keycode, keyrecord_t *record) { | ||
68 | if (keycode == PRINT_ON) { | ||
69 | enabled_printing(); | ||
70 | return false; | ||
71 | } | ||
72 | if (keycode == PRINT_OFF) { | ||
73 | disable_printing(); | ||
74 | return false; | ||
75 | } | ||
76 | |||
77 | if (printing_enabled) { | ||
78 | switch(keycode) { | ||
79 | case KC_EXLM ... KC_RPRN: | ||
80 | case KC_UNDS: | ||
81 | case KC_PLUS: | ||
82 | case KC_LCBR: | ||
83 | case KC_RCBR: | ||
84 | case KC_PIPE: | ||
85 | case KC_TILD: | ||
86 | keycode &= 0xFF; | ||
87 | case KC_LSFT: | ||
88 | case KC_RSFT: | ||
89 | if (record->event.pressed) { | ||
90 | character_shift++; | ||
91 | } else { | ||
92 | character_shift--; | ||
93 | } | ||
94 | return false; | ||
95 | break; | ||
96 | } | ||
97 | |||
98 | switch(keycode) { | ||
99 | case KC_F1: | ||
100 | if (record->event.pressed) { | ||
101 | print_string("This is a line of text!\n\n\n"); | ||
102 | } | ||
103 | return false; | ||
104 | case KC_ESC: | ||
105 | if (record->event.pressed) { | ||
106 | print_char(0x1B); | ||
107 | } | ||
108 | return false; | ||
109 | break; | ||
110 | case KC_SPC: | ||
111 | if (record->event.pressed) { | ||
112 | print_char(0x20); | ||
113 | } | ||
114 | return false; | ||
115 | break; | ||
116 | case KC_A ... KC_Z: | ||
117 | if (record->event.pressed) { | ||
118 | if (character_shift) { | ||
119 | print_char(0x41 + (keycode - KC_A)); | ||
120 | } else { | ||
121 | print_char(0x61 + (keycode - KC_A)); | ||
122 | } | ||
123 | } | ||
124 | return false; | ||
125 | break; | ||
126 | case KC_1 ... KC_0: | ||
127 | if (record->event.pressed) { | ||
128 | if (character_shift) { | ||
129 | print_char(shifted_numbers[keycode - KC_1]); | ||
130 | } else { | ||
131 | print_char(0x30 + ((keycode - KC_1 + 1) % 10)); | ||
132 | } | ||
133 | } | ||
134 | return false; | ||
135 | break; | ||
136 | case KC_ENT: | ||
137 | if (record->event.pressed) { | ||
138 | if (character_shift) { | ||
139 | print_char(0x0C); | ||
140 | } else { | ||
141 | print_char(0x0A); | ||
142 | } | ||
143 | } | ||
144 | return false; | ||
145 | break; | ||
146 | case KC_BSPC: | ||
147 | if (record->event.pressed) { | ||
148 | if (character_shift) { | ||
149 | print_char(0x18); | ||
150 | } else { | ||
151 | print_char(0x1A); | ||
152 | } | ||
153 | } | ||
154 | return false; | ||
155 | break; | ||
156 | case KC_DOT: | ||
157 | if (record->event.pressed) { | ||
158 | if (character_shift) { | ||
159 | print_char(0x3E); | ||
160 | } else { | ||
161 | print_char(0x2E); | ||
162 | } | ||
163 | } | ||
164 | return false; | ||
165 | break; | ||
166 | case KC_COMM: | ||
167 | if (record->event.pressed) { | ||
168 | if (character_shift) { | ||
169 | print_char(0x3C); | ||
170 | } else { | ||
171 | print_char(0x2C); | ||
172 | } | ||
173 | } | ||
174 | return false; | ||
175 | break; | ||
176 | case KC_SLSH: | ||
177 | if (record->event.pressed) { | ||
178 | if (character_shift) { | ||
179 | print_char(0x3F); | ||
180 | } else { | ||
181 | print_char(0x2F); | ||
182 | } | ||
183 | } | ||
184 | return false; | ||
185 | break; | ||
186 | case KC_QUOT: | ||
187 | if (record->event.pressed) { | ||
188 | if (character_shift) { | ||
189 | print_char(0x22); | ||
190 | } else { | ||
191 | print_char(0x27); | ||
192 | } | ||
193 | } | ||
194 | return false; | ||
195 | break; | ||
196 | case KC_GRV: | ||
197 | if (record->event.pressed) { | ||
198 | if (character_shift) { | ||
199 | print_char(0x7E); | ||
200 | } else { | ||
201 | print_char(0x60); | ||
202 | } | ||
203 | } | ||
204 | return false; | ||
205 | break; | ||
206 | case KC_MINS: | ||
207 | if (record->event.pressed) { | ||
208 | if (character_shift) { | ||
209 | print_char(0x5F); | ||
210 | } else { | ||
211 | print_char(0x2D); | ||
212 | } | ||
213 | } | ||
214 | return false; | ||
215 | break; | ||
216 | case KC_EQL: | ||
217 | if (record->event.pressed) { | ||
218 | if (character_shift) { | ||
219 | print_char(0x2B); | ||
220 | } else { | ||
221 | print_char(0x3D); | ||
222 | } | ||
223 | } | ||
224 | return false; | ||
225 | break; | ||
226 | case KC_LBRC: | ||
227 | if (record->event.pressed) { | ||
228 | if (character_shift) { | ||
229 | print_char(0x7B); | ||
230 | } else { | ||
231 | print_char(0x5B); | ||
232 | } | ||
233 | } | ||
234 | return false; | ||
235 | break; | ||
236 | case KC_RBRC: | ||
237 | if (record->event.pressed) { | ||
238 | if (character_shift) { | ||
239 | print_char(0x7D); | ||
240 | } else { | ||
241 | print_char(0x5D); | ||
242 | } | ||
243 | } | ||
244 | return false; | ||
245 | break; | ||
246 | case KC_BSLS: | ||
247 | if (record->event.pressed) { | ||
248 | if (character_shift) { | ||
249 | print_char(0x7C); | ||
250 | } else { | ||
251 | print_char(0x5C); | ||
252 | } | ||
253 | } | ||
254 | return false; | ||
255 | break; | ||
256 | } | ||
257 | } | ||
258 | return true; | ||
259 | |||
260 | } \ No newline at end of file | ||
diff --git a/quantum/quantum.c b/quantum/quantum.c index 098312e6e..b8a81a76b 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -129,6 +129,8 @@ bool process_record_quantum(keyrecord_t *record) { | |||
129 | #ifdef UCIS_ENABLE | 129 | #ifdef UCIS_ENABLE |
130 | process_ucis(keycode, record) && | 130 | process_ucis(keycode, record) && |
131 | #endif | 131 | #endif |
132 | #ifdef PRINTING_ENABLE | ||
133 | process_printer(keycode, record) && | ||
132 | #ifdef UNICODEMAP_ENABLE | 134 | #ifdef UNICODEMAP_ENABLE |
133 | process_unicode_map(keycode, record) && | 135 | process_unicode_map(keycode, record) && |
134 | #endif | 136 | #endif |
diff --git a/quantum/quantum.h b/quantum/quantum.h index 0c6046649..06a2e049d 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
@@ -59,6 +59,10 @@ extern uint32_t default_layer_state; | |||
59 | 59 | ||
60 | #include "process_tap_dance.h" | 60 | #include "process_tap_dance.h" |
61 | 61 | ||
62 | #ifdef PRINTING_ENABLE | ||
63 | #include "process_printer.h" | ||
64 | #endif | ||
65 | |||
62 | #define SEND_STRING(str) send_string(PSTR(str)) | 66 | #define SEND_STRING(str) send_string(PSTR(str)) |
63 | void send_string(const char *str); | 67 | void send_string(const char *str); |
64 | 68 | ||
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index d550c5866..221a16402 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
@@ -69,7 +69,11 @@ const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20}; | |||
69 | 69 | ||
70 | rgblight_config_t rgblight_config; | 70 | rgblight_config_t rgblight_config; |
71 | rgblight_config_t inmem_config; | 71 | rgblight_config_t inmem_config; |
72 | struct cRGB led[RGBLED_NUM]; | 72 | #ifdef RGBW |
73 | struct cRGBW led[RGBLED_NUM]; | ||
74 | #else | ||
75 | struct cRGB led[RGBLED_NUM]; | ||
76 | #endif | ||
73 | uint8_t rgblight_inited = 0; | 77 | uint8_t rgblight_inited = 0; |
74 | 78 | ||
75 | 79 | ||
@@ -351,14 +355,22 @@ void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { | |||
351 | 355 | ||
352 | void rgblight_set(void) { | 356 | void rgblight_set(void) { |
353 | if (rgblight_config.enable) { | 357 | if (rgblight_config.enable) { |
354 | ws2812_setleds(led, RGBLED_NUM); | 358 | #ifdef RGBW |
359 | ws2812_setleds_rgbw(led, RGBLED_NUM); | ||
360 | #else | ||
361 | ws2812_setleds(led, RGBLED_NUM); | ||
362 | #endif | ||
355 | } else { | 363 | } else { |
356 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | 364 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { |
357 | led[i].r = 0; | 365 | led[i].r = 0; |
358 | led[i].g = 0; | 366 | led[i].g = 0; |
359 | led[i].b = 0; | 367 | led[i].b = 0; |
360 | } | 368 | } |
361 | ws2812_setleds(led, RGBLED_NUM); | 369 | #ifdef RGBW |
370 | ws2812_setleds_rgbw(led, RGBLED_NUM); | ||
371 | #else | ||
372 | ws2812_setleds(led, RGBLED_NUM); | ||
373 | #endif | ||
362 | } | 374 | } |
363 | } | 375 | } |
364 | 376 | ||
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 17f04ffcf..efc685f31 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #ifndef RGBLIGHT_H | 1 | #ifndef RGBLIGHT_H |
2 | #define RGBLIGHT_H | 2 | #define RGBLIGHT_H |
3 | 3 | ||
4 | #define RGBW 1 | ||
4 | 5 | ||
5 | #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) | 6 | #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) |
6 | #define RGBLIGHT_MODES 23 | 7 | #define RGBLIGHT_MODES 23 |