Example #1
0
 def setIntensity(self, intensity):
     try:
         intensity = int(intensity)
     except:
         intensity = 100
         pass
     self.__intensity = intensity
     color = Color()
     color.fromHex(self.__color.toHex())
     color.darken(100 - intensity)
     if color.red == 0 and color.green == 0 and color.blue == 0:
         self.isOn = False
         self.close()
     if self.__pi.connected:
         self.__pi.set_PWM_dutycycle(self.redPin, color.red)
         self.__pi.set_PWM_dutycycle(self.greenPin, color.green)
         self.__pi.set_PWM_dutycycle(self.bluePin, color.blue)
         print("LedStrip color intensity updated...")
         self.isOn = True
     else:
         self.isOn = False