Skip to content

Commit d2b6539

Browse files
authored
Merge pull request #109 from adafruit/rainbowio
Update example to use rainbowio
2 parents e0fecb6 + 3eebeb9 commit d2b6539

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

examples/circuitplayground_pixels_simpletest.py

+2-15
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,15 @@
33

44
"""This example lights up the NeoPixels with a rainbow swirl."""
55
import time
6+
from rainbowio import colorwheel
67
from adafruit_circuitplayground import cp
78

89

9-
def wheel(pos):
10-
# Input a value 0 to 255 to get a color value.
11-
# The colours are a transition r - g - b - back to r.
12-
if (pos < 0) or (pos > 255):
13-
return (0, 0, 0)
14-
if pos < 85:
15-
return (int(pos * 3), int(255 - (pos * 3)), 0)
16-
if pos < 170:
17-
pos -= 85
18-
return (int(255 - pos * 3), 0, int(pos * 3))
19-
pos -= 170
20-
return (0, int(pos * 3), int(255 - pos * 3))
21-
22-
2310
def rainbow_cycle(wait):
2411
for j in range(255):
2512
for i in range(cp.pixels.n):
2613
idx = int((i * 256 / len(cp.pixels)) + j)
27-
cp.pixels[i] = wheel(idx & 255)
14+
cp.pixels[i] = colorwheel(idx & 255)
2815
cp.pixels.show()
2916
time.sleep(wait)
3017

0 commit comments

Comments
 (0)