Skip to content

Commit

Permalink
Merge pull request #883 from raybellis/main
Browse files Browse the repository at this point in the history
fix hue errors in plasma_stick_rainbows
  • Loading branch information
Gadgetoid authored Jan 16, 2024
2 parents bff2453 + da0ac18 commit 0d3fce9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion examples/plasma_stick/plasma_stick_rainbows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion micropython/examples/plasma_stick/rainbows.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@

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)

0 comments on commit 0d3fce9

Please sign in to comment.