def onChangeColor(self, newColor): if self.finishTrigger.isFalse(): self.finish() filteredColor = utils.interpolateColor(newColor, self.black, self.finishTrigger.progress()) if log.m(log.LEVEL_FILTER_ACTIONS): log.l(self.type+'-filter color ('+str(self.finishTrigger.progress()*100)+'%) from '+str(newColor)+' to '+str(filteredColor)) self.finishTrigger.step() return filteredColor
def fade(task, timeInSecs, endColor, startColor=None): if task is not None and task.state != constants.CMD_STATE_STARTED: raise RuntimeError("the thread, which is responsible for this fade has an invalid state: "+str(task.state)) if timeInSecs <= 0: raise ValueError("time cannot be 0 or below: "+str(timeInSecs)) startVolume = 0 ##timeInSecs = 20 if config.ENABLE_XBMC_REMOTE: startVolume = xbmcremote.getVolume() if startColor is None: startColor = datatypes.Color(led.COLOR[0].R, led.COLOR[0].G, led.COLOR[0].B) currentColor = datatypes.Color(startColor.R, startColor.G, startColor.B) startTime = time.time() secondsPassed = 0.0 lastVolume = startVolume while ((task is not None and (task.isStarted() and (task.thread is None or task.thread.isStarted()))) and secondsPassed <= timeInSecs): secondsPassed = time.time() - startTime #interpolate new color utils.interpolateColor(startColor, endColor, secondsPassed/timeInSecs, currentColor) #fade step filters for f in server.CurrentFilters: f.onFadeStep(timeInSecs, startColor, endColor, secondsPassed/timeInSecs) time.sleep(config.DELAY) #print startColor," ", endColor, " ", secondsPassed/timeInSecs led.setColor(currentColor) #fade end filters for f in server.CurrentFilters: f.onFadeEnd(timeInSecs, startColor, endColor)