diff options
| author | Joshua Diamond <josh@windowoffire.com> | 2021-01-02 16:42:48 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-02 13:42:48 -0800 |
| commit | b3de903a3dfe5f75312b6b8a7555ccabe01a5e6e (patch) | |
| tree | 561211e8c17960269b2f2628ecd6aa4f5562d162 /quantum/rgblight.c | |
| parent | c07543133a092039c7eae0cead6c9ee3badcc7dc (diff) | |
| download | qmk_firmware-b3de903a3dfe5f75312b6b8a7555ccabe01a5e6e.tar.gz qmk_firmware-b3de903a3dfe5f75312b6b8a7555ccabe01a5e6e.zip | |
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
Diffstat (limited to 'quantum/rgblight.c')
| -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 db725301c..beeef6568 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
| @@ -628,7 +628,7 @@ void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val) { rgblight_set | |||
| 628 | 628 | ||
| 629 | #ifdef RGBLIGHT_LAYERS | 629 | #ifdef RGBLIGHT_LAYERS |
| 630 | void rgblight_set_layer_state(uint8_t layer, bool enabled) { | 630 | void rgblight_set_layer_state(uint8_t layer, bool enabled) { |
| 631 | rgblight_layer_mask_t mask = 1 << layer; | 631 | rgblight_layer_mask_t mask = (rgblight_layer_mask_t)1 << layer; |
| 632 | if (enabled) { | 632 | if (enabled) { |
| 633 | rgblight_status.enabled_layer_mask |= mask; | 633 | rgblight_status.enabled_layer_mask |= mask; |
| 634 | } else { | 634 | } else { |
| @@ -649,7 +649,7 @@ void rgblight_set_layer_state(uint8_t layer, bool enabled) { | |||
| 649 | } | 649 | } |
| 650 | 650 | ||
| 651 | bool rgblight_get_layer_state(uint8_t layer) { | 651 | bool rgblight_get_layer_state(uint8_t layer) { |
| 652 | rgblight_layer_mask_t mask = 1 << layer; | 652 | rgblight_layer_mask_t mask = (rgblight_layer_mask_t)1 << layer; |
| 653 | return (rgblight_status.enabled_layer_mask & mask) != 0; | 653 | return (rgblight_status.enabled_layer_mask & mask) != 0; |
| 654 | } | 654 | } |
| 655 | 655 | ||
| @@ -689,7 +689,7 @@ static uint16_t _blink_timer; | |||
| 689 | 689 | ||
| 690 | void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { | 690 | void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { |
| 691 | rgblight_set_layer_state(layer, true); | 691 | rgblight_set_layer_state(layer, true); |
| 692 | _blinked_layer_mask |= 1 << layer; | 692 | _blinked_layer_mask |= (rgblight_layer_mask_t)1 << layer; |
| 693 | _blink_timer = timer_read(); | 693 | _blink_timer = timer_read(); |
| 694 | _blink_duration = duration_ms; | 694 | _blink_duration = duration_ms; |
| 695 | } | 695 | } |
| @@ -697,7 +697,7 @@ void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { | |||
| 697 | void rgblight_unblink_layers(void) { | 697 | void rgblight_unblink_layers(void) { |
| 698 | if (_blinked_layer_mask != 0 && timer_elapsed(_blink_timer) > _blink_duration) { | 698 | if (_blinked_layer_mask != 0 && timer_elapsed(_blink_timer) > _blink_duration) { |
| 699 | for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) { | 699 | for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) { |
| 700 | if ((_blinked_layer_mask & 1 << layer) != 0) { | 700 | if ((_blinked_layer_mask & (rgblight_layer_mask_t)1 << layer) != 0) { |
| 701 | rgblight_set_layer_state(layer, false); | 701 | rgblight_set_layer_state(layer, false); |
| 702 | } | 702 | } |
| 703 | } | 703 | } |
