aboutsummaryrefslogtreecommitdiffstats
path: root/quantum/rgblight.h
diff options
context:
space:
mode:
authorNathan Gray <n8gray@n8gray.org>2020-03-10 12:50:01 -0700
committerGitHub <noreply@github.com>2020-03-10 12:50:01 -0700
commit2ffb08843ba59f0af0870335934bdb277fc85620 (patch)
treef38f760dd73bca0f7089ff8751eecc03a95f7256 /quantum/rgblight.h
parent2a8ccafe6e704eced2d383810e1061613871433e (diff)
downloadfirmware-2ffb08843ba59f0af0870335934bdb277fc85620.tar.gz
firmware-2ffb08843ba59f0af0870335934bdb277fc85620.tar.bz2
firmware-2ffb08843ba59f0af0870335934bdb277fc85620.zip
Feature: RGBLight layers (#7768)
* New feature: RGBLIGHT_LAYERS This feature allows users to define multiple independent layers of lighting that can be toggled on and off individually, making it easy to use your RGB lighting to indicate things like active keyboard layer & modifier state. * Demonstrate built in functions for layer state checking Also link the video in the docs. * Follow existing pattern for setting rgblight_status flags * Eliminate rgblight_is_static_mode since it's not needed Just check to see if the timer is enabled directly.
Diffstat (limited to 'quantum/rgblight.h')
-rw-r--r--quantum/rgblight.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 39c4c2784..40f267daa 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -170,6 +170,29 @@ enum RGBLIGHT_EFFECT_MODE {
# include <avr/pgmspace.h>
# endif
+# ifdef RGBLIGHT_LAYERS
+typedef struct {
+ uint8_t index; // The first LED to light
+ uint8_t count; // The number of LEDs to light
+ uint8_t hue;
+ uint8_t sat;
+ uint8_t val;
+} rgblight_segment_t;
+
+# define RGBLIGHT_END_SEGMENT_INDEX (255)
+# define RGBLIGHT_END_SEGMENTS {RGBLIGHT_END_SEGMENT_INDEX, 0, 0, 0}
+# define RGBLIGHT_MAX_LAYERS 8
+# define RGBLIGHT_LAYER_SEGMENTS(...) { __VA_ARGS__, RGBLIGHT_END_SEGMENTS }
+# define RGBLIGHT_LAYERS_LIST(...) { __VA_ARGS__, NULL }
+
+// Get/set enabled rgblight layers
+void rgblight_set_layer_state(uint8_t layer, bool enabled);
+bool rgblight_get_layer_state(uint8_t layer);
+
+// Point this to an array of rgblight_segment_t arrays in keyboard_post_init_user to use rgblight layers
+extern const rgblight_segment_t * const * rgblight_layers;
+# endif
+
extern LED_TYPE led[RGBLED_NUM];
extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM;
@@ -199,6 +222,9 @@ typedef struct _rgblight_status_t {
# ifdef RGBLIGHT_SPLIT
uint8_t change_flags;
# endif
+# ifdef RGBLIGHT_LAYERS
+ uint8_t enabled_layer_mask;
+# endif
} rgblight_status_t;
/* === Utility Functions ===*/
@@ -313,6 +339,7 @@ void rgblight_timer_toggle(void);
# define RGBLIGHT_STATUS_CHANGE_HSVS (1 << 1)
# define RGBLIGHT_STATUS_CHANGE_TIMER (1 << 2)
# define RGBLIGHT_STATUS_ANIMATION_TICK (1 << 3)
+# define RGBLIGHT_STATUS_CHANGE_LAYERS (1 << 4)
typedef struct _rgblight_syncinfo_t {
rgblight_config_t config;