Tutorial

Table Of Contents
77
super(RobotLight, self).__init__(*args, **kwargs)
self.__flag = threading.Event()
self.__flag.clear()
# Define functions which animate LEDs in various ways.
def setColor(self, R, G, B):
'''
Set the color of all lights
'''
color = Color(int(R),int(G),int(B))
for i in range(self.strip.numPixels()):
self.strip.setPixelColor(i, color)
self.strip.show()
def setSomeColor(self, R, G, B, ID):
'''
Set the color of some lamps, the ID is the array of the serial number of this lamp
'''
color = Color(int(R),int(G),int(B))
#print(int(R),' ',int(G),' ',int(B))
for i in ID:
self.strip.setPixelColor(i, color)
self.strip.show()
def pause(self):
'''
Call this function, set __flag to False, block the thread
'''
self.lightMode = 'none'
self.setColor(0,0,0)
self.__flag.clear()
def resume(self):
'''
Call this function, set __flag to True to start the thread
'''
self.__flag.set()
def police(self):