Пример #1
0
    def button_push(self, pin):
        '''
        Callback method when a button is pushed.

        :param int pin: Pin number
        '''
        now = time()
        before = self.timestamps[pin]

        if (GPIO.input(pin) == GPIO.LOW) and (now - before > 0.25):
            LOGGER.debug('Button at pin %s was pushed', pin)
            play_sound('success.wav')
            self.button_pins[pin](self.core)
            self.timestamps[pin] = now
Пример #2
0
    def handle_uid(self, uid):
        '''
        Handle the scanned tag / retreived UID.

        :param str uid: The UID
        '''
        tag = Tag(uid)

        if tag.registered:
            LOGGER.info('Triggering action of registered tag')
            play_sound('success.wav')
            tag(self.core)

        else:
            LOGGER.info('Tag is not registered, thus doing nothing')
            play_sound('fail.wav')

        tag.scanned = time()
        TagReader.latest = tag
Пример #3
0
    def handle_uid(self, uid):
        '''
        Handle the scanned tag / retreived UID.

        :param str uid: The UID
        '''
        try:
            action = REGISTRY[str(uid)]
            LOGGER.info('Triggering action of registered tag')
            play_sound('success.wav')
            action(self.core)

        except KeyError:
            LOGGER.info('Tag is not registered, thus doing nothing')
            play_sound('fail.wav')
            action = Action(uid=uid)

        action.scanned   = time()
        TagReader.latest = action