# Intialize the library (must be called once before other functions).
self.strip.begin()
def LED_TYPR(self,order,R_G_B):
B=R_G_B & 255
G=R_G_B >> 8 & 255
R=R_G_B >> 16 & 255
Led_type=["GRB","GBR","RGB", "RBG","BRG","BGR"]
color =
[Color(G,R,B),Color(G,B,R),Color(R,G,B),Color(R,B,G),Color(B,R,G),Color(B,G,R)]
if order in Led_type:
return color[Led_type.index(order)]
def colorWipe(self,strip, color, wait_ms=50):
"""Wipe color across display a pixel at a time."""
color=self.LED_TYPR(self.ORDER,color)
for i in range(self.strip.numPixels()):
self.strip.setPixelColor(i, color)
self.strip.show()
time.sleep(wait_ms/1000.0)
def wheel(self,pos):
"""Generate rainbow colors across 0-255 positions."""
if pos<0 or pos >255:
r=g=b=0
elif pos < 85:
r=pos * 3
g=255 - pos * 3
b=0
elif pos < 170:
pos -= 85
r=255 - pos * 3
g=0
b=pos * 3
else:
pos -= 170
r=0
g=pos * 3
b=255 - pos * 3
return self.LED_TYPR(self.ORDER,Color(r,g,b))
def rainbow(self,strip, wait_ms=20, iterations=1):
"""Draw rainbow that fades across all pixels at once."""
for j in range(256*iterations):
for i in range(self.strip.numPixels()):
self.strip.setPixelColor(i, self.wheel((i+j) & 255))
self.strip.show()
time.sleep(wait_ms/1000.0)