diff options
Diffstat (limited to 'quantum/rgblight.c')
| -rw-r--r-- | quantum/rgblight.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 78072a61d..63eda47cd 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -245,17 +245,12 @@ void rgblight_mode(uint8_t mode) { | |||
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | void rgblight_toggle(void) { | 247 | void rgblight_toggle(void) { |
| 248 | rgblight_config.enable ^= 1; | 248 | xprintf("rgblight toggle: rgblight_config.enable = %u\n", !rgblight_config.enable); |
| 249 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 250 | xprintf("rgblight toggle: rgblight_config.enable = %u\n", rgblight_config.enable); | ||
| 251 | if (rgblight_config.enable) { | 249 | if (rgblight_config.enable) { |
| 252 | rgblight_mode(rgblight_config.mode); | 250 | rgblight_disable(); |
| 253 | } else { | 251 | } |
| 254 | #ifdef RGBLIGHT_ANIMATIONS | 252 | else { |
| 255 | rgblight_timer_disable(); | 253 | rgblight_enable(); |
| 256 | #endif | ||
| 257 | _delay_ms(50); | ||
| 258 | rgblight_set(); | ||
| 259 | } | 254 | } |
| 260 | } | 255 | } |
| 261 | 256 | ||
| @@ -266,6 +261,17 @@ void rgblight_enable(void) { | |||
| 266 | rgblight_mode(rgblight_config.mode); | 261 | rgblight_mode(rgblight_config.mode); |
| 267 | } | 262 | } |
| 268 | 263 | ||
| 264 | void rgblight_disable(void) { | ||
| 265 | rgblight_config.enable = 0; | ||
| 266 | eeconfig_update_rgblight(rgblight_config.raw); | ||
| 267 | xprintf("rgblight disable: rgblight_config.enable = %u\n", rgblight_config.enable); | ||
| 268 | #ifdef RGBLIGHT_ANIMATIONS | ||
| 269 | rgblight_timer_disable(); | ||
| 270 | #endif | ||
| 271 | _delay_ms(50); | ||
| 272 | rgblight_set(); | ||
| 273 | } | ||
| 274 | |||
| 269 | 275 | ||
| 270 | void rgblight_increase_hue(void) { | 276 | void rgblight_increase_hue(void) { |
| 271 | uint16_t hue; | 277 | uint16_t hue; |
| @@ -365,7 +371,8 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { | |||
| 365 | } | 371 | } |
| 366 | 372 | ||
| 367 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { | 373 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { |
| 368 | // dprintf("rgblight set rgb: %u,%u,%u\n", r,g,b); | 374 | if (!rgblight_config.enable) { return; } |
| 375 | |||
| 369 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { | 376 | for (uint8_t i = 0; i < RGBLED_NUM; i++) { |
| 370 | led[i].r = r; | 377 | led[i].r = r; |
| 371 | led[i].g = g; | 378 | led[i].g = g; |
| @@ -374,6 +381,23 @@ void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { | |||
| 374 | rgblight_set(); | 381 | rgblight_set(); |
| 375 | } | 382 | } |
| 376 | 383 | ||
| 384 | void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index) { | ||
| 385 | if (!rgblight_config.enable || index >= RGBLED_NUM) { return; } | ||
| 386 | |||
| 387 | led[index].r = r; | ||
| 388 | led[index].g = g; | ||
| 389 | led[index].b = b; | ||
| 390 | rgblight_set(); | ||
| 391 | } | ||
| 392 | |||
| 393 | void rgblight_sethsv_at(uint16_t hue, uint8_t sat, uint8_t val, uint8_t index) { | ||
| 394 | if (!rgblight_config.enable) { return; } | ||
| 395 | |||
| 396 | LED_TYPE tmp_led; | ||
| 397 | sethsv(hue, sat, val, &tmp_led); | ||
| 398 | rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index); | ||
| 399 | } | ||
| 400 | |||
| 377 | #ifndef RGBLIGHT_CUSTOM_DRIVER | 401 | #ifndef RGBLIGHT_CUSTOM_DRIVER |
| 378 | void rgblight_set(void) { | 402 | void rgblight_set(void) { |
| 379 | if (rgblight_config.enable) { | 403 | if (rgblight_config.enable) { |
