diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/quantum.c | 158 | ||||
-rw-r--r-- | quantum/quantum_keycodes.h | 16 | ||||
-rw-r--r-- | quantum/rgblight.c | 24 | ||||
-rw-r--r-- | quantum/rgblight.h | 10 |
4 files changed, 147 insertions, 61 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index 87975ef99..285e1e81e 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -249,105 +249,153 @@ bool process_record_quantum(keyrecord_t *record) { | |||
249 | if (record->event.pressed) { | 249 | if (record->event.pressed) { |
250 | reset_keyboard(); | 250 | reset_keyboard(); |
251 | } | 251 | } |
252 | return false; | 252 | return false; |
253 | break; | ||
254 | case DEBUG: | 253 | case DEBUG: |
255 | if (record->event.pressed) { | 254 | if (record->event.pressed) { |
256 | debug_enable = true; | 255 | debug_enable = true; |
257 | print("DEBUG: enabled.\n"); | 256 | print("DEBUG: enabled.\n"); |
258 | } | 257 | } |
259 | return false; | 258 | return false; |
260 | break; | ||
261 | #ifdef FAUXCLICKY_ENABLE | 259 | #ifdef FAUXCLICKY_ENABLE |
262 | case FC_TOG: | 260 | case FC_TOG: |
263 | if (record->event.pressed) { | 261 | if (record->event.pressed) { |
264 | FAUXCLICKY_TOGGLE; | 262 | FAUXCLICKY_TOGGLE; |
265 | } | 263 | } |
266 | return false; | 264 | return false; |
267 | break; | ||
268 | case FC_ON: | 265 | case FC_ON: |
269 | if (record->event.pressed) { | 266 | if (record->event.pressed) { |
270 | FAUXCLICKY_ON; | 267 | FAUXCLICKY_ON; |
271 | } | 268 | } |
272 | return false; | 269 | return false; |
273 | break; | ||
274 | case FC_OFF: | 270 | case FC_OFF: |
275 | if (record->event.pressed) { | 271 | if (record->event.pressed) { |
276 | FAUXCLICKY_OFF; | 272 | FAUXCLICKY_OFF; |
277 | } | 273 | } |
278 | return false; | 274 | return false; |
279 | break; | ||
280 | #endif | 275 | #endif |
281 | #ifdef RGBLIGHT_ENABLE | 276 | #ifdef RGBLIGHT_ENABLE |
282 | case RGB_TOG: | 277 | case RGB_TOG: |
283 | if (record->event.pressed) { | 278 | if (record->event.pressed) { |
284 | rgblight_toggle(); | 279 | rgblight_toggle(); |
285 | } | 280 | } |
286 | return false; | 281 | return false; |
287 | break; | 282 | case RGB_MOD: |
288 | case RGB_MOD: | 283 | if (record->event.pressed) { |
289 | if (record->event.pressed) { | 284 | rgblight_step(); |
290 | rgblight_step(); | 285 | } |
291 | } | 286 | return false; |
292 | return false; | 287 | case RGB_HUI: |
293 | break; | 288 | if (record->event.pressed) { |
294 | case RGB_HUI: | 289 | rgblight_increase_hue(); |
295 | if (record->event.pressed) { | 290 | } |
296 | rgblight_increase_hue(); | 291 | return false; |
292 | case RGB_HUD: | ||
293 | if (record->event.pressed) { | ||
294 | rgblight_decrease_hue(); | ||
295 | } | ||
296 | return false; | ||
297 | case RGB_SAI: | ||
298 | if (record->event.pressed) { | ||
299 | rgblight_increase_sat(); | ||
300 | } | ||
301 | return false; | ||
302 | case RGB_SAD: | ||
303 | if (record->event.pressed) { | ||
304 | rgblight_decrease_sat(); | ||
305 | } | ||
306 | return false; | ||
307 | case RGB_VAI: | ||
308 | if (record->event.pressed) { | ||
309 | rgblight_increase_val(); | ||
310 | } | ||
311 | return false; | ||
312 | case RGB_VAD: | ||
313 | if (record->event.pressed) { | ||
314 | rgblight_decrease_val(); | ||
315 | } | ||
316 | return false; | ||
317 | case RGB_MODE_PLAIN: | ||
318 | if (record->event.pressed) { | ||
319 | rgblight_mode(1); | ||
320 | } | ||
321 | return false; | ||
322 | case RGB_MODE_BREATHE: | ||
323 | if (record->event.pressed) { | ||
324 | if ((2 <= rgblight_get_mode()) && (rgblight_get_mode() < 5)) { | ||
325 | rgblight_step(); | ||
326 | } else { | ||
327 | rgblight_mode(2); | ||
297 | } | 328 | } |
298 | return false; | 329 | } |
299 | break; | 330 | return false; |
300 | case RGB_HUD: | 331 | case RGB_MODE_RAINBOW: |
301 | if (record->event.pressed) { | 332 | if (record->event.pressed) { |
302 | rgblight_decrease_hue(); | 333 | if ((6 <= rgblight_get_mode()) && (rgblight_get_mode() < 8)) { |
334 | rgblight_step(); | ||
335 | } else { | ||
336 | rgblight_mode(6); | ||
303 | } | 337 | } |
304 | return false; | 338 | } |
305 | break; | 339 | return false; |
306 | case RGB_SAI: | 340 | case RGB_MODE_SWIRL: |
307 | if (record->event.pressed) { | 341 | if (record->event.pressed) { |
308 | rgblight_increase_sat(); | 342 | if ((9 <= rgblight_get_mode()) && (rgblight_get_mode() < 14)) { |
343 | rgblight_step(); | ||
344 | } else { | ||
345 | rgblight_mode(9); | ||
309 | } | 346 | } |
310 | return false; | 347 | } |
311 | break; | 348 | return false; |
312 | case RGB_SAD: | 349 | case RGB_MODE_SNAKE: |
313 | if (record->event.pressed) { | 350 | if (record->event.pressed) { |
314 | rgblight_decrease_sat(); | 351 | if ((15 <= rgblight_get_mode()) && (rgblight_get_mode() < 20)) { |
352 | rgblight_step(); | ||
353 | } else { | ||
354 | rgblight_mode(15); | ||
315 | } | 355 | } |
316 | return false; | 356 | } |
317 | break; | 357 | return false; |
318 | case RGB_VAI: | 358 | case RGB_MODE_KNIGHT: |
319 | if (record->event.pressed) { | 359 | if (record->event.pressed) { |
320 | rgblight_increase_val(); | 360 | if ((21 <= rgblight_get_mode()) && (rgblight_get_mode() < 23)) { |
361 | rgblight_step(); | ||
362 | } else { | ||
363 | rgblight_mode(21); | ||
321 | } | 364 | } |
322 | return false; | 365 | } |
323 | break; | 366 | return false; |
324 | case RGB_VAD: | 367 | case RGB_MODE_XMAS: |
325 | if (record->event.pressed) { | 368 | if (record->event.pressed) { |
326 | rgblight_decrease_val(); | 369 | rgblight_mode(24); |
370 | } | ||
371 | return false; | ||
372 | case RGB_MODE_GRADIENT: | ||
373 | if (record->event.pressed) { | ||
374 | if ((25 <= rgblight_get_mode()) && (rgblight_get_mode() < 34)) { | ||
375 | rgblight_step(); | ||
376 | } else { | ||
377 | rgblight_mode(25); | ||
327 | } | 378 | } |
328 | return false; | 379 | } |
329 | break; | 380 | return false; |
330 | #endif | 381 | #endif |
331 | #ifdef PROTOCOL_LUFA | 382 | #ifdef PROTOCOL_LUFA |
332 | case OUT_AUTO: | 383 | case OUT_AUTO: |
333 | if (record->event.pressed) { | 384 | if (record->event.pressed) { |
334 | set_output(OUTPUT_AUTO); | 385 | set_output(OUTPUT_AUTO); |
335 | } | 386 | } |
336 | return false; | 387 | return false; |
337 | break; | ||
338 | case OUT_USB: | 388 | case OUT_USB: |
339 | if (record->event.pressed) { | 389 | if (record->event.pressed) { |
340 | set_output(OUTPUT_USB); | 390 | set_output(OUTPUT_USB); |
341 | } | 391 | } |
342 | return false; | 392 | return false; |
343 | break; | ||
344 | #ifdef BLUETOOTH_ENABLE | 393 | #ifdef BLUETOOTH_ENABLE |
345 | case OUT_BT: | 394 | case OUT_BT: |
346 | if (record->event.pressed) { | 395 | if (record->event.pressed) { |
347 | set_output(OUTPUT_BLUETOOTH); | 396 | set_output(OUTPUT_BLUETOOTH); |
348 | } | 397 | } |
349 | return false; | 398 | return false; |
350 | break; | ||
351 | #endif | 399 | #endif |
352 | #endif | 400 | #endif |
353 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: | 401 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: |
@@ -454,7 +502,6 @@ bool process_record_quantum(keyrecord_t *record) { | |||
454 | unregister_mods(MOD_BIT(KC_LSFT)); | 502 | unregister_mods(MOD_BIT(KC_LSFT)); |
455 | } | 503 | } |
456 | return false; | 504 | return false; |
457 | // break; | ||
458 | } | 505 | } |
459 | 506 | ||
460 | case KC_RSPC: { | 507 | case KC_RSPC: { |
@@ -477,7 +524,6 @@ bool process_record_quantum(keyrecord_t *record) { | |||
477 | unregister_mods(MOD_BIT(KC_RSFT)); | 524 | unregister_mods(MOD_BIT(KC_RSFT)); |
478 | } | 525 | } |
479 | return false; | 526 | return false; |
480 | // break; | ||
481 | } | 527 | } |
482 | case GRAVE_ESC: { | 528 | case GRAVE_ESC: { |
483 | uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT) | 529 | uint8_t shifted = get_mods() & ((MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT) |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 1bb6706ba..ccd4565f5 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
@@ -401,6 +401,14 @@ enum quantum_keycodes { | |||
401 | RGB_SAD, | 401 | RGB_SAD, |
402 | RGB_VAI, | 402 | RGB_VAI, |
403 | RGB_VAD, | 403 | RGB_VAD, |
404 | RGB_MODE_PLAIN, | ||
405 | RGB_MODE_BREATHE, | ||
406 | RGB_MODE_RAINBOW, | ||
407 | RGB_MODE_SWIRL, | ||
408 | RGB_MODE_SNAKE, | ||
409 | RGB_MODE_KNIGHT, | ||
410 | RGB_MODE_XMAS, | ||
411 | RGB_MODE_GRADIENT, | ||
404 | 412 | ||
405 | // Left shift, open paren | 413 | // Left shift, open paren |
406 | KC_LSPO, | 414 | KC_LSPO, |
@@ -534,6 +542,14 @@ enum quantum_keycodes { | |||
534 | 542 | ||
535 | #define KC_GESC GRAVE_ESC | 543 | #define KC_GESC GRAVE_ESC |
536 | 544 | ||
545 | #define RGB_M_P RGB_MODE_PLAIN | ||
546 | #define RGB_M_B RGB_MODE_BREATHE | ||
547 | #define RGB_M_R RGB_MODE_RAINBOW | ||
548 | #define RGB_M_SW RGB_MODE_SWIRL | ||
549 | #define RGB_M_SN RGB_MODE_SNAKE | ||
550 | #define RGB_M_K RGB_MODE_KNIGHT | ||
551 | #define RGB_M_X RGB_MODE_XMAS | ||
552 | #define RGB_M_G RGB_MODE_GRADIENT | ||
537 | 553 | ||
538 | // L-ayer, T-ap - 256 keycode max, 16 layer max | 554 | // L-ayer, T-ap - 256 keycode max, 16 layer max |
539 | #define LT(layer, kc) (kc | QK_LAYER_TAP | ((layer & 0xF) << 8)) | 555 | #define LT(layer, kc) (kc | QK_LAYER_TAP | ((layer & 0xF) << 8)) |
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 1b5076450..5ae6e69d6 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include "debug.h" | 22 | #include "debug.h" |
23 | #include "led_tables.h" | 23 | #include "led_tables.h" |
24 | 24 | ||
25 | |||
26 | __attribute__ ((weak)) | 25 | __attribute__ ((weak)) |
27 | const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; | 26 | const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; |
28 | __attribute__ ((weak)) | 27 | __attribute__ ((weak)) |
@@ -32,7 +31,7 @@ const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20}; | |||
32 | __attribute__ ((weak)) | 31 | __attribute__ ((weak)) |
33 | const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; | 32 | const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; |
34 | __attribute__ ((weak)) | 33 | __attribute__ ((weak)) |
35 | const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20}; | 34 | const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; |
36 | __attribute__ ((weak)) | 35 | __attribute__ ((weak)) |
37 | const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; | 36 | const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; |
38 | 37 | ||
@@ -197,6 +196,14 @@ void rgblight_step_reverse(void) { | |||
197 | rgblight_mode(mode); | 196 | rgblight_mode(mode); |
198 | } | 197 | } |
199 | 198 | ||
199 | uint32_t rgblight_get_mode(void) { | ||
200 | if (!rgblight_config.enable) { | ||
201 | return false; | ||
202 | } | ||
203 | |||
204 | return rgblight_config.mode; | ||
205 | } | ||
206 | |||
200 | void rgblight_mode(uint8_t mode) { | 207 | void rgblight_mode(uint8_t mode) { |
201 | if (!rgblight_config.enable) { | 208 | if (!rgblight_config.enable) { |
202 | return; | 209 | return; |
@@ -220,6 +227,8 @@ void rgblight_mode(uint8_t mode) { | |||
220 | // MODE 9-14, rainbow swirl | 227 | // MODE 9-14, rainbow swirl |
221 | // MODE 15-20, snake | 228 | // MODE 15-20, snake |
222 | // MODE 21-23, knight | 229 | // MODE 21-23, knight |
230 | // MODE 24, xmas | ||
231 | // MODE 25-34, static rainbow | ||
223 | 232 | ||
224 | #ifdef RGBLIGHT_ANIMATIONS | 233 | #ifdef RGBLIGHT_ANIMATIONS |
225 | rgblight_timer_enable(); | 234 | rgblight_timer_enable(); |
@@ -550,7 +559,14 @@ void rgblight_effect_knight(uint8_t interval) { | |||
550 | static int8_t increment = 1; | 559 | static int8_t increment = 1; |
551 | uint8_t i, cur; | 560 | uint8_t i, cur; |
552 | 561 | ||
562 | // Set all the LEDs to 0 | ||
553 | for (i = 0; i < RGBLED_NUM; i++) { | 563 | for (i = 0; i < RGBLED_NUM; i++) { |
564 | led[i].r = 0; | ||
565 | led[i].g = 0; | ||
566 | led[i].b = 0; | ||
567 | } | ||
568 | // Determine which LEDs should be lit up | ||
569 | for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) { | ||
554 | cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM; | 570 | cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM; |
555 | 571 | ||
556 | if (i >= low_bound && i <= high_bound) { | 572 | if (i >= low_bound && i <= high_bound) { |
@@ -563,10 +579,12 @@ void rgblight_effect_knight(uint8_t interval) { | |||
563 | } | 579 | } |
564 | rgblight_set(); | 580 | rgblight_set(); |
565 | 581 | ||
582 | // Move from low_bound to high_bound changing the direction we increment each | ||
583 | // time a boundary is hit. | ||
566 | low_bound += increment; | 584 | low_bound += increment; |
567 | high_bound += increment; | 585 | high_bound += increment; |
568 | 586 | ||
569 | if (high_bound <= 0 || low_bound >= RGBLED_NUM - 1) { | 587 | if (high_bound <= 0 || low_bound >= RGBLIGHT_EFFECT_KNIGHT_LED_NUM - 1) { |
570 | increment = -increment; | 588 | increment = -increment; |
571 | } | 589 | } |
572 | } | 590 | } |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index d0dd6e490..7acd5a257 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
@@ -23,16 +23,21 @@ | |||
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | #ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH | 25 | #ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH |
26 | #define RGBLIGHT_EFFECT_SNAKE_LENGTH 7 | 26 | #define RGBLIGHT_EFFECT_SNAKE_LENGTH 4 |
27 | #endif | 27 | #endif |
28 | 28 | ||
29 | #ifndef RGBLIGHT_EFFECT_KNIGHT_LENGTH | 29 | #ifndef RGBLIGHT_EFFECT_KNIGHT_LENGTH |
30 | #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 7 | 30 | #define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3 |
31 | #endif | 31 | #endif |
32 | |||
32 | #ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET | 33 | #ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET |
33 | #define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0 | 34 | #define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0 |
34 | #endif | 35 | #endif |
35 | 36 | ||
37 | #ifndef RGBLIGHT_EFFECT_KNIGHT_LED_NUM | ||
38 | #define RGBLIGHT_EFFECT_KNIGHT_LED_NUM RGBLED_NUM | ||
39 | #endif | ||
40 | |||
36 | #ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL | 41 | #ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL |
37 | #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000 | 42 | #define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 1000 |
38 | #endif | 43 | #endif |
@@ -85,6 +90,7 @@ void rgblight_toggle(void); | |||
85 | void rgblight_enable(void); | 90 | void rgblight_enable(void); |
86 | void rgblight_step(void); | 91 | void rgblight_step(void); |
87 | void rgblight_step_reverse(void); | 92 | void rgblight_step_reverse(void); |
93 | uint32_t rgblight_get_mode(void); | ||
88 | void rgblight_mode(uint8_t mode); | 94 | void rgblight_mode(uint8_t mode); |
89 | void rgblight_set(void); | 95 | void rgblight_set(void); |
90 | void rgblight_update_dword(uint32_t dword); | 96 | void rgblight_update_dword(uint32_t dword); |