The majority of the information used to generate this library comes from the Wii-brew website, and specifically these three pages:
http://www.wiibrew.org/wiki/Wiimote
http://www.wiibrew.org/wiki/Wiimote/Extension_Controllers
http://www.wiibrew.org/wiki/Wii_Balance_Board
Currently my library is based around the bluecove interface for accessing the bluetooth hardware:
http://code.google.com/p/bluecove/
In order for bluecove to compile under eclipse for 64-bit systems requires the following flag passed to the JVM:
<jvmarg
value="-d32"/>
The standard bluecove library does not work with 64-bit Matlab, in order to get this to work requires downloading the snapshot #63:
http://snapshot.bluecove.org/distribution/download/2.1.1-SNAPSHOT/
In order to get the library to work with Matlab requires a few adjustments. To begin, exit Matlab if it is open. Then open Matlab's static class path:
<MATLABPATH>/toolbox/local/classpath.txt
Add the path to the bluecove library bluecove-2.1.1-SNAPSHOT.jar to the end of classpath.txt. The path to the Processing files is most likely something like:
<BLUECOVEPATH>/Libraries/bluecove-2.1.1-SNAPSHOT.jar
Now restart Matlab and add dynamic paths to the directories containing the java class code. These must contain the full path to the class path including the root folder containing the package:
javaaddpath({ ...
'/Users/bingjeff/Projects/WiiBalance/bin/', ...
'/Users/bingjeff/Projects/WiiBalance/bin/wiibalance', ...
'/Users/bingjeff/Projects/WiiBalance/bin/wiibalance/devices' ...
'/Users/bingjeff/Projects/WiiBalance/bin/wiibalance/gui' ...
'/Users/bingjeff/Projects/WiiBalance/bin/wiibalance/server'})
To test if the bluecove library is reachable with Matlab try the following commands:
import javax.bluetooth.*
o = LocalDevice.getLocalDevice();
A very basic script for reading data from Matlab using the Wii Library is then done by running the following example m-file:
% Create DataHandler object
oDataHand = wiibalance.gui.DataHandler();
% Initialize DataHandler
oDataHand.init();
% Get data from DataHandler
while(oDataHand.isRunning)
oDataHand.update();
end
% Close connection to bluetooth
oDataHand.stop();
On Windows Vista/7 systems additional steps may be required. These include downloading a specially compiled library bluecove.dll and setting a system property.
System.setProperty("bluecove.stack", "widcomm");