From 748181dccddb8c9fa52a776f4fcd904ddca9aa31 Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Wed, 28 Dec 2016 16:29:02 -0500 Subject: Add extern for 'led' global, set 'weak' attribute for rgblight_set() --- quantum/rgblight.c | 1 + 1 file changed, 1 insertion(+) (limited to 'quantum/rgblight.c') diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 6e335a483..0f7a1d828 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 -- cgit v1.2.3-24-g4f1b From b8e74c378b1f118178edf0634d9fa7f0f9dd5e08 Mon Sep 17 00:00:00 2001 From: Scott Wilson Date: Thu, 29 Dec 2016 09:32:02 -0500 Subject: Removed errant + --- quantum/rgblight.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum/rgblight.c') diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 0f7a1d828..52a09817a 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -370,7 +370,7 @@ void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { rgblight_set(); } -+__attribute__ ((weak)) +__attribute__ ((weak)) void rgblight_set(void) { if (rgblight_config.enable) { #ifdef RGBW -- cgit v1.2.3-24-g4f1b From 0e548f8b5d6b89de877f098ea919eaea87511b6e Mon Sep 17 00:00:00 2001 From: dungdung Date: Mon, 6 Feb 2017 14:08:21 -0800 Subject: Christmas mode now works with even RGBED_NUM Added Christmas mode steps to reduce red and green colors blending into each other Added Christmas mode interval Increased green hue to 120 --- quantum/rgblight.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'quantum/rgblight.c') diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 52a09817a..f91f3caff 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -237,7 +237,7 @@ void rgblight_mode(uint8_t mode) { #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_disable(); #endif - } else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 23) { + } else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 24) { // MODE 2-5, breathing // MODE 6-8, rainbow mood // MODE 9-14, rainbow swirl @@ -450,7 +450,7 @@ 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 { + } else if (rgblight_config.mode == 24) { // mode = 24, christmas mode rgblight_effect_christmas(); } @@ -604,13 +604,13 @@ void rgblight_effect_christmas(void) { static uint16_t last_timer = 0; uint16_t hue; uint8_t i; - if (timer_elapsed(last_timer) < 1000) { + if (timer_elapsed(last_timer) < RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL) { 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; + hue = 0 + ((i/RGBLIGHT_EFFECT_CHRISTMAS_STEP + current_offset) % 2) * 120; sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i]); } rgblight_set(); -- cgit v1.2.3-24-g4f1b From 5a1b68d562036ff26820069baafe40654eef70a3 Mon Sep 17 00:00:00 2001 From: dungdung Date: Mon, 6 Feb 2017 14:09:29 -0800 Subject: Added mode reverse step function --- quantum/rgblight.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'quantum/rgblight.c') diff --git a/quantum/rgblight.c b/quantum/rgblight.c index f91f3caff..7e057b63e 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -219,6 +219,14 @@ void rgblight_step(void) { } rgblight_mode(mode); } +void rgblight_step_reverse(void) { + uint8_t mode = 0; + mode = rgblight_config.mode - 1; + if (mode < 1) { + mode = RGBLIGHT_MODES; + } + rgblight_mode(mode); +} void rgblight_mode(uint8_t mode) { if (!rgblight_config.enable) { -- cgit v1.2.3-24-g4f1b From a7882b1ffceb6002dd1adf916a8fc32523227860 Mon Sep 17 00:00:00 2001 From: dungdung Date: Mon, 6 Feb 2017 14:14:56 -0800 Subject: Added non-animated gradient mode --- quantum/rgblight.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'quantum/rgblight.c') 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)) const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; __attribute__ ((weak)) const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {100, 50, 20}; +__attribute__ ((weak)) +const uint16_t RGBLED_GRADIENT_RANGES[] PROGMEM = {360, 240, 180, 120, 90}; rgblight_config_t rgblight_config; rgblight_config_t inmem_config; @@ -255,6 +257,12 @@ void rgblight_mode(uint8_t mode) { #ifdef RGBLIGHT_ANIMATIONS rgblight_timer_enable(); #endif + } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) { + // MODE 25-34, static gradient + + #ifdef RGBLIGHT_ANIMATIONS + rgblight_timer_disable(); + #endif } rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); } @@ -358,6 +366,17 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) { // rainbow mood and rainbow swirl, ignore the change of hue hue = rgblight_config.hue; + } else if (rgblight_config.mode >= 25 && rgblight_config.mode <= 34) { + // static gradient + uint16_t _hue; + int8_t direction = ((rgblight_config.mode - 25) % 2) ? -1 : 1; + uint16_t range = pgm_read_word(&RGBLED_GRADIENT_RANGES[(rgblight_config.mode - 25) / 2]); + for (uint8_t i = 0; i < RGBLED_NUM; i++) { + _hue = (range / RGBLED_NUM * i * direction + hue + 360) % 360; + dprintf("rgblight rainbow set hsv: %u,%u,%d,%u\n", i, _hue, direction, range); + sethsv(_hue, sat, val, (LED_TYPE *)&led[i]); + } + rgblight_set(); } } rgblight_config.hue = hue; -- cgit v1.2.3-24-g4f1b From 23839b8c6d2f955e4da89b0981948c721346c528 Mon Sep 17 00:00:00 2001 From: skullydazed Date: Tue, 28 Mar 2017 15:20:36 -0700 Subject: Clarify the quantum license (#1042) * Clarify the license for files we have signoff on * Update against the currently signed off files * Remove unused and not clearly licensed headers * Replace an #endif I accidentally removed while resolving merge conflicts --- quantum/rgblight.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'quantum/rgblight.c') diff --git a/quantum/rgblight.c b/quantum/rgblight.c index dd1b91c63..eff70aae1 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -1,3 +1,18 @@ +/* Copyright 2016-2017 Yang Liu + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include #include #include -- cgit v1.2.3-24-g4f1b