Exemplo n.º 1
0
    def check_for_idle(self):
        if not self.settings['auto_dim_eyes'] == "true":
            self.cancel_scheduled_event('IdleCheck')
            return

        if DisplayManager.get_active() == '':
            # No activity, start to fall asleep
            self.idle_count += 1
            if self.idle_count == 2:
                # Go into a 'sleep' visual state
                self.enclosure.eyes_look('d')

                # Lower the eyes
                time.sleep(0.5)
                rgb = self._current_color
                enclosure_eyes_setpixel(3, r=rgb[0], g=rgb[1], b=rgb[2])
                enclosure_eyes_setpixel(8, r=rgb[0], g=rgb[1], b=rgb[2])
                enclosure_eyes_setpixel(15, r=rgb[0], g=rgb[1], b=rgb[2])
                enclosure_eyes_setpixel(20, r=rgb[0], g=rgb[1], b=rgb[2])
            elif self.idle_count > 2:
                self.cancel_scheduled_event('IdleCheck')

                # Go into an 'inattentive' visual state
                rgb = self._darker_color(self._current_color, 0.5)
                for idx in range(3, 9):
                    enclosure_eyes_setpixel(idx, r=rgb[0], g=rgb[1], b=rgb[2])
                for idx in range(15, 21):
                    enclosure_eyes_setpixel(idx, r=rgb[0], g=rgb[1], b=rgb[2])

        else:
            self.idle_count = 0
Exemplo n.º 2
0
    def check_for_idle(self):
        if not self.piano_bar_state == "autopause":
            self.cancel_scheduled_event('IdleCheck')
            return

        if DisplayManager.get_active() == '':
            # No activity, start to fall asleep
            self.idle_count += 1

            if self.idle_count >= 2:
                # Resume playback after 2 seconds of being idle
                self.cancel_scheduled_event('IdleCheck')
                self.handle_resume_song()
        else:
            self.idle_count = 0
Exemplo n.º 3
0
    def check_for_idle(self):
        if not self.settings['auto_dim_eyes'] == "true":
            self.cancel_scheduled_event('IdleCheck')
            return

        if DisplayManager.get_active() == '':
            # No activity, start to fall asleep
            self.idle_count += 1
            try:
                # Found the built-in API for setpixel (introduced in 0.9.17)
                setpixel = self.enclosure.eyes_setpixel
            except:
                # Use adaptor that writes straight to the serial port
                setpixel = enclosure_eyes_setpixel

            if self.idle_count == 2:
                # Go into a 'sleep' visual state
                self.enclosure.eyes_look('d')

                # Lower the eyes
                time.sleep(0.5)  # prevent overwriting of eye down animation
                rgb = self._current_color
                setpixel(3, r=rgb[0], g=rgb[1], b=rgb[2])
                setpixel(8, r=rgb[0], g=rgb[1], b=rgb[2])
                setpixel(15, r=rgb[0], g=rgb[1], b=rgb[2])
                setpixel(20, r=rgb[0], g=rgb[1], b=rgb[2])
            elif self.idle_count > 2:
                self.cancel_scheduled_event('IdleCheck')

                # Go into an 'inattentive' visual state
                rgb = self._darker_color(self._current_color, 0.5)
                for idx in range(0, 3):
                    setpixel(idx, r=0, g=0, b=0)
                    time.sleep(0.05)  # hack to prevent serial port overflow
                for idx in range(3, 9):
                    setpixel(idx, r=rgb[0], g=rgb[1], b=rgb[2])
                    time.sleep(0.05)  # hack to prevent serial port overflow
                for idx in range(9, 15):
                    setpixel(idx, r=0, g=0, b=0)
                    time.sleep(0.05)  # hack to prevent serial port overflow
                for idx in range(15, 21):
                    setpixel(idx, r=rgb[0], g=rgb[1], b=rgb[2])
                    time.sleep(0.05)  # hack to prevent serial port overflow
                for idx in range(21, 24):
                    setpixel(idx, r=0, g=0, b=0)
                    time.sleep(0.05)  # hack to prevent serial port overflow
        else:
            self.idle_count = 0
Exemplo n.º 4
0
    def check_for_idle(self):
        if not self.piano_bar_state == "autopause":
            self.cancel_scheduled_event('IdleCheck')
            return
        active = DisplayManager.get_active()
        # LOG.info("active: " + str(active))
        if active == "PianobarSkill" or not active:
            # No activity, start to fall asleep
            self.idle_count += 1

            if self.idle_count >= 2:
                # Resume playback after 2 seconds of being idle
                self.cancel_scheduled_event('IdleCheck')
                self.handle_resume_song()
        else:
            self.idle_count = 0
Exemplo n.º 5
0
    def check_for_idle(self):
        """ Repeating event checking for end of auto ducking. """
        if not self.ducking:
            self.cancel_scheduled_event('IdleCheck')
            return

        active = DisplayManager.get_active()
        if not active == '' or active == 'SpotifySkill':
            # No activity, start to fall asleep
            self.idle_count += 1

            if self.idle_count >= 5:
                # Resume playback after 5 seconds of being idle
                self.cancel_scheduled_event('IdleCheck')
                self.ducking = False
                self.resume()
        else:
            self.idle_count = 0
Exemplo n.º 6
0
 def _is_display_idle(self):
     # check if the display is being used by another skill right now
     # or _get_active() == "TimeSkill"
     return DisplayManager.get_active() == ''