def _calibrationCallback(self, state, theTime): """Wii's callback destination while zeroing the device.""" self._warmupCnt += 1 if self._warmupCnt < NUM_WARMUP_READINGS: return if self._readingsCnt >= NUM_ZEROING_READINGS: return thisState = wiistate.WIIState(state, theTime, self.getRumble(), self._wm.state['buttons']) # Pull out the accelerometer x,y,z, accumulate in a list: self._accList.append(thisState.accRaw) # Pull out the gyro x,y,z, and build a GyroReading from them. # For a few cycles, the Wiimote does not deliver gyro info. # When it doesn't, we get a 'None' is unsubscriptable. Ignore # those initial instabilities: try: self._gyroList.append(thisState.angleRate) except TypeError: pass self._readingsCnt += 1 if thisState.nunchukPresent and self._nunchukJoyOrig is None: self._nunchukJoyOrig = thisState.nunchukStickRaw wiistate.WIIState.setNunchukJoystickCalibration( self._nunchukJoyOrig) return
def _calibrationCallback(self, state, theTime): """Wii's callback destination while zeroing the device.""" if self._readingsCnt >= self._NUM_ZEROING_READINGS: return thisState = wiistate.WIIState(state, theTime, self.getRumble(), self._wm.state['buttons']) # Pull out the accelerometer x,y,z, and build an WIIReading from them: self._accList.append(wiistate.WIIReading(thisState.accRaw)) # Pull out the gyro x,y,z, and build a GyroReading from them: self._gyroList.append(wiistate.GyroReading(thisState.angleRate)) self._readingsCnt += 1 return
def _steadyStateCallback(self, state, theTime): now = getTimeStamp() if now - self._startTime >= self.sampleRate: # If this Wiimote driver is to synchronize write # access to the wii state variable (which is read from # outside), then acquire the lock that was provided # by the instantiator of this instance: if self.wiiStateLock is not None: self.wiiStateLock.acquire() try: self.wiiMoteState = wiistate.WIIState(state, theTime, self.getRumble(), self._wm.state['buttons']) except ValueError: # A 'Wiimote is closed' error can occur as a race condition # as threads close down after a Cnt-C. Catch those and # ignore: pass if self.wiiStateLock is not None: self.wiiStateLock.release() self._startTime = now
def _steadyStateCallback(self, state, theTime): #print state now = getTimeStamp() if now - self._startTime >= self.sampleRate: self.wiiMoteState = wiistate.WIIState(state, theTime, self.getRumble(), self._wm.state['buttons']); self._startTime = now