diff options
| author | dungdung <dungdung@users.noreply.github.com> | 2017-02-06 14:14:56 -0800 |
|---|---|---|
| committer | dungdung <dungdung@users.noreply.github.com> | 2017-02-06 14:18:20 -0800 |
| commit | a7882b1ffceb6002dd1adf916a8fc32523227860 (patch) | |
| tree | 2cdc663e9cab404bf1a96e9d153daf2e9e0bb8c7 /quantum | |
| parent | 5a1b68d562036ff26820069baafe40654eef70a3 (diff) | |
| download | qmk_firmware-a7882b1ffceb6002dd1adf916a8fc32523227860.tar.gz qmk_firmware-a7882b1ffceb6002dd1adf916a8fc32523227860.zip | |
Added non-animated gradient mode
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/rgblight.c | 19 | ||||
| -rw-r--r-- | quantum/rgblight.h | 2 |
2 files changed, 20 insertions, 1 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 7e057b63e..dd1b91c63 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -66,6 +66,8 @@ __attribute__ ((weak)) | |||
| 66 | const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; | 66 | const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; |
| 67 | __attribute__ ((weak)) | 67 | __attribute__ ((weak)) |
| 68 | const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20}; | 68 | const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20}; |
| 69 | __attribute__ ((weak)) | ||
| 70 | const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; | ||
| 69 | 71 | ||
| 70 | rgblight_config_t rgblight_config; | 72 | rgblight_config_t rgblight_config; |
| 71 | rgblight_config_t inmem_config; | 73 | rgblight_config_t inmem_config; |
| @@ -255,6 +257,12 @@ void rgblight_mode(uint8_t mode) { | |||
| 255 | #ifdef RGBLIGHT_ANIMATIONS | 257 | #ifdef RGBLIGHT_ANIMATIONS |
| 256 | rgblight_timer_enable(); | 258 | rgblight_timer_enable(); |
| 257 | #endif | 259 | #endif |
| 260 | } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) { | ||
| 261 | // MODE 25-34, static gradient | ||
| 262 | |||
| 263 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 264 | rgblight_timer_disable(); | ||
| 265 | #endif | ||
| 258 | } | 266 | } |
| 259 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); | 267 | rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); |
| 260 | } | 268 | } |
| @@ -358,6 +366,17 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { | |||
| 358 | } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) { | 366 | } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) { |
| 359 | // rainbow mood and rainbow swirl, ignore the change of hue | 367 | // rainbow mood and rainbow swirl, ignore the change of hue |
| 360 | hue = rgblight_config.hue; | 368 | hue = rgblight_config.hue; |
| 369 | } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) { | ||
| 370 | // static gradient | ||
| 371 | uint16_t _hue; | ||
| 372 | int8_t direction = ((rgblight_config.mode - 25) % 2) ? -1 : 1; | ||
| 373 | uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[(rgblight_config.mode - 25) / 2]); | ||
| 374 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | ||
| 375 | _hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360; | ||
| 376 | dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range); | ||
| 377 | sethsv(_hue, sat, val, (LED_TYPE *)&led[i]); | ||
| 378 | } | ||
| 379 | rgblight_set(); | ||
| 361 | } | 380 | } |
| 362 | } | 381 | } |
| 363 | rgblight_config.hue = hue; | 382 | rgblight_config.hue = hue; |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index a63b24604..2b3e791bf 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | #define RGBLIGHT_H | 2 | #define RGBLIGHT_H |
| 3 | 3 | ||
| 4 | #ifdef RGBLIGHT_ANIMATIONS | 4 | #ifdef RGBLIGHT_ANIMATIONS |
| 5 | #define RGBLIGHT_MODES 24 | 5 | #define RGBLIGHT_MODES 34 |
| 6 | #else | 6 | #else |
| 7 | #define RGBLIGHT_MODES 1 | 7 | #define RGBLIGHT_MODES 1 |
| 8 | #endif | 8 | #endif |
