Tutorial

Table Of Contents
79
self.colorBreathB = B_input
self.resume()
def breathProcessing(self):
'''
Specific realization method of breathing lamp
'''
while self.lightMode == 'breath':
'''
All lights gradually brighten
'''
for i in range(0,self.breathSteps):
if self.lightMode != 'breath':
break
self.setColor(self.colorBreathR*i/self.breathSteps,
self.colorBreathG*i/self.breathSteps,
self.colorBreathB*i/self.breathSteps)
time.sleep(0.03)
'''
All lights are getting darker
'''
for i in range(0,self.breathSteps):
if self.lightMode != 'breath':
break
self.setColor(self.colorBreathR-(self.colorBreathR*i/self.breathSteps),
self.colorBreathG-(self.colorBreathG*i/self.breathSteps),
self.colorBreathB-(self.colorBreathB*i/self.breathSteps))
time.sleep(0.03)
def lightChange(self):
'''
This function is used to select the task to perform
'''
if self.lightMode == 'none':
self.pause()
elif self.lightMode == 'police':
self.policeProcessing()
elif self.lightMode == 'breath':
self.breathProcessing()