X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=quantum%2Frgblight.c;h=52a09817a1e46a48697bb1f6329ba64166b586ea;hb=a8a1fbbac8cd941bc0b12a112fe4b06c780bc13e;hp=bb03d6e913890eb4ac6dcebe208895ad3e38a272;hpb=2e23689b8e3222982082c1f5a4f8ce7686f9658b;p=qmk_firmware.git diff --git a/quantum/rgblight.c b/quantum/rgblight.c index bb03d6e91..52a09817a 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -370,6 +370,7 @@ void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { rgblight_set(); } +__attribute__ ((weak)) void rgblight_set(void) { if (rgblight_config.enable) { #ifdef RGBW @@ -425,6 +426,12 @@ void rgblight_timer_toggle(void) { dprintf("TIMER3 toggled.\n"); } +void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) { + rgblight_enable(); + rgblight_mode(1); + rgblight_setrgb(r, g, b); +} + void rgblight_task(void) { if (rgblight_timer_enabled) { // mode = 1, static light, do nothing here @@ -443,6 +450,9 @@ void rgblight_task(void) { } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) { // mode = 21 to 23, knight mode rgblight_effect_knight(rgblight_config.mode - 21); + } else { + // mode = 24, christmas mode + rgblight_effect_christmas(); } } } @@ -588,4 +598,22 @@ void rgblight_effect_knight(uint8_t interval) { } } + +void rgblight_effect_christmas(void) { + static uint16_t current_offset = 0; + static uint16_t last_timer = 0; + uint16_t hue; + uint8_t i; + if (timer_elapsed(last_timer) < 1000) { + return; + } + last_timer = timer_read(); + current_offset = (current_offset + 1) % 2; + for (i = 0; i < RGBLED_NUM; i++) { + hue = 0 + ((RGBLED_NUM * (i + current_offset)) % 2) * 80; + sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); + } + rgblight_set(); +} + #endif