UT CS Bootcamp code for creating a secret knock
Dependencies: MMA8451Q mbed tsi_sensor
Fork of UTCSBootcamp by
Revision 5:8dde418f0d1e, committed 2013-08-23
- Comitter:
- ccoleman
- Date:
- Fri Aug 23 00:40:51 2013 +0000
- Parent:
- 4:4233d072b5af
- Child:
- 6:4b101f051a1f
- Commit message:
- Minor documentation edits.
Changed in this revision
CarAPI.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/CarAPI.cpp Fri Aug 23 00:38:23 2013 +0000 +++ b/CarAPI.cpp Fri Aug 23 00:40:51 2013 +0000 @@ -13,17 +13,14 @@ /******************************** Wheels and Motor ********************************/ -/* turn the car. turnAngle should be between [-1,1] */ void turn(float turnAngle){ turn(0,turnAngle); } -/** move forward with the given power, turn angle, for a specified time */ void move(float power, float seconds){ move (power,power,seconds); } -/** move forward with the given powers for each wheel, turn angle, for a specified time */ void move(float leftWheelPower,float rightWheelPower, float seconds){ if(debug) utrace("move(%f,%f,%f)\r\n",leftWheelPower,rightWheelPower,seconds); TFC_SetMotorPWM(leftWheelPower,rightWheelPower); // power for n seconds with both wheels the same power @@ -32,27 +29,24 @@ wait(0.05); //need a wait to register or sebsequent calls to this method won't spin the wheel; hardware can't detect instaneous input? } -/** lock the wheels*/ void parkingBrake(){ if(debug) utrace("parkingBrake()\r\n"); TFC_SetMotorPWM(0.1,0.1); //slight spinning of wheel wait(0.1); } -/** do nothing for the specified time */ void sleep(float seconds){ if(debug) utrace("sleep(%f)\r\n",seconds); } /******************************** INPUTS AND OUTPUTS ********************************/ -/** check to see if the car is crashing into something */ + bool checkIsCrashing(){ if(debug) utrace("checkIsCrashing()\r\n"); return abs(accelerometer.getAccX()) >= crashSensitivity; } -/** check to see if the car has stopped */ bool isStopped() { double x = accelerometer.getAccX(); @@ -64,60 +58,45 @@ return 0; } - - -/** Return the line direction - line to the left of center. return [-1,0 - line to the right of center. return (0,1] - line in center. return 0 -*/ float lineDirection(){ return 0; } -/* toggle led 0 */ void toggleLED0(){ if(debug) utrace("toggleLED0()\r\n"); TFC_BAT_LED0_TOGGLE; } -/* toggle led 1 */ void toggleLED1(){ if(debug) utrace("toggleLED1()\r\n"); TFC_BAT_LED1_TOGGLE; } -/* toggle led 2 */ void toggleLED2(){ if(debug) utrace("toggleLED2()\r\n"); TFC_BAT_LED2_TOGGLE; } -/* toggle led 3 */ void toggleLED3(){ if(debug) utrace("toggleLED3()\r\n"); TFC_BAT_LED3_TOGGLE; } -/** is Button B pressed */ bool isButtonBPressed(){ if(debug) utrace("isButtonBPressed()=%d\r\n",TFC_PUSH_BUTTON_1_PRESSED); return TFC_PUSH_BUTTON_1_PRESSED; } -/** read Potentiometer 0. returns [-1,1] */ float getPot0(){ if(debug) utrace("getPot0()= %f\r\n", TFC_ReadPot(0)); return TFC_ReadPot(0); } -/** read Potentiometer 1. returns [-1,1] */ float getPot1(){ if(debug) utrace("getPot1()= %f\r\n", TFC_ReadPot(1)); return TFC_ReadPot(1); } -/** How much batter remains. returns [0,1] */ float batteryLife(){ if(debug) utrace("batteryLife()= %f\r\n", TFC_ReadBatteryVoltage()); return TFC_ReadBatteryVoltage(); @@ -125,43 +104,36 @@ /******************************** Changing Variables ********************************/ -/** set the base turn offset*/ void setOffset(float _turnOffset){ if(debug) utrace("setOffset(%f)\r\n", _turnOffset); turnOffset = _turnOffset; } -/** get the base turn offset */ float getOffset(){ if(debug) utrace("getOffset()= %f\r\n", turnOffset); return turnOffset; } -/** set the base crash sensitivity*/ void setCrashSensitivity(float _sensitivity){ if(debug) utrace("setCrashSensitivity(%f)\r\n", _sensitivity); crashSensitivity = _sensitivity; } -/** return the crash sensitivity */ float getCrashSensitivity(){ if(debug) utrace("getCrashSensitivity()= %f\r\n", crashSensitivity); return crashSensitivity; } -/** set the base stop sensitivity*/ void setStopSensitivity(float _sensitivity){ if(debug) utrace("setStopSensitivity(%f)\r\n", _sensitivity); stopSensitivity = _sensitivity; } -/** return the stop sensitivity */ float getStopSensitivity(){ if(debug) utrace("getStopSensitivity()= %f\r\n", stopSensitivity); return stopSensitivity; } -/** turn on debugging*/ void setDebug(bool _debug){ if(debug) utrace("setDebug()= %d\r\n", _debug); debug = _debug;