diff --git a/examples/circuitplayground_pixels_simpletest.py b/examples/circuitplayground_pixels_simpletest.py index f3c8f69..9e9da05 100644 --- a/examples/circuitplayground_pixels_simpletest.py +++ b/examples/circuitplayground_pixels_simpletest.py @@ -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)