diff options
| author | yiancar <yiangosyiangou@cytanet.com.cy> | 2018-05-09 04:23:21 +0100 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2018-05-08 23:23:21 -0400 |
| commit | afacd42368e0dc7627a695508f15598b38429c63 (patch) | |
| tree | 8228c3f9974282e0f8f506bcce5489616ce3e684 /quantum/rgblight.c | |
| parent | 23df5fb89a05ead778b25fe1e586e47df6209c6d (diff) | |
| download | qmk_firmware-afacd42368e0dc7627a695508f15598b38429c63.tar.gz qmk_firmware-afacd42368e0dc7627a695508f15598b38429c63.zip | |
Add effect speed support for RGB Matrix *No EEPROM yet* (#2922)
* Added Modular keyboards L,R and NUM
Created code modules for the 3 modules of the modular keyboard.
Original idea by MechboardsUK. Uses i2c implementation similar to lets
split
* Remove modular from master
This is to fix incorrect branching
* Add effect speed support for RGB Matrix *No eeprom yet*
Keycodes RGB_SPI and RGB_SPD have been added to increase and decrease effect speed.
Speed is not saved in EEPROM yet as per Jack's request.
* Update rgb_matrix.c
* RGB Matrix speed fix rgblight.h
* More fixes for rgb speed. Speed functions declared but not used in rgblight
* More travis fixes..
* Another one for travis..
Diffstat (limited to 'quantum/rgblight.c')
| -rw-r--r-- | quantum/rgblight.c | 26 |
1 files changed, 26 insertions, 0 deletions
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; |
