mirror of
https://github.com/wled/WLED.git
synced 2025-04-24 14:57:18 +00:00
BUGFIX in oscillate FX
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
700a7076fd
commit
012143bd7b
@ -1798,7 +1798,7 @@ uint16_t mode_oscillate(void) {
|
||||
// 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;
|
||||
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].dir = 1;
|
||||
// make bigger steps for faster speeds
|
||||
@ -1814,7 +1814,7 @@ uint16_t mode_oscillate(void) {
|
||||
for (unsigned i = 0; i < SEGLEN; i++) {
|
||||
uint32_t color = BLACK;
|
||||
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), 128);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user