diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/quantum.c | 10 | ||||
| -rw-r--r-- | quantum/quantum_keycodes.h | 2 | ||||
| -rw-r--r-- | quantum/rgb.h | 6 | ||||
| -rw-r--r-- | quantum/rgb_matrix.c | 18 | ||||
| -rw-r--r-- | quantum/rgb_matrix.h | 3 | ||||
| -rw-r--r-- | quantum/rgblight.c | 26 | ||||
| -rw-r--r-- | quantum/rgblight.h | 6 |
7 files changed, 68 insertions, 3 deletions
diff --git a/quantum/quantum.c b/quantum/quantum.c index e1bc8b242..f9b3e2197 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -368,6 +368,16 @@ bool process_record_quantum(keyrecord_t *record) { | |||
| 368 | rgblight_decrease_val(); | 368 | rgblight_decrease_val(); |
| 369 | } | 369 | } |
| 370 | return false; | 370 | return false; |
| 371 | case RGB_SPI: | ||
| 372 | if (record->event.pressed) { | ||
| 373 | rgblight_increase_speed(); | ||
| 374 | } | ||
| 375 | return false; | ||
| 376 | case RGB_SPD: | ||
| 377 | if (record->event.pressed) { | ||
| 378 | rgblight_decrease_speed(); | ||
| 379 | } | ||
| 380 | return false; | ||
| 371 | case RGB_MODE_PLAIN: | 381 | case RGB_MODE_PLAIN: |
| 372 | if (record->event.pressed) { | 382 | if (record->event.pressed) { |
| 373 | rgblight_mode(1); | 383 | rgblight_mode(1); |
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index d6030284a..405741eb1 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h | |||
| @@ -413,6 +413,8 @@ enum quantum_keycodes { | |||
| 413 | RGB_SAD, | 413 | RGB_SAD, |
| 414 | RGB_VAI, | 414 | RGB_VAI, |
| 415 | RGB_VAD, | 415 | RGB_VAD, |
| 416 | RGB_SPI, | ||
| 417 | RGB_SPD, | ||
| 416 | RGB_MODE_PLAIN, | 418 | RGB_MODE_PLAIN, |
| 417 | RGB_MODE_BREATHE, | 419 | RGB_MODE_BREATHE, |
| 418 | RGB_MODE_RAINBOW, | 420 | RGB_MODE_RAINBOW, |
diff --git a/quantum/rgb.h b/quantum/rgb.h index fbdda293f..ce674ce6b 100644 --- a/quantum/rgb.h +++ b/quantum/rgb.h | |||
| @@ -44,4 +44,10 @@ void rgblight_increase_val(void) {}; | |||
| 44 | __attribute__((weak)) | 44 | __attribute__((weak)) |
| 45 | void rgblight_decrease_val(void) {}; | 45 | void rgblight_decrease_val(void) {}; |
| 46 | 46 | ||
| 47 | __attribute__((weak)) | ||
| 48 | void rgblight_increase_speed(void) {}; | ||
| 49 | |||
| 50 | __attribute__((weak)) | ||
| 51 | void rgblight_decrease_speed(void) {}; | ||
| 52 | |||
| 47 | #endif \ No newline at end of file | 53 | #endif \ No newline at end of file |
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 6cb0478f7..558e28dec 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
| @@ -69,6 +69,7 @@ void eeconfig_update_rgb_matrix_default(void) { | |||
| 69 | rgb_matrix_config.hue = 0; | 69 | rgb_matrix_config.hue = 0; |
| 70 | rgb_matrix_config.sat = 255; | 70 | rgb_matrix_config.sat = 255; |
| 71 | rgb_matrix_config.val = 255; | 71 | rgb_matrix_config.val = 255; |
| 72 | rgb_matrix_config.speed = 0; | ||
| 72 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 73 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 73 | } | 74 | } |
| 74 | void eeconfig_debug_rgb_matrix(void) { | 75 | void eeconfig_debug_rgb_matrix(void) { |
| @@ -78,6 +79,7 @@ void eeconfig_debug_rgb_matrix(void) { | |||
| 78 | dprintf("rgb_matrix_config.hue = %d\n", rgb_matrix_config.hue); | 79 | dprintf("rgb_matrix_config.hue = %d\n", rgb_matrix_config.hue); |
| 79 | dprintf("rgb_matrix_config.sat = %d\n", rgb_matrix_config.sat); | 80 | dprintf("rgb_matrix_config.sat = %d\n", rgb_matrix_config.sat); |
| 80 | dprintf("rgb_matrix_config.val = %d\n", rgb_matrix_config.val); | 81 | dprintf("rgb_matrix_config.val = %d\n", rgb_matrix_config.val); |
| 82 | dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed); | ||
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | // Last led hit | 85 | // Last led hit |
| @@ -343,7 +345,7 @@ void rgb_matrix_raindrops(bool initialize) { | |||
| 343 | } | 345 | } |
| 344 | 346 | ||
| 345 | void rgb_matrix_cycle_all(void) { | 347 | void rgb_matrix_cycle_all(void) { |
| 346 | uint8_t offset = g_tick & 0xFF; | 348 | uint8_t offset = ( g_tick << rgb_matrix_config.speed ) & 0xFF; |
| 347 | 349 | ||
| 348 | rgb_led led; | 350 | rgb_led led; |
| 349 | 351 | ||
| @@ -364,7 +366,7 @@ void rgb_matrix_cycle_all(void) { | |||
| 364 | } | 366 | } |
| 365 | 367 | ||
| 366 | void rgb_matrix_cycle_left_right(void) { | 368 | void rgb_matrix_cycle_left_right(void) { |
| 367 | uint8_t offset = g_tick & 0xFF; | 369 | uint8_t offset = ( g_tick << rgb_matrix_config.speed ) & 0xFF; |
| 368 | HSV hsv = { .h = 0, .s = 255, .v = rgb_matrix_config.val }; | 370 | HSV hsv = { .h = 0, .s = 255, .v = rgb_matrix_config.val }; |
| 369 | RGB rgb; | 371 | RGB rgb; |
| 370 | Point point; | 372 | Point point; |
| @@ -388,7 +390,7 @@ void rgb_matrix_cycle_left_right(void) { | |||
| 388 | } | 390 | } |
| 389 | 391 | ||
| 390 | void rgb_matrix_cycle_up_down(void) { | 392 | void rgb_matrix_cycle_up_down(void) { |
| 391 | uint8_t offset = g_tick & 0xFF; | 393 | uint8_t offset = ( g_tick << rgb_matrix_config.speed ) & 0xFF; |
| 392 | HSV hsv = { .h = 0, .s = 255, .v = rgb_matrix_config.val }; | 394 | HSV hsv = { .h = 0, .s = 255, .v = rgb_matrix_config.val }; |
| 393 | RGB rgb; | 395 | RGB rgb; |
| 394 | Point point; | 396 | Point point; |
| @@ -863,6 +865,16 @@ void rgblight_decrease_val(void) { | |||
| 863 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 865 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
| 864 | } | 866 | } |
| 865 | 867 | ||
| 868 | void rgblight_increase_speed(void) { | ||
| 869 | rgb_matrix_config.speed = increment( rgb_matrix_config.speed, 1, 0, 3 ); | ||
| 870 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this | ||
| 871 | } | ||
| 872 | |||
| 873 | void rgblight_decrease_speed(void) { | ||
| 874 | rgb_matrix_config.speed = decrement( rgb_matrix_config.speed, 1, 0, 3 ); | ||
| 875 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this | ||
| 876 | } | ||
| 877 | |||
| 866 | void rgblight_mode(uint8_t mode) { | 878 | void rgblight_mode(uint8_t mode) { |
| 867 | rgb_matrix_config.mode = mode; | 879 | rgb_matrix_config.mode = mode; |
| 868 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 880 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); |
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index ef93c6d5c..1552d5910 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h | |||
| @@ -58,6 +58,7 @@ typedef union { | |||
| 58 | uint16_t hue :9; | 58 | uint16_t hue :9; |
| 59 | uint8_t sat :8; | 59 | uint8_t sat :8; |
| 60 | uint8_t val :8; | 60 | uint8_t val :8; |
| 61 | uint8_t speed :8;//EECONFIG needs to be increased to support this | ||
| 61 | }; | 62 | }; |
| 62 | } rgb_config_t; | 63 | } rgb_config_t; |
| 63 | 64 | ||
| @@ -129,6 +130,8 @@ void rgblight_increase_sat(void); | |||
| 129 | void rgblight_decrease_sat(void); | 130 | void rgblight_decrease_sat(void); |
| 130 | void rgblight_increase_val(void); | 131 | void rgblight_increase_val(void); |
| 131 | void rgblight_decrease_val(void); | 132 | void rgblight_decrease_val(void); |
| 133 | void rgblight_increase_speed(void); | ||
| 134 | void rgblight_decrease_speed(void); | ||
| 132 | void rgblight_mode(uint8_t mode); | 135 | void rgblight_mode(uint8_t mode); |
| 133 | uint32_t rgblight_get_mode(void); | 136 | uint32_t rgblight_get_mode(void); |
| 134 | 137 | ||
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index ae1834408..75512e97a 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -27,6 +27,9 @@ | |||
| 27 | #define RGBLIGHT_LIMIT_VAL 255 | 27 | #define RGBLIGHT_LIMIT_VAL 255 |
| 28 | #endif | 28 | #endif |
| 29 | 29 | ||
| 30 | #define MIN(a,b) (((a)<(b))?(a):(b)) | ||
| 31 | #define MAX(a,b) (((a)>(b))?(a):(b)) | ||
| 32 | |||
| 30 | __attribute__ ((weak)) | 33 | __attribute__ ((weak)) |
| 31 | const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; | 34 | const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; |
| 32 | __attribute__ ((weak)) | 35 | __attribute__ ((weak)) |
| @@ -122,6 +125,7 @@ void eeconfig_update_rgblight_default(void) { | |||
| 122 | rgblight_config.hue = 0; | 125 | rgblight_config.hue = 0; |
| 123 | rgblight_config.sat = 255; | 126 | rgblight_config.sat = 255; |
| 124 | rgblight_config.val = RGBLIGHT_LIMIT_VAL; | 127 | rgblight_config.val = RGBLIGHT_LIMIT_VAL; |
| 128 | rgblight_config.speed = 0; | ||
| 125 | eeconfig_update_rgblight(rgblight_config.raw); | 129 | eeconfig_update_rgblight(rgblight_config.raw); |
| 126 | } | 130 | } |
| 127 | void eeconfig_debug_rgblight(void) { | 131 | void eeconfig_debug_rgblight(void) { |
| @@ -131,6 +135,7 @@ void eeconfig_debug_rgblight(void) { | |||
| 131 | dprintf("rgblight_config.hue = %d\n", rgblight_config.hue); | 135 | dprintf("rgblight_config.hue = %d\n", rgblight_config.hue); |
| 132 | dprintf("rgblight_config.sat = %d\n", rgblight_config.sat); | 136 | dprintf("rgblight_config.sat = %d\n", rgblight_config.sat); |
| 133 | dprintf("rgblight_config.val = %d\n", rgblight_config.val); | 137 | dprintf("rgblight_config.val = %d\n", rgblight_config.val); |
| 138 | dprintf("rgblight_config.speed = %d\n", rgblight_config.speed); | ||
| 134 | } | 139 | } |
| 135 | 140 | ||
| 136 | void rgblight_init(void) { | 141 | void rgblight_init(void) { |
| @@ -280,6 +285,18 @@ void rgblight_disable(void) { | |||
| 280 | rgblight_set(); | 285 | rgblight_set(); |
| 281 | } | 286 | } |
| 282 | 287 | ||
| 288 | // Deals with the messy details of incrementing an integer | ||
| 289 | uint8_t increment( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { | ||
| 290 | int16_t new_value = value; | ||
| 291 | new_value += step; | ||
| 292 | return MIN( MAX( new_value, min ), max ); | ||
| 293 | } | ||
| 294 | |||
| 295 | uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max ) { | ||
| 296 | int16_t new_value = value; | ||
| 297 | new_value -= step; | ||
| 298 | return MIN( MAX( new_value, min ), max ); | ||
| 299 | } | ||
| 283 | 300 | ||
| 284 | void rgblight_increase_hue(void) { | 301 | void rgblight_increase_hue(void) { |
| 285 | uint16_t hue; | 302 | uint16_t hue; |
| @@ -331,6 +348,15 @@ void rgblight_decrease_val(void) { | |||
| 331 | } | 348 | } |
| 332 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val); | 349 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val); |
| 333 | } | 350 | } |
| 351 | void rgblight_increase_speed(void) { | ||
| 352 | rgblight_config.speed = increment( rgblight_config.speed, 1, 0, 3 ); | ||
| 353 | eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this | ||
| 354 | } | ||
| 355 | |||
| 356 | void rgblight_decrease_speed(void) { | ||
| 357 | rgblight_config.speed = decrement( rgblight_config.speed, 1, 0, 3 ); | ||
| 358 | eeconfig_update_rgblight(rgblight_config.raw);//EECONFIG needs to be increased to support this | ||
| 359 | } | ||
| 334 | 360 | ||
| 335 | void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { | 361 | void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { |
| 336 | inmem_config.raw = rgblight_config.raw; | 362 | inmem_config.raw = rgblight_config.raw; |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 8c33f1a8f..a6593af98 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
| @@ -92,6 +92,7 @@ typedef union { | |||
| 92 | uint16_t hue :9; | 92 | uint16_t hue :9; |
| 93 | uint8_t sat :8; | 93 | uint8_t sat :8; |
| 94 | uint8_t val :8; | 94 | uint8_t val :8; |
| 95 | uint8_t speed :8;//EECONFIG needs to be increased to support this | ||
| 95 | }; | 96 | }; |
| 96 | } rgblight_config_t; | 97 | } rgblight_config_t; |
| 97 | 98 | ||
| @@ -113,6 +114,8 @@ void rgblight_increase_sat(void); | |||
| 113 | void rgblight_decrease_sat(void); | 114 | void rgblight_decrease_sat(void); |
| 114 | void rgblight_increase_val(void); | 115 | void rgblight_increase_val(void); |
| 115 | void rgblight_decrease_val(void); | 116 | void rgblight_decrease_val(void); |
| 117 | void rgblight_increase_speed(void); | ||
| 118 | void rgblight_decrease_speed(void); | ||
| 116 | void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val); | 119 | void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val); |
| 117 | uint16_t rgblight_get_hue(void); | 120 | uint16_t rgblight_get_hue(void); |
| 118 | uint8_t rgblight_get_sat(void); | 121 | uint8_t rgblight_get_sat(void); |
| @@ -126,6 +129,9 @@ void eeconfig_update_rgblight(uint32_t val); | |||
| 126 | void eeconfig_update_rgblight_default(void); | 129 | void eeconfig_update_rgblight_default(void); |
| 127 | void eeconfig_debug_rgblight(void); | 130 | void eeconfig_debug_rgblight(void); |
| 128 | 131 | ||
| 132 | void rgb_matrix_increase(void); | ||
| 133 | void rgb_matrix_decrease(void); | ||
| 134 | |||
| 129 | void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); | 135 | void sethsv(uint16_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); |
| 130 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); | 136 | void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); |
| 131 | void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); | 137 | void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); |
