def run(self):
        while self.notifying:
            self.curr1 = GPIO.input(INPUT_PIN1)
            if (not self.curr1 and self.curr1 != self.prev1):
                self.count += 1
                self.send_notify_event(sint16(self.count))
            self.prev1 = self.curr1

            self.curr2 = GPIO.input(INPUT_PIN2)
            if (not self.curr2 and self.curr2 != self.prev2):
                self.count += 1
                self.send_notify_event(sint16(self.count))
            self.prev2 = self.curr2
Пример #2
0
 def run(self):
     i = 0
     while self.notifying:
         self.send_notify_event(sint16(i))
         i += 1
         print to_int(self.value)
         sleep(POLL_RATE)
 def notify_event(self):
     if self.notifying:
         self.thread = Thread(target=self.run, args=())
         self.thread.setDaemon(True)
         self.thread.start()
         self.send_notify_event(sint16(self.count))
     else:
         self.thread.join()
Пример #4
0
    def __init__(self, uuid, service):
        peripheral.Characteristic.__init__(self, uuid, ['read', 'notify'],
                                           service, sint16(0))
        self.add_descriptor(UserDescriptor(NAME, self))
        self.add_descriptor(
            FormatDescriptor([0x0E, 0x00, 0x00, 0x27, 0x01, 0x00, 0x00], self))

        self.add_notify_event(self.notify_event)
Пример #5
0
    def run(self):
        while self.notifying:
            val = 0
            if self.wiimote() != None:
                val = self.wiimote().state['buttons']

            if (to_int(self.value) != val):
                self.send_notify_event(sint16(val))

            sleep(POLL_RATE)
    def __init__(self, uuid, service):
        peripheral.Characteristic.__init__(self, uuid, ['read', 'notify'],
                                           service, sint16(0))
        self.add_descriptor(UserDescriptor(NAME, self))
        self.add_descriptor(
            FormatDescriptor([0x0E, 0x00, 0x00, 0x27, 0x01, 0x00, 0x00], self))

        self.add_notify_event(self.notify_event)

        self.count = 0

        self.prev1 = False
        self.curr1 = False
        self.prev2 = False
        self.curr2 = False

        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(INPUT_PIN1, GPIO.IN)
        GPIO.setup(INPUT_PIN2, GPIO.IN)