summaryrefslogtreecommitdiffstats
path: root/quantum/rgblight
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgblight')
-rw-r--r--quantum/rgblight/rgblight.c60
-rw-r--r--quantum/rgblight/rgblight.h1
-rw-r--r--quantum/rgblight/rgblight_list.h136
3 files changed, 40 insertions, 157 deletions
diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c
index e5d3a98bea..f832854c5f 100644
--- a/quantum/rgblight/rgblight.c
+++ b/quantum/rgblight/rgblight.c
@@ -16,7 +16,6 @@
#include <math.h>
#include <string.h>
#include <stdlib.h>
-#include "wait.h"
#include "progmem.h"
#include "sync_timer.h"
#include "rgblight.h"
@@ -128,6 +127,8 @@ LED_TYPE led[RGBLED_NUM];
#ifdef RGBLIGHT_LAYERS
rgblight_segment_t const *const *rgblight_layers = NULL;
+
+static bool deferred_set_layer_state = false;
#endif
rgblight_ranges_t rgblight_ranges = {0, RGBLED_NUM, 0, RGBLED_NUM, RGBLED_NUM};
@@ -410,7 +411,6 @@ void rgblight_disable(void) {
dprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
rgblight_timer_disable();
RGBLIGHT_SPLIT_SET_CHANGE_MODE;
- wait_ms(50);
rgblight_set();
}
@@ -419,7 +419,6 @@ void rgblight_disable_noeeprom(void) {
dprintf("rgblight disable [NOEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable);
rgblight_timer_disable();
RGBLIGHT_SPLIT_SET_CHANGE_MODE;
- wait_ms(50);
rgblight_set();
}
@@ -526,10 +525,19 @@ void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) {
void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) {
if (rgblight_config.enable) {
+#ifdef RGBLIGHT_SPLIT
+ if (rgblight_config.hue != hue || rgblight_config.sat != sat || rgblight_config.val != val) {
+ RGBLIGHT_SPLIT_SET_CHANGE_HSVS;
+ }
+#endif
rgblight_status.base_mode = mode_base_table[rgblight_config.mode];
if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) {
// same static color
LED_TYPE tmp_led;
+#ifdef RGBLIGHT_LAYERS_RETAIN_VAL
+ // needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val
+ rgblight_config.val = val;
+#endif
sethsv(hue, sat, val, &tmp_led);
rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
} else {
@@ -571,15 +579,14 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w
dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range);
sethsv(_hue, sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]);
}
+# ifdef RGBLIGHT_LAYERS_RETAIN_VAL
+ // needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val
+ rgblight_config.val = val;
+# endif
rgblight_set();
}
#endif
}
-#ifdef RGBLIGHT_SPLIT
- if (rgblight_config.hue != hue || rgblight_config.sat != sat || rgblight_config.val != val) {
- RGBLIGHT_SPLIT_SET_CHANGE_HSVS;
- }
-#endif
rgblight_config.hue = hue;
rgblight_config.sat = sat;
rgblight_config.val = val;
@@ -704,7 +711,6 @@ void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8
#endif
}
rgblight_set();
- wait_ms(1);
}
void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) {
@@ -744,17 +750,13 @@ void rgblight_set_layer_state(uint8_t layer, bool enabled) {
rgblight_status.enabled_layer_mask &= ~mask;
}
RGBLIGHT_SPLIT_SET_CHANGE_LAYERS;
- // Static modes don't have a ticker running to update the LEDs
- if (rgblight_status.timer_enabled == false) {
- rgblight_mode_noeeprom(rgblight_config.mode);
- }
-# ifdef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF
- // If not enabled, then nothing else will actually set the LEDs...
- if (!rgblight_config.enable) {
- rgblight_set();
- }
-# endif
+ // Calling rgblight_set() here (directly or indirectly) could
+ // potentially cause timing issues when there are multiple
+ // successive calls to rgblight_set_layer_state(). Instead,
+ // set a flag and do it the next time rgblight_task() runs.
+
+ deferred_set_layer_state = true;
}
bool rgblight_get_layer_state(uint8_t layer) {
@@ -1150,8 +1152,26 @@ void rgblight_task(void) {
}
}
-# ifdef RGBLIGHT_LAYER_BLINK
+# ifdef RGBLIGHT_LAYERS
+# ifdef RGBLIGHT_LAYER_BLINK
rgblight_blink_layer_repeat_helper();
+# endif
+
+ if (deferred_set_layer_state) {
+ deferred_set_layer_state = false;
+
+ // Static modes don't have a ticker running to update the LEDs
+ if (rgblight_status.timer_enabled == false) {
+ rgblight_mode_noeeprom(rgblight_config.mode);
+ }
+
+# ifdef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF
+ // If not enabled, then nothing else will actually set the LEDs...
+ if (!rgblight_config.enable) {
+ rgblight_set();
+ }
+# endif
+ }
# endif
}
diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h
index a08b9a7b6b..46e8e07212 100644
--- a/quantum/rgblight/rgblight.h
+++ b/quantum/rgblight/rgblight.h
@@ -181,7 +181,6 @@ enum RGBLIGHT_EFFECT_MODE {
#include "eeconfig.h"
#include "ws2812.h"
#include "color.h"
-#include "rgblight_list.h"
#ifdef RGBLIGHT_LAYERS
typedef struct {
diff --git a/quantum/rgblight/rgblight_list.h b/quantum/rgblight/rgblight_list.h
deleted file mode 100644
index 0fd68b75f3..0000000000
--- a/quantum/rgblight/rgblight_list.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Copyright 2018 Jack Humbert
- *
- * 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 <http://www.gnu.org/licenses/>.
- */
-#pragma once
-
-#include "color.h"
-
-/*
-########################################################################################
-## ##
-## ##
-## ##
-## The functions below have been deprecated and may be removed in a future release. ##
-## ##
-## Please use the values in color.h with the RGB functions. ##
-## ##
-## ##
-## ##
-########################################################################################
-*/
-
-/* SET RGB List */
-#define rgblight_setrgb_white() rgblight_setrgb(RGB_WHITE)
-#define rgblight_setrgb_red() rgblight_setrgb(RGB_RED)
-#define rgblight_setrgb_coral() rgblight_setrgb(RGB_CORAL)
-#define rgblight_setrgb_orange() rgblight_setrgb(RGB_ORANGE)
-#define rgblight_setrgb_goldenrod() rgblight_setrgb(RGB_GOLDENROD)
-#define rgblight_setrgb_gold() rgblight_setrgb(RGB_GOLD)
-#define rgblight_setrgb_yellow() rgblight_setrgb(RGB_YELLOW)
-#define rgblight_setrgb_chartreuse() rgblight_setrgb(RGB_CHARTREUSE)
-#define rgblight_setrgb_green() rgblight_setrgb(RGB_GREEN)
-#define rgblight_setrgb_springgreen() rgblight_setrgb(RGB_SPRINGGREEN)
-#define rgblight_setrgb_turquoise() rgblight_setrgb(RGB_TURQUOISE)
-#define rgblight_setrgb_teal() rgblight_setrgb(RGB_TEAL)
-#define rgblight_setrgb_cyan() rgblight_setrgb(RGB_CYAN)
-#define rgblight_setrgb_azure() rgblight_setrgb(RGB_AZURE)
-#define rgblight_setrgb_blue() rgblight_setrgb(RGB_BLUE)
-#define rgblight_setrgb_purple() rgblight_setrgb(RGB_PURPLE)
-#define rgblight_setrgb_magenta() rgblight_setrgb(RGB_MAGENTA)
-#define rgblight_setrgb_pink() rgblight_setrgb(RGB_PINK)
-
-/* SET RGB List */
-#define rgblight_setrgb_white_at(at) rgblight_setrgb_at(RGB_WHITE, at)
-#define rgblight_setrgb_red_at(at) rgblight_setrgb_at(RGB_RED, at)
-#define rgblight_setrgb_coral_at(at) rgblight_setrgb_at(RGB_CORAL, at)
-#define rgblight_setrgb_orange_at(at) rgblight_setrgb_at(RGB_ORANGE at)
-#define rgblight_setrgb_goldenrod_at(at) rgblight_setrgb_at(RGB_GOLDENROD, at)
-#define rgblight_setrgb_gold_at(at) rgblight_setrgb_at(RGB_GOLD, at)
-#define rgblight_setrgb_yellow_at(at) rgblight_setrgb_at(RGB_YELLOW, at)
-#define rgblight_setrgb_chartreuse_at(at) rgblight_setrgb_at(RGB_CHARTREUSE, at)
-#define rgblight_setrgb_green_at(at) rgblight_setrgb_at(RGB_GREEN, at)
-#define rgblight_setrgb_springgreen_at(at) rgblight_setrgb_at(RGB_SPRINGGREEN, at)
-#define rgblight_setrgb_turquoise_at(at) rgblight_setrgb_at(RGB_TURQUOISE, at)
-#define rgblight_setrgb_teal_at(at) rgblight_setrgb_at(RGB_TEAL, at)
-#define rgblight_setrgb_cyan_at(at) rgblight_setrgb_at(RGB_CYAN, at)
-#define rgblight_setrgb_azure_at(at) rgblight_setrgb_at(RGB_AZURE, at)
-#define rgblight_setrgb_blue_at(at) rgblight_setrgb_at(RGB_BLUE, at)
-#define rgblight_setrgb_purple_at(at) rgblight_setrgb_at(RGB_PURPLE, at)
-#define rgblight_setrgb_magenta_at(at) rgblight_setrgb_at(RGB_MAGENTA, at)
-#define rgblight_setrgb_pink_at(at) rgblight_setrgb_at(RGB_PINK, at)
-
-/* SET HSV List */
-#define rgblight_sethsv_white() rgblight_sethsv(HSV_WHITE)
-#define rgblight_sethsv_red() rgblight_sethsv(HSV_RED)
-#define rgblight_sethsv_coral() rgblight_sethsv(HSV_CORAL)
-#define rgblight_sethsv_orange() rgblight_sethsv(HSV_ORANGE)
-#define rgblight_sethsv_goldenrod() rgblight_sethsv(HSV_GOLDENROD)
-#define rgblight_sethsv_gold() rgblight_sethsv(HSV_GOLD)
-#define rgblight_sethsv_yellow() rgblight_sethsv(HSV_YELLOW)
-#define rgblight_sethsv_chartreuse() rgblight_sethsv(HSV_CHARTREUSE)
-#define rgblight_sethsv_green() rgblight_sethsv(HSV_GREEN)
-#define rgblight_sethsv_springgreen() rgblight_sethsv(HSV_SPRINGGREEN)
-#define rgblight_sethsv_turquoise() rgblight_sethsv(HSV_TURQUOISE)
-#define rgblight_sethsv_teal() rgblight_sethsv(HSV_TEAL)
-#define rgblight_sethsv_cyan() rgblight_sethsv(HSV_CYAN)
-#define rgblight_sethsv_azure() rgblight_sethsv(HSV_AZURE)
-#define rgblight_sethsv_blue() rgblight_sethsv(HSV_BLUE)
-#define rgblight_sethsv_purple() rgblight_sethsv(HSV_PURPLE)
-#define rgblight_sethsv_magenta() rgblight_sethsv(HSV_MAGENTA)
-#define rgblight_sethsv_pink() rgblight_sethsv(HSV_PINK)
-
-/* SET HSV List */
-/* If you're doing layer indication, this is best, as it won't */
-/* write to the eeprom, since it's limited (very high value). */
-/* If you want to use modes with this (since you can), then you */
-/* want to use rgblight_mode_noeeprom(x) instead. */
-#define rgblight_sethsv_noeeprom_white() rgblight_sethsv_noeeprom(HSV_WHITE)
-#define rgblight_sethsv_noeeprom_red() rgblight_sethsv_noeeprom(HSV_RED)
-#define rgblight_sethsv_noeeprom_coral() rgblight_sethsv_noeeprom(HSV_CORAL)
-#define rgblight_sethsv_noeeprom_orange() rgblight_sethsv_noeeprom(HSV_ORANGE)
-#define rgblight_sethsv_noeeprom_goldenrod() rgblight_sethsv_noeeprom(HSV_GOLDENROD)
-#define rgblight_sethsv_noeeprom_gold() rgblight_sethsv_noeeprom(HSV_GOLD)
-#define rgblight_sethsv_noeeprom_yellow() rgblight_sethsv_noeeprom(HSV_YELLOW)
-#define rgblight_sethsv_noeeprom_chartreuse() rgblight_sethsv_noeeprom(HSV_CHARTREUSE)
-#define rgblight_sethsv_noeeprom_green() rgblight_sethsv_noeeprom(HSV_GREEN)
-#define rgblight_sethsv_noeeprom_springgreen() rgblight_sethsv_noeeprom(HSV_SPRINGGREEN)
-#define rgblight_sethsv_noeeprom_turquoise() rgblight_sethsv_noeeprom(HSV_TURQUOISE)
-#define rgblight_sethsv_noeeprom_teal() rgblight_sethsv_noeeprom(HSV_TEAL)
-#define rgblight_sethsv_noeeprom_cyan() rgblight_sethsv_noeeprom(HSV_CYAN)
-#define rgblight_sethsv_noeeprom_azure() rgblight_sethsv_noeeprom(HSV_AZURE)
-#define rgblight_sethsv_noeeprom_blue() rgblight_sethsv_noeeprom(HSV_BLUE)
-#define rgblight_sethsv_noeeprom_purple() rgblight_sethsv_noeeprom(HSV_PURPLE)
-#define rgblight_sethsv_noeeprom_magenta() rgblight_sethsv_noeeprom(HSV_MAGENTA)
-#define rgblight_sethsv_noeeprom_pink() rgblight_sethsv_noeeprom(HSV_PINK)
-
-/* SET HSV List */
-#define rgblight_sethsv_white_at(at) rgblight_sethsv_at(HSV_WHITE, at)
-#define rgblight_sethsv_red_at(at) rgblight_sethsv_at(HSV_RED, at)
-#define rgblight_sethsv_coral_at(at) rgblight_sethsv_at(HSV_CORAL, at)
-#define rgblight_sethsv_orange_at(at) rgblight_sethsv_at(HSV_ORANGE, at)
-#define rgblight_sethsv_goldenrod_at(at) rgblight_sethsv_at(HSV_GOLDENROD, at)
-#define rgblight_sethsv_gold_at(at) rgblight_sethsv_at(HSV_GOLD, at)
-#define rgblight_sethsv_yellow_at(at) rgblight_sethsv_at(HSV_YELLOW, at)
-#define rgblight_sethsv_chartreuse_at(at) rgblight_sethsv_at(HSV_CHARTREUSE, at)
-#define rgblight_sethsv_green_at(at) rgblight_sethsv_at(HSV_GREEN, at)
-#define rgblight_sethsv_springgreen_at(at) rgblight_sethsv_at(HSV_SPRINGGREEN, at)
-#define rgblight_sethsv_turquoise_at(at) rgblight_sethsv_at(HSV_TURQUOISE, at)
-#define rgblight_sethsv_teal_at(at) rgblight_sethsv_at(HSV_TEAL, at)
-#define rgblight_sethsv_cyan_at(at) rgblight_sethsv_at(HSV_CYAN, at)
-#define rgblight_sethsv_azure_at(at) rgblight_sethsv_at(HSV_AZURE, at)
-#define rgblight_sethsv_blue_at(at) rgblight_sethsv_at(HSV_BLUE, at)
-#define rgblight_sethsv_purple_at(at) rgblight_sethsv_at(HSV_PURPLE, at)
-#define rgblight_sethsv_magenta_at(at) rgblight_sethsv_at(HSV_MAGENTA, at)
-#define rgblight_sethsv_pink_at(at) rgblight_sethsv_at(HSV_PINK, at)