Clamp reactive offset value (#25489)
* Avoids underflow of the unsigned 8-bit
This commit is contained in:
parent
2c34b480fc
commit
ad4233d078
2 changed files with 2 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE)
|
||||||
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||||
|
|
||||||
static hsv_t SOLID_REACTIVE_math(hsv_t hsv, uint16_t offset) {
|
static hsv_t SOLID_REACTIVE_math(hsv_t hsv, uint16_t offset) {
|
||||||
|
if (offset > 255) offset = 255;
|
||||||
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
|
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
|
||||||
hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4);
|
hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4);
|
||||||
# endif
|
# endif
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE)
|
||||||
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||||
|
|
||||||
static hsv_t SOLID_REACTIVE_SIMPLE_math(hsv_t hsv, uint16_t offset) {
|
static hsv_t SOLID_REACTIVE_SIMPLE_math(hsv_t hsv, uint16_t offset) {
|
||||||
|
if (offset > 255) offset = 255;
|
||||||
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
|
# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
|
||||||
hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4);
|
hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4);
|
||||||
# endif
|
# endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue