Wii nunchuk 3rd party compatible controller library (WiiChuk_compat) test

Dependencies:   mbed WiiChuk_compat

Committer:
gbrush
Date:
Mon Mar 14 23:48:15 2011 +0000
Revision:
0:7c98bcd8a245
Initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gbrush 0:7c98bcd8a245 1 #include "mbed.h"
gbrush 0:7c98bcd8a245 2
gbrush 0:7c98bcd8a245 3 #include "WiiChuk_compat.h"
gbrush 0:7c98bcd8a245 4
gbrush 0:7c98bcd8a245 5 WiiChuck WiiNun(p9, p10);
gbrush 0:7c98bcd8a245 6 Serial pc(USBTX, USBRX);
gbrush 0:7c98bcd8a245 7
gbrush 0:7c98bcd8a245 8 int main() {
gbrush 0:7c98bcd8a245 9
gbrush 0:7c98bcd8a245 10
gbrush 0:7c98bcd8a245 11 pc.baud(115200);
gbrush 0:7c98bcd8a245 12 pc.printf("wii test begin \r\n");
gbrush 0:7c98bcd8a245 13
gbrush 0:7c98bcd8a245 14 int joyX = 0;int joyY = 0;
gbrush 0:7c98bcd8a245 15 int accX = 0;int accY = 0;int accZ = 0;
gbrush 0:7c98bcd8a245 16 int buttonC = 0;int buttonZ = 0;
gbrush 0:7c98bcd8a245 17
gbrush 0:7c98bcd8a245 18 while(1) {
gbrush 0:7c98bcd8a245 19 bool read = WiiNun.Read(&joyX,&joyY,&accX,&accY,&accZ,&buttonC,&buttonZ);
gbrush 0:7c98bcd8a245 20 if(read)
gbrush 0:7c98bcd8a245 21 {
gbrush 0:7c98bcd8a245 22 pc.printf("x%3d y%3d c%1d z%1d --", joyX, joyY, buttonC, buttonZ);
gbrush 0:7c98bcd8a245 23 pc.printf("x%d y%d z%d \r", accX, accY, accZ);
gbrush 0:7c98bcd8a245 24 }
gbrush 0:7c98bcd8a245 25 else
gbrush 0:7c98bcd8a245 26 {
gbrush 0:7c98bcd8a245 27 pc.printf("Error\n");
gbrush 0:7c98bcd8a245 28 }
gbrush 0:7c98bcd8a245 29 wait(0.001);
gbrush 0:7c98bcd8a245 30 }
gbrush 0:7c98bcd8a245 31 }