def update(self):
     """Read in new data. The device refreshes at 62.5 Hz"""
     if not self._running:
       return
 
     ret,data = hid.hid_interrupt_read(self._hid,0x82,15,0);
     if ret != hid.HID_RET_SUCCESS:
         sys.stderr.write("hid_interrupt_read failed with return code %d.\n" % ret)
     else:
         # see: http://www.pnicorp.com/support/notes/spacepoint-fusion
         x = ((ord(data[0])|(ord(data[1])<<8))-32768)*0.000183105469
         y = ((ord(data[2])|(ord(data[3])<<8))-32768)*0.000183105469
         z = ((ord(data[4])|(ord(data[5])<<8))-32768)*0.000183105469
         self.accel = (x,y,z)
         q0 = ((ord(data[6])|(ord(data[7])<<8))-32768)/32768.0
         q1 = ((ord(data[8])|(ord(data[9])<<8))-32768)/32768.0
         q2 = ((ord(data[10])|(ord(data[11])<<8))-32768)/32768.0
         q3 = ((ord(data[12])|(ord(data[13])<<8))-32768)/32768.0
         self.quat = (q0,q1,q2,q3)
         b0 = ord(data[14])&1;
         b1 = (ord(data[14])&2)>>1;
         self.buttons = (b0,b1)
    def update(self):
        """Read in new data. The device refreshes at 62.5 Hz"""
        if not self._running:
            return

        ret, data = hid.hid_interrupt_read(self._hid, 0x82, 15, 0)
        if ret != hid.HID_RET_SUCCESS:
            sys.stderr.write(
                "hid_interrupt_read failed with return code %d.\n" % ret)
        else:
            # see: http://www.pnicorp.com/support/notes/spacepoint-fusion
            x = ((ord(data[0]) | (ord(data[1]) << 8)) - 32768) * 0.000183105469
            y = ((ord(data[2]) | (ord(data[3]) << 8)) - 32768) * 0.000183105469
            z = ((ord(data[4]) | (ord(data[5]) << 8)) - 32768) * 0.000183105469
            self.accel = (x, y, z)
            q0 = ((ord(data[6]) | (ord(data[7]) << 8)) - 32768) / 32768.0
            q1 = ((ord(data[8]) | (ord(data[9]) << 8)) - 32768) / 32768.0
            q2 = ((ord(data[10]) | (ord(data[11]) << 8)) - 32768) / 32768.0
            q3 = ((ord(data[12]) | (ord(data[13]) << 8)) - 32768) / 32768.0
            self.quat = (q0, q1, q2, q3)
            b0 = ord(data[14]) & 1
            b1 = (ord(data[14]) & 2) >> 1
            self.buttons = (b0, b1)
Beispiel #3
0
 def interrupt_read(self, endpoint, size, timeout):
     ret, bytes = hid.hid_interrupt_read(self._interface,
                                         endpoint, size, timeout)
     self._check(ret, 'hid_interrupt_read')
     return bytes
Beispiel #4
0
 def interrupt_read(self, endpoint, size, timeout=0):
     return _hid_raise("interrupt_read",
             hid.hid_interrupt_read(self.interface, endpoint, size, timeout))
Beispiel #5
0
 def interrupt_read(self, endpoint, size, timeout=0):
     return _hid_raise(
         "interrupt_read",
         hid.hid_interrupt_read(self.interface, endpoint, size, timeout))