File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import neopixel
44
55pixels = neopixel .NeoPixel (board .NEOPIXEL , 10 , brightness = 0.2 , auto_write = False )
6+ rainbow_cycle_demo = 1
7+
8+ def colorwheel (pos ):
9+ if pos < 0 or pos > 255 :
10+ return (0 , 0 , 0 )
11+ if pos < 85 :
12+ return (255 - pos * 3 , pos * 3 , 0 )
13+ if pos < 170 :
14+ pos -= 85
15+ return (0 , 255 - pos * 3 , pos * 3 )
16+ pos -= 170
17+ return (pos * 3 , 0 , 255 - pos * 3 )
18+
19+ def rainbow_cycle (wait ):
20+ for j in range (255 ):
21+ for i in range (10 ):
22+ rc_index = (i * 256 // 10 ) + j * 5
23+ pixels [i ] = colorwheel (rc_index & 255 )
24+ pixels .show ()
25+ time .sleep (wait )
626
727while True :
8- for j in range (255 ):
9- for i in range (len (pixels )):
10- rc_index = (i * 256 // len (pixels )) + j
11- pixels [i ] = neopixel ._pixelbuf .wheel (rc_index )
12- pixels .show ()
28+ if rainbow_cycle_demo :
29+ rainbow_cycle (0.05 )
You can’t perform that action at this time.
0 commit comments