diff --git a/examples/plasma_stick/plasma_stick_rainbows.cpp b/examples/plasma_stick/plasma_stick_rainbows.cpp index d068d4e9..faa84e41 100644 --- a/examples/plasma_stick/plasma_stick_rainbows.cpp +++ b/examples/plasma_stick/plasma_stick_rainbows.cpp @@ -34,10 +34,15 @@ int main() { while(true) { offset += float(SPEED) / 2000.0f; + if (offset > 1.0) { + offset -= 1.0; + } for(auto i = 0u; i < NUM_LEDS; ++i) { float hue = float(i) / NUM_LEDS; - led_strip.set_hsv(i, hue + offset, 1.0f, 1.0f); + hue += offset; + hue -= floor(hue); + led_strip.set_hsv(i, hue, 1.0f, 1.0f); } sleep_ms(1000 / UPDATES); diff --git a/micropython/examples/plasma_stick/rainbows.py b/micropython/examples/plasma_stick/rainbows.py index 5c0b5ea9..dc6d52bc 100644 --- a/micropython/examples/plasma_stick/rainbows.py +++ b/micropython/examples/plasma_stick/rainbows.py @@ -28,9 +28,10 @@ while True: SPEED = min(255, max(1, SPEED)) offset += float(SPEED) / 2000.0 + offset %= 1 for i in range(NUM_LEDS): - hue = float(i) / NUM_LEDS + hue = (offset + float(i) / NUM_LEDS) % 1 led_strip.set_hsv(i, hue + offset, 1.0, 1.0) time.sleep(1.0 / UPDATES)