File tree Expand file tree Collapse file tree 1 file changed +2
-15
lines changed Expand file tree Collapse file tree 1 file changed +2
-15
lines changed Original file line number Diff line number Diff line change 33
44"""This example lights up the NeoPixels with a rainbow swirl."""
55import time
6+ from rainbowio import colorwheel
67from 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-
2310def 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
You can’t perform that action at this time.
0 commit comments