def loop()

in smart-mirror-full/extracted/device/script/agt_smart_mirror.py [0:0]


    def loop(self):
        """
        Main function of this class. This is an endless loop running in a separate thread. It will check what action to run on each iteration.
        """
        while True:
            # Check if anything should be visualized
            if self.keep_cycling:
                logger.info(f'{self.currentAction} is on')
                try:
                    if self.currentAction == Actions.Off:
                        time.sleep(0.1)
                    if self.currentAction == Actions.Rainbow:
                        self.smart_mirror.rainbow_cycle(0.001)
                    if self.currentAction == Actions.Breathe:
                        self.smart_mirror.breathe()
                    if self.currentAction == Actions.Police:
                        self.smart_mirror.police()
                    if self.currentAction == Actions.Clock:
                        self.smart_mirror.clock()
                    if self.currentAction == Actions.ShowColor:
                        self.smart_mirror.showColor(
                            self.showColorOptions['color'])
                    if self.currentAction == Actions.Timer:
                        timerPosition = self.getCurrentTimerPosition()
                        if(timerPosition != 0):
                            self.smart_mirror.showRange(0, timerPosition, 0.1, self.showTimerOptions['color'])
                        else:
                            self.smart_mirror.showColor(self.showTimerOptions['color'])
                except Exception as e:
                    logger.info(f'Error in loop: {e}')
                    logger.error(f'Stack: {traceback.format_exc()}')
                    time.sleep(0.1)
            else:
                logger.info('Nothing is on')
                self.smart_mirror.reset()
                time.sleep(0.1)