
| Public Member Functions | |
| def | __init__ (self, theSampleRate=0, wiiStateLock=None, gatherCalibrationStats=False) | 
| def | computeAccStatistics (self) | 
| def | computeGyroStatistics (self) | 
| def | getAccelerometerCalibration (self) | 
| def | getAccFactoryCalibrationSettings (self) | 
| def | getBattery (self) | 
| def | getGyroCalibration (self) | 
| def | getLEDs (self, asInt=False) | 
| def | getMeanAccelerator (self) | 
| def | getMeanGyro (self) | 
| def | getNunchukFactoryCalibrationSettings (self) | 
| def | getRumble (self) | 
| def | getStdevAccelerator (self) | 
| def | getStdevGyro (self) | 
| def | getVarianceAccelerator (self) | 
| def | getVarianceGyro (self) | 
| def | getWiimoteState (self) | 
| def | motionPlusPresent (self) | 
| def | nunchukPresent (self) | 
| def | printState (self) | 
| def | setAccelerometerCalibration (self, zeroReadingList, oneReadingList) | 
| def | setAccelerometerCalibration (self, zeroReadingNPArray, oneReadingNPArray) | 
| def | setGyroCalibration (self, gyroTriplet) | 
| def | setLEDs (self, statusList) | 
| def | setNunchukAccelerometerCalibration (self, zeroReadingList, oneReadingList) | 
| def | setRumble (self, switchPos) | 
| def | shutdown (self) | 
| def | zeroDevice (self) | 
| Static Public Attributes | |
| BATTERY_MAX = cwiid.BATTERY_MAX | |
| Private Member Functions | |
| def | _calibrationCallback (self, state, theTime) | 
| def | _getInstanceVarCriticalSection (self, varName) | 
| def | _steadyStateCallback (self, state, theTime) | 
| Private Attributes | |
| _warmupCnt | |
| Static Private Attributes | |
| _accList = None | |
| _accNormal = None | |
| _accTotal = None | |
| _gyroList = None | |
| _gyroNormal = None | |
| _gyroTotal = None | |
| list | _LEDMasksOff | 
| list | _LEDMasksOn = [LED1_ON, LED2_ON, LED3_ON, LED4_ON] | 
| _nunchukJoyOrig = None | |
| _readingsCnt = None | |
| _startTime = None | |
| _wiiCallbackStack = None | |
| _wm = None | |
Main class for Wiimote device interaction.
This class should be a singleton, or it should have
only class members/methods.
Public Data attributes:
    wiiMoteState   WIIState object that holds the latest sampled state
    sampleRate     Control Wiimote state samples to take per second
    meanAcc        Triplet with mean of accelerator at rest
    stdevAcc       Triplet with standard deviation of accelerator at rest
    meanGyro       Triplet with mean of gyro (angular rate) at rest
    stdevGyro      Triplet with standard deviation gyro (angular rate) at rest
Public Methods: 
Definition at line 53 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.__init__ | ( | self, | |
| theSampleRate = 0, | |||
| wiiStateLock = None, | |||
| gatherCalibrationStats = False | |||
| ) | 
Instantiate a Wiimote driver instance, which controls one physical Wiimote device.
Parameters:
    theSampleRate: How often to update the instance's wiiMoteState variable:
theSampleRate= -1: never
theSampleRate=  0: as often as possible
theSampleRate=  x: every x seconds
 
Definition at line 94 of file WIIMote.py.
| 
 | private | 
Wii's callback destination while zeroing the device.
Definition at line 216 of file WIIMote.py.
| 
 | private | 
Return the value of the given instance variable, providing locking service.
Definition at line 422 of file WIIMote.py.
| 
 | private | 
Definition at line 196 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.computeAccStatistics | ( | self | ) | 
Compute mean and stdev for accelerometer data list self._accList in both Gs and metric m/sec^2
Definition at line 605 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.computeGyroStatistics | ( | self | ) | 
Compute mean and stdev for gyro data list self._gyroList in both Gs and metric m/sec^2
Definition at line 629 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getAccelerometerCalibration | ( | self | ) | 
Returns currently operative accelerometer calibration. Return value: tuple with calibration for zero reading, and calibration or a '1' reading.
Definition at line 528 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getAccFactoryCalibrationSettings | ( | self | ) | 
Obtain calibration data from accelerometer. Retrieve factory-installed calibration data for the Wiimote's accelerometer. Returns a two-tuple with the calibration numbers for zero and one:
Definition at line 536 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getBattery | ( | self | ) | 
Obtain battery state from Wiimote. Maximum charge is BATTERY_MAX.
Definition at line 520 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getGyroCalibration | ( | self | ) | 
Return current Gyro zeroing offsets as list x/y/z.
Definition at line 569 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getLEDs | ( | self, | |
| asInt = False | |||
| ) | 
Get the status of the four Wii LEDs. Return value depends on the asInt parameter: if asInt=False, the method returns a 4-tuple. Each entry is either True or False. True indicates that the respective LED is on; False means off. If asInt=True, return value is a bit vector indicating which LEDs are on.
Definition at line 482 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getMeanAccelerator | ( | self | ) | 
Accessor that provides locking.
Definition at line 392 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getMeanGyro | ( | self | ) | 
Accessor that provides locking.
Definition at line 407 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getNunchukFactoryCalibrationSettings | ( | self | ) | 
Obtain calibration data from nunchuk accelerometer. Retrieve factory-installed calibration data for the Nunchuk's accelerometer. Returns a two-tuple with the calibration numbers for zero and one:
Definition at line 552 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getRumble | ( | self | ) | 
Definition at line 453 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getStdevAccelerator | ( | self | ) | 
Accessor that provides locking.
Definition at line 397 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getStdevGyro | ( | self | ) | 
Accessor that provides locking.
Definition at line 412 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getVarianceAccelerator | ( | self | ) | 
Accessor that provides locking.
Definition at line 402 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getVarianceGyro | ( | self | ) | 
Accessor that provides locking.
Definition at line 417 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.getWiimoteState | ( | self | ) | 
Returns the most recent Wiistate instance. Provides proper locking.
Definition at line 387 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.motionPlusPresent | ( | self | ) | 
Return True/False to indicate whether a Wiimotion Plus is detected. Note: The return value is accurate only after at least one Wiimote state has been read. This means that either _steadyStateCallback or _calibrationCallback must have run at least once.
Definition at line 579 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.nunchukPresent | ( | self | ) | 
Return True/False to indicate whether a Nunchuk is detected. Note: The return value is accurate only after at least one Wiimote state has been read. This means that either _steadyStateCallback or _calibrationCallback must have run at least once.
Definition at line 592 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.printState | ( | self | ) | 
Definition at line 648 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.setAccelerometerCalibration | ( | self, | |
| zeroReadingList, | |||
| oneReadingList | |||
| ) | 
Definition at line 563 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.setAccelerometerCalibration | ( | self, | |
| zeroReadingNPArray, | |||
| oneReadingNPArray | |||
| ) | 
Definition at line 566 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.setGyroCalibration | ( | self, | |
| gyroTriplet | |||
| ) | 
Definition at line 573 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.setLEDs | ( | self, | |
| statusList | |||
| ) | 
Set the four Wii LEDs according to statusList statusList must be a 4-tuple. Each entry is either True/1, False/0, or None. True (or 1) will turn the respective LED on; False (or 0) turns it off, and None leaves the state unchanged.
Definition at line 461 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.setNunchukAccelerometerCalibration | ( | self, | |
| zeroReadingList, | |||
| oneReadingList | |||
| ) | 
Definition at line 576 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.setRumble | ( | self, | |
| switchPos | |||
| ) | 
Start of stop rumble (i.e. vibration). 1: start; 0: stop
Definition at line 449 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.shutdown | ( | self | ) | 
Definition at line 651 of file WIIMote.py.
| def wiimote.WIIMote.WIIMote.zeroDevice | ( | self | ) | 
Find the at-rest values of the accelerometer and the gyro. Collect NUM_ZEROING_READINGS readings of acc and gyro. Average them. If the standard deviation of any of the six axes exceeds a threshold that was determined empirically, then the calibration fails. Else the gyro is biased to compensate for its at-rest offset. The offset is the abs(mean(Gyro)). The stdev thresholds are documented in wiimoteConstants.py. Note that we always use the Wiimote's factory-installed zeroing data. In the code below we nonetheless compute the stats for the accelerometer, in case this behavior is to change in the future. We sleep while the samples are taken. In order to prevent other threads from reading bad values for mean/stdev, and variance, we lock access to those vars.
Definition at line 247 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 77 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 83 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 80 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 78 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 84 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 81 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 89 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 88 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 86 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 79 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 76 of file WIIMote.py.
| 
 | private | 
Definition at line 271 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 74 of file WIIMote.py.
| 
 | staticprivate | 
Definition at line 73 of file WIIMote.py.
| 
 | static | 
Definition at line 71 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.calibrationSamples | 
Definition at line 109 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.gatherCalibrationStats | 
Definition at line 107 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.lastZeroingTime | 
Definition at line 105 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.latestCalibrationSuccessful | 
Definition at line 147 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.maxAccReading | 
Definition at line 609 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.maxGyroReading | 
Definition at line 632 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.meanAcc | 
Definition at line 130 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.meanAccMetric | 
Definition at line 131 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.meanGyro | 
Definition at line 139 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.meanGyroMetric | 
Definition at line 140 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.sampleRate | 
Definition at line 124 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.stdevAcc | 
Definition at line 133 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.stdevAccMetric | 
Definition at line 134 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.stdevGyro | 
Definition at line 142 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.stdevGyroMetric | 
Definition at line 143 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.varAcc | 
Definition at line 136 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.varGyroMetric | 
Definition at line 145 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.wiiMoteState | 
Definition at line 123 of file WIIMote.py.
| wiimote.WIIMote.WIIMote.wiiStateLock | 
Definition at line 122 of file WIIMote.py.