diff options
author | Joshua Diamond <josh@windowoffire.com> | 2021-01-02 16:42:48 -0500 |
---|---|---|
committer | Drashna Jael're <drashna@live.com> | 2021-01-12 22:46:13 -0800 |
commit | ab717d2a52e7128a404ce4e0d3866bd70ca5e352 (patch) | |
tree | 52f569cc365563581554c7b0d735891bb1e4a1e3 | |
parent | 8f03f44ec773d4a917e1a81bc1102771cd04eb5c (diff) |
Fix broken Lighting Layers when RGBLIGHT_MAX_LAYERS > 16 (#11406)
* fix incorrect bit math when RGBLIGHT_MAX_LAYERS > 16
* with 1UL cast is not needed
* ...but just casting works and is even more efficient
* cformat
-rw-r--r-- | quantum/rgblight.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 11886a1ed0..bd805813c8 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -630,7 +630,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) { - rgblight_layer_mask_t mask = 1 << layer; + rgblight_layer_mask_t mask = (rgblight_layer_mask_t)1 << layer; if (enabled) { rgblight_status.enabled_layer_mask |= mask; } else { @@ -651,7 +651,7 @@ void rgblight_set_layer_state(uint8_t layer, bool enabled) { } bool rgblight_get_layer_state(uint8_t layer) { - rgblight_layer_mask_t mask = 1 << layer; + rgblight_layer_mask_t mask = (rgblight_layer_mask_t)1 << layer; return (rgblight_status.enabled_layer_mask & mask) != 0; } @@ -691,7 +691,7 @@ static uint16_t _blink_timer; void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { rgblight_set_layer_state(layer, true); - _blinked_layer_mask |= 1 << layer; + _blinked_layer_mask |= (rgblight_layer_mask_t)1 << layer; _blink_timer = timer_read(); _blink_duration = duration_ms; } @@ -699,7 +699,7 @@ void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { void rgblight_unblink_layers(void) { if (_blinked_layer_mask != 0 && timer_elapsed(_blink_timer) > _blink_duration) { for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) { - if ((_blinked_layer_mask & 1 << layer) != 0) { + if ((_blinked_layer_mask & (rgblight_layer_mask_t)1 << layer) != 0) { rgblight_set_layer_state(layer, false); } } |