Skip to content

Update example to use rainbowio #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions examples/circuitplayground_pixels_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,15 @@

"""This example lights up the NeoPixels with a rainbow swirl."""
import time
from rainbowio import colorwheel
from adafruit_circuitplayground import cp


def wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if (pos < 0) or (pos > 255):
return (0, 0, 0)
if pos < 85:
return (int(pos * 3), int(255 - (pos * 3)), 0)
if pos < 170:
pos -= 85
return (int(255 - pos * 3), 0, int(pos * 3))
pos -= 170
return (0, int(pos * 3), int(255 - pos * 3))


def rainbow_cycle(wait):
for j in range(255):
for i in range(cp.pixels.n):
idx = int((i * 256 / len(cp.pixels)) + j)
cp.pixels[i] = wheel(idx & 255)
cp.pixels[i] = colorwheel(idx & 255)
cp.pixels.show()
time.sleep(wait)

Expand Down