nunchuck: C port; FTI; C++ wraps C

Some API changes were made as well, see docs/apichanges.md.

Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
Jon Trulson
2017-01-31 13:06:26 -07:00
parent 1bbb9386b7
commit 0749f130e1
15 changed files with 740 additions and 214 deletions

View File

@ -24,38 +24,38 @@
public class NUNCHUCKSample {
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a nunchuck controller bus 0
upm_nunchuck.NUNCHUCK nunchuck = new upm_nunchuck.NUNCHUCK(0);
public static void main(String[] args) throws InterruptedException {
// ! [Interesting]
// Instantiate a nunchuck controller bus 0
upm_nunchuck.NUNCHUCK nunchuck = new upm_nunchuck.NUNCHUCK(3);
// always do this first
System.out.println("Initializing... ");
if (!nunchuck.init()) {
System.err.println("nunchuck->init() failed.");
return;
}
while (true)
{
nunchuck.update();
System.out.println("stickX: "
+ nunchuck.getStickX()
+ ", stickY: "
+ nunchuck.getStickY());
System.out.println("accelX: "
+ nunchuck.getAccelX()
+ ", accelY: "
+ nunchuck.getAccelY()
+ ", accelZ: "
+ nunchuck.getAccelZ());
while (true) {
nunchuck.update();
System.out.println("stickX: " + nunchuck.getStickX() + ", stickY: "
+ nunchuck.getStickY());
System.out.println("accelX: " + nunchuck.getAccelX() + ", accelY: "
+ nunchuck.getAccelY() + ", accelZ: " + nunchuck.getAccelZ());
if (nunchuck.getButtonC())
System.out.println("Button C pressed");
else
System.out.println("Button C not pressed");
if (nunchuck.getButtonC())
System.out.println("Button C pressed");
else
System.out.println("Button C not pressed");
if (nunchuck.getButtonZ())
System.out.println("Button Z pressed");
else
System.out.println("Button Z not pressed");
if (nunchuck.getButtonZ())
System.out.println("Button Z pressed");
else
System.out.println("Button Z not pressed");
Thread.sleep(100);
}
// ! [Interesting]
}
Thread.sleep(1000);
}
// ! [Interesting]
}
}
}