diff options
author | Joshua Diamond <[email protected]> | 2020-05-13 16:39:05 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-13 21:39:05 +0100 |
commit | a8a8bf0ff3d6e1c9637079b925b30cf7eb8913fd (patch) | |
tree | 3e7f1d53536711151fb7f8aebe63ab4d41f1d298 /quantum | |
parent | fadd3cb4617fe7e48c802c4470a50df36e6c5109 (diff) | |
download | qmk_firmware-a8a8bf0ff3d6e1c9637079b925b30cf7eb8913fd.tar.gz qmk_firmware-a8a8bf0ff3d6e1c9637079b925b30cf7eb8913fd.zip |
Allow expanding from 8 to 32 RGB Lighting Layers (#8941)0.8.156
* Allow 16 lighting layers
* Require #define RGBLIGHT_LAYERS_16 to enable 16 layers
* Override RGBLIGHT_MAX_LAYERS to set maximum number of lighting layers
* Enforce lower bound on RGBLIGHT_MAX_LAYERS
Co-Authored-By: Takeshi ISHII <[email protected]>
* Fix an error in the check for valid RGBLIGHT_MAX_LAYERS
* Don't use bitfield / PACKED, as it causes bloat
* Update documentation re: up to 32 lighting layers
* Run cformat
* Add note about increasing FW size in docs/config_options.md
Co-authored-by: Drashna Jaelre <[email protected]>
* Remove no-longer-valid comment
* Add doc note that split sync will be slower
Co-authored-by: Takeshi ISHII <[email protected]>
Co-authored-by: Drashna Jaelre <[email protected]>
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/rgblight.c | 4 | ||||
-rw-r--r-- | quantum/rgblight.h | 17 |
2 files changed, 17 insertions, 4 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 4f227794fe..64123774c7 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -613,7 +613,7 @@ void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_set #ifdef RGBLIGHT_LAYERS void rgblight_set_layer_state(uint8_t layer, bool enabled) { - uint8_t mask = 1 << layer; + rgblight_layer_mask_t mask = 1 << layer; if (enabled) { rgblight_status.enabled_layer_mask |= mask; } else { @@ -627,7 +627,7 @@ void rgblight_set_layer_state(uint8_t layer, bool enabled) { } bool rgblight_get_layer_state(uint8_t layer) { - uint8_t mask = 1 << layer; + rgblight_layer_mask_t mask = 1 << layer; return (rgblight_status.enabled_layer_mask & mask) != 0; } diff --git a/quantum/rgblight.h b/quantum/rgblight.h index f93a30c5a5..6fc3b6f177 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h @@ -196,7 +196,20 @@ typedef struct { # define RGBLIGHT_END_SEGMENT_INDEX (255) # define RGBLIGHT_END_SEGMENTS \ { RGBLIGHT_END_SEGMENT_INDEX, 0, 0, 0 } -# define RGBLIGHT_MAX_LAYERS 8 +# ifndef RGBLIGHT_MAX_LAYERS +# define RGBLIGHT_MAX_LAYERS 8 +# endif +# if RGBLIGHT_MAX_LAYERS <= 0 +# error invalid RGBLIGHT_MAX_LAYERS value (must be >= 1) +# elif RGBLIGHT_MAX_LAYERS <= 8 +typedef uint8_t rgblight_layer_mask_t; +# elif RGBLIGHT_MAX_LAYERS <= 16 +typedef uint16_t rgblight_layer_mask_t; +# elif RGBLIGHT_MAX_LAYERS <= 32 +typedef uint32_t rgblight_layer_mask_t; +# else +# error invalid RGBLIGHT_MAX_LAYERS value (must be <= 32) +# endif # define RGBLIGHT_LAYER_SEGMENTS(...) \ { __VA_ARGS__, RGBLIGHT_END_SEGMENTS } # define RGBLIGHT_LAYERS_LIST(...) \ @@ -247,7 +260,7 @@ typedef struct _rgblight_status_t { uint8_t change_flags; # endif # ifdef RGBLIGHT_LAYERS - uint8_t enabled_layer_mask; + rgblight_layer_mask_t enabled_layer_mask; # endif } rgblight_status_t; |