Wii Nunchuk via RFM69HW to Duplo 9203 Remote Control Car Kit using ARM mbed on a FRDM-KL25Z
Dependencies: CRC FastPWM RFM69 USBDevice WakeUp WiiChuk_compat mbed-rtos mbed tlc59108
Fork of wiiNunchuk_compat by
Diff: main.cpp
- Revision:
- 14:579137c8ceac
- Parent:
- 13:ab524cb4f768
- Child:
- 15:8888e36afe43
--- a/main.cpp Tue Jun 28 10:17:09 2016 +0000 +++ b/main.cpp Tue Jun 28 10:33:10 2016 +0000 @@ -23,12 +23,25 @@ const char *directions[8] = { "XR", "RR", "RX", "FR", "FX", "FF", "XF", "RF" }; +#define DEBUG 0 +#ifdef DEBUG #ifdef USBSerial USBSerial pc; #else Serial pc(USBTX, USBRX); #endif +#else + class Null : public Stream { + public: + Null(): Stream("null") {} + void baud(int) {} + protected: + virtual int _getc() { return 0; } + virtual int _putc(int c) { return 0; } + }; + Null pc; +#endif #if TARGET_KL25Z DigitalOut gnd(PTC0); PwmOut ir(PTD4); @@ -129,7 +142,9 @@ while(1) { //if (!central) for(int x = 0; x < 5; x++) { - //pc.printf(central? "stop %s %d\r\n" : "direction %s %d\r\n", directions[direction], stops_sent); + #if DEBUG + pc.printf(central? "stop %s %d\r\n" : "direction %s %d\r\n", directions[direction], stops_sent); + #endif if (central) { if (stops_sent < 50) { stops_sent++; @@ -378,7 +393,6 @@ if (!read) pc.printf("len %d\r\n", radio.DATALEN); } else if (rx_to_snooze) { - pc.printf("to snooze\r\n"); rx_snooze.start(200); rx_to_snooze = false; } @@ -399,7 +413,7 @@ if (p > 3) c = 7; direction = c; -#if DEBUG +#if DEBUG > 1 pc.printf("%d: ", sizeof(struct nunchuk)); pc.printf("x%3d y%3d c%1d z%1d --", n->X, n->Y, n->C, n->Z); pc.printf("x%d y%d z%d -- %.3f %s \r\n", n->aX, n->aY, n->aZ, R, direction);//s[c]);