mirror of
https://github.com/wled/WLED.git
synced 2025-07-13 22:06:31 +00:00
BUGFIX in oscillate FX (#4494)
effect was changed from int to uint but it relied on negative numbers. fixed by checking overflow and a cast.
This commit is contained in:
parent
9e37d7051c
commit
39b3e7e507
@ -1827,7 +1827,7 @@ uint16_t mode_oscillate(void) {
|
|||||||
// if the counter has increased, move the oscillator by the random step
|
// if the counter has increased, move the oscillator by the random step
|
||||||
if (it != SEGENV.step) oscillators[i].pos += oscillators[i].dir * oscillators[i].speed;
|
if (it != SEGENV.step) oscillators[i].pos += oscillators[i].dir * oscillators[i].speed;
|
||||||
oscillators[i].size = SEGLEN/(3+SEGMENT.intensity/8);
|
oscillators[i].size = SEGLEN/(3+SEGMENT.intensity/8);
|
||||||
if((oscillators[i].dir == -1) && (oscillators[i].pos <= 0)) {
|
if((oscillators[i].dir == -1) && (oscillators[i].pos > SEGLEN << 1)) { // use integer overflow
|
||||||
oscillators[i].pos = 0;
|
oscillators[i].pos = 0;
|
||||||
oscillators[i].dir = 1;
|
oscillators[i].dir = 1;
|
||||||
// make bigger steps for faster speeds
|
// make bigger steps for faster speeds
|
||||||
@ -1843,7 +1843,7 @@ uint16_t mode_oscillate(void) {
|
|||||||
for (unsigned i = 0; i < SEGLEN; i++) {
|
for (unsigned i = 0; i < SEGLEN; i++) {
|
||||||
uint32_t color = BLACK;
|
uint32_t color = BLACK;
|
||||||
for (unsigned j = 0; j < numOscillators; j++) {
|
for (unsigned j = 0; j < numOscillators; j++) {
|
||||||
if(i >= (unsigned)oscillators[j].pos - oscillators[j].size && i <= oscillators[j].pos + oscillators[j].size) {
|
if((int)i >= (int)oscillators[j].pos - oscillators[j].size && i <= oscillators[j].pos + oscillators[j].size) {
|
||||||
color = (color == BLACK) ? SEGCOLOR(j) : color_blend(color, SEGCOLOR(j), uint8_t(128));
|
color = (color == BLACK) ? SEGCOLOR(j) : color_blend(color, SEGCOLOR(j), uint8_t(128));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user