diff --git a/Wiiceiver/Blinker.h b/Wiiceiver/Blinker.h index 2509de2..c046a45 100644 --- a/Wiiceiver/Blinker.h +++ b/Wiiceiver/Blinker.h @@ -1,3 +1,32 @@ +/* + * (CC BY-NC-SA 4.0) + * http://creativecommons.org/licenses/by-nc-sa/4.0/ + * + * WARNING WARNING WARNING: attaching motors to a skateboard is + * a terribly dangerous thing to do. This software is totally + * for amusement and/or educational purposes. Don't obtain or + * make a wiiceiver (see below for instructions and parts), + * don't attach it to a skateboard, and CERTAINLY don't use it + * to zip around with just a tiny, ergonomic nunchuck instead + * of a bulky R/C controller. + * + * This software is made freely available. If you wish to + * sell it, don't. If you wish to modify it, DO! (and please + * let me know). Much of the code is derived from others out + * there, I've made attributuions where appropriate. + * + * http://austindavid.com/wiiceiver + * + * latest software: https://github.com/jaustindavid/wiiceiver + * schematic & parts: http://www.digikey.com/schemeit#t9g + * + * Enjoy! Be safe! + * + * (CC BY-NC-SA 4.0) Austin David, austin@austindavid.com + * 12 May 2014 + * + */ + #ifndef BLINKER_H #define BLINKER_H diff --git a/Wiiceiver/Chuck.h b/Wiiceiver/Chuck.h index dca2844..a35ff55 100644 --- a/Wiiceiver/Chuck.h +++ b/Wiiceiver/Chuck.h @@ -1,3 +1,32 @@ +/* + * (CC BY-NC-SA 4.0) + * http://creativecommons.org/licenses/by-nc-sa/4.0/ + * + * WARNING WARNING WARNING: attaching motors to a skateboard is + * a terribly dangerous thing to do. This software is totally + * for amusement and/or educational purposes. Don't obtain or + * make a wiiceiver (see below for instructions and parts), + * don't attach it to a skateboard, and CERTAINLY don't use it + * to zip around with just a tiny, ergonomic nunchuck instead + * of a bulky R/C controller. + * + * This software is made freely available. If you wish to + * sell it, don't. If you wish to modify it, DO! (and please + * let me know). Much of the code is derived from others out + * there, I've made attributuions where appropriate. + * + * http://austindavid.com/wiiceiver + * + * latest software: https://github.com/jaustindavid/wiiceiver + * schematic & parts: http://www.digikey.com/schemeit#t9g + * + * Enjoy! Be safe! + * + * (CC BY-NC-SA 4.0) Austin David, austin@austindavid.com + * 12 May 2014 + * + */ + #ifndef CHUCK_H #define CHUCK_H @@ -147,7 +176,7 @@ class Chuck { void readEEPROM() { byte storedY; - storedY = EEPROM.read(0); + storedY = EEPROM.read(EEPROM_Y_ADDY); #ifdef DEBUGGING_CHUCK Serial.print(F("Reading stored value: Y=")); Serial.println(storedY); @@ -169,7 +198,7 @@ class Chuck { void writeEEPROM() { - EEPROM.write(0, Y0); + EEPROM.write(EEPROM_Y_ADDY, Y0); #ifdef DEBUGGING_CHUCK Serial.print("Storing value: Y="); Serial.println(Y0); diff --git a/Wiiceiver/ElectronicSpeedController.h b/Wiiceiver/ElectronicSpeedController.h index 6d43b17..c0d9f2c 100644 --- a/Wiiceiver/ElectronicSpeedController.h +++ b/Wiiceiver/ElectronicSpeedController.h @@ -1,3 +1,32 @@ +/* + * (CC BY-NC-SA 4.0) + * http://creativecommons.org/licenses/by-nc-sa/4.0/ + * + * WARNING WARNING WARNING: attaching motors to a skateboard is + * a terribly dangerous thing to do. This software is totally + * for amusement and/or educational purposes. Don't obtain or + * make a wiiceiver (see below for instructions and parts), + * don't attach it to a skateboard, and CERTAINLY don't use it + * to zip around with just a tiny, ergonomic nunchuck instead + * of a bulky R/C controller. + * + * This software is made freely available. If you wish to + * sell it, don't. If you wish to modify it, DO! (and please + * let me know). Much of the code is derived from others out + * there, I've made attributuions where appropriate. + * + * http://austindavid.com/wiiceiver + * + * latest software: https://github.com/jaustindavid/wiiceiver + * schematic & parts: http://www.digikey.com/schemeit#t9g + * + * Enjoy! Be safe! + * + * (CC BY-NC-SA 4.0) Austin David, austin@austindavid.com + * 12 May 2014 + * + */ + #ifndef ELECTRONICSPEEDCONTROLLER_H #define ELECTRONICSPEEDCONTROLLER_H diff --git a/Wiiceiver/Smoother.h b/Wiiceiver/Smoother.h index 07cbfbb..82e221c 100644 --- a/Wiiceiver/Smoother.h +++ b/Wiiceiver/Smoother.h @@ -1,3 +1,32 @@ +/* + * (CC BY-NC-SA 4.0) + * http://creativecommons.org/licenses/by-nc-sa/4.0/ + * + * WARNING WARNING WARNING: attaching motors to a skateboard is + * a terribly dangerous thing to do. This software is totally + * for amusement and/or educational purposes. Don't obtain or + * make a wiiceiver (see below for instructions and parts), + * don't attach it to a skateboard, and CERTAINLY don't use it + * to zip around with just a tiny, ergonomic nunchuck instead + * of a bulky R/C controller. + * + * This software is made freely available. If you wish to + * sell it, don't. If you wish to modify it, DO! (and please + * let me know). Much of the code is derived from others out + * there, I've made attributuions where appropriate. + * + * http://austindavid.com/wiiceiver + * + * latest software: https://github.com/jaustindavid/wiiceiver + * schematic & parts: http://www.digikey.com/schemeit#t9g + * + * Enjoy! Be safe! + * + * (CC BY-NC-SA 4.0) Austin David, austin@austindavid.com + * 12 May 2014 + * + */ + #ifndef SMOOTHER_H #define SMOOTHER_H diff --git a/Wiiceiver/Throttle.h b/Wiiceiver/Throttle.h index 9a53bfe..c071184 100644 --- a/Wiiceiver/Throttle.h +++ b/Wiiceiver/Throttle.h @@ -1,3 +1,32 @@ +/* + * (CC BY-NC-SA 4.0) + * http://creativecommons.org/licenses/by-nc-sa/4.0/ + * + * WARNING WARNING WARNING: attaching motors to a skateboard is + * a terribly dangerous thing to do. This software is totally + * for amusement and/or educational purposes. Don't obtain or + * make a wiiceiver (see below for instructions and parts), + * don't attach it to a skateboard, and CERTAINLY don't use it + * to zip around with just a tiny, ergonomic nunchuck instead + * of a bulky R/C controller. + * + * This software is made freely available. If you wish to + * sell it, don't. If you wish to modify it, DO! (and please + * let me know). Much of the code is derived from others out + * there, I've made attributuions where appropriate. + * + * http://austindavid.com/wiiceiver + * + * latest software: https://github.com/jaustindavid/wiiceiver + * schematic & parts: http://www.digikey.com/schemeit#t9g + * + * Enjoy! Be safe! + * + * (CC BY-NC-SA 4.0) Austin David, austin@austindavid.com + * 12 May 2014 + * + */ + #ifndef THROTTLE_H #define THROTTLE_H @@ -87,31 +116,16 @@ class Throttle { #endif if (checkAutoCruise(chuck)) { - return throttle; // we're looking for autoCruise, so do that -- don't change the throttle + return throttle; // we're looking for autoCruise, so do that; + // don't change the throttle position } if (chuck.C) { // cruise control! -/* -#ifdef DEBUGGING_THROTTLE - Serial.print("CC: last = "); - Serial.print(throttle, 4); - Serial.print(", "); -#endif - - if (throttle < autoCruise) { - throttle += THROTTLE_CC_BUMP * 1.5; - } else { - if (chuck.Y > 0.5 && throttle < 1.0) { - throttle += THROTTLE_CC_BUMP * (chuck.Z ? 2 : 1); - } else if (chuck.Y < -0.5 && throttle > -1.0) { - throttle -= THROTTLE_CC_BUMP * (chuck.Z ? 2 : 1); - } // if (chuck.Y > 0.5 && throttle < 1.0) - else - } // if (throttle < THROTTLE_MIN_CC) - else -*/ + if (chuck.Y > 0.5 && throttle < 1.0) { throttle += THROTTLE_CC_BUMP * (chuck.Z ? 2 : 1); } else { - if (chuck.Y < -0.5 && throttle > -1.0) { + if (chuck.Y < -0.5 && throttle > 0) { throttle -= THROTTLE_CC_BUMP * (chuck.Z ? 2 : 1); } else { if (throttle < autoCruise) { diff --git a/Wiiceiver/Wiiceiver.ino b/Wiiceiver/Wiiceiver.ino index f57d6f9..7c1dd31 100644 --- a/Wiiceiver/Wiiceiver.ino +++ b/Wiiceiver/Wiiceiver.ino @@ -1,8 +1,36 @@ +/* + * (CC BY-NC-SA 4.0) + * http://creativecommons.org/licenses/by-nc-sa/4.0/ + * + * WARNING WARNING WARNING: attaching motors to a skateboard is + * a terribly dangerous thing to do. This software is totally + * for amusement and/or educational purposes. Don't obtain or + * make a wiiceiver (see below for instructions and parts), + * don't attach it to a skateboard, and CERTAINLY don't use it + * to zip around with just a tiny, ergonomic nunchuck instead + * of a bulky R/C controller. + * + * This software is made freely available. If you wish to + * sell it, don't. If you wish to modify it, DO! (and please + * let me know). Much of the code is derived from others out + * there, I've made attributuions where appropriate. + * + * http://austindavid.com/wiiceiver + * + * latest software: https://github.com/jaustindavid/wiiceiver + * schematic & parts: http://www.digikey.com/schemeit#t9g + * + * Enjoy! Be safe! + * + * (CC BY-NC-SA 4.0) Austin David, austin@austindavid.com + * 12 May 2014 + * + */ + #include #include #include - #define DEBUGGING #include "Blinker.h" @@ -23,7 +51,7 @@ #define THROTTLE_MIN 0.05 // the lowest throttle to send the ESC #define THROTTLE_CC_BUMP 0.002 // CC = 0.1% throttle increase; 50/s = 10s to hit 100% on cruise #define THROTTLE_SMOOTHNESS 0.05 // default "smoothing" factor -#define THROTTLE_MIN_CC 0.10 // minimum / inital speed for cruise crontrol +#define THROTTLE_MIN_CC 0.05 // minimum / inital speed for cruise crontrol // note that a different value may be stored in EEPROM #include "Throttle.h" diff --git a/Wiiceiver/pinouts.h b/Wiiceiver/pinouts.h index f94d39b..0183a38 100644 --- a/Wiiceiver/pinouts.h +++ b/Wiiceiver/pinouts.h @@ -1,3 +1,32 @@ +/* + * (CC BY-NC-SA 4.0) + * http://creativecommons.org/licenses/by-nc-sa/4.0/ + * + * WARNING WARNING WARNING: attaching motors to a skateboard is + * a terribly dangerous thing to do. This software is totally + * for amusement and/or educational purposes. Don't obtain or + * make a wiiceiver (see below for instructions and parts), + * don't attach it to a skateboard, and CERTAINLY don't use it + * to zip around with just a tiny, ergonomic nunchuck instead + * of a bulky R/C controller. + * + * This software is made freely available. If you wish to + * sell it, don't. If you wish to modify it, DO! (and please + * let me know). Much of the code is derived from others out + * there, I've made attributuions where appropriate. + * + * http://austindavid.com/wiiceiver + * + * latest software: https://github.com/jaustindavid/wiiceiver + * schematic & parts: http://www.digikey.com/schemeit#t9g + * + * Enjoy! Be safe! + * + * (CC BY-NC-SA 4.0) Austin David, austin@austindavid.com + * 12 May 2014 + * + */ + /* * version detection -- pin layouts change over time ... * historical note: CSEL = "chip select" @@ -49,7 +78,7 @@ void chipSelect (void) { /* * locations are specified in the following table: * rows == component - * columns = version; first column = v1, second = v2, etc + * columns = version; first column = v0, second = v1, etc */ int pinLocation(int pinID) { int pinMap[6][2] = { @@ -59,7 +88,7 @@ int pinLocation(int pinID) { {10, 9}, // ESC_PPM PWM required {9, 11}, // WII_POWER any digital pin {19, 19}, // WII_SCL A5, don't change - {18, 18}, // WII_SDA A4, don't cange + {18, 18}, // WII_SDA A4, don't change }; if (CSEL < 0) {