UT CS Bootcamp code for creating a secret knock
Dependencies: MMA8451Q mbed tsi_sensor
Fork of UTCSBootcamp by
Revision 3:1afe0cfab2d1, committed 2013-08-22
- Comitter:
- ccoleman
- Date:
- Thu Aug 22 21:52:21 2013 +0000
- Parent:
- 2:0a64af7ab7c6
- Child:
- 4:4233d072b5af
- Commit message:
- More better documentation.
Changed in this revision
CarAPI.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/CarAPI.cpp Thu Aug 22 21:48:25 2013 +0000 +++ b/CarAPI.cpp Thu Aug 22 21:52:21 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) pc.printf("move(%f,%f,%f)",leftWheelPower,rightWheelPower,seconds); TFC_SetMotorPWM(leftWheelPower,rightWheelPower); // power for n seconds with both wheels the same power @@ -32,7 +29,6 @@ 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) pc.printf("parkingBrake()"); TFC_SetMotorPWM(0.1,0.1); //slight spinning of wheel @@ -40,64 +36,51 @@ } /******************************** INPUTS AND OUTPUTS ********************************/ -/** check to see if the car is crashing into something */ + bool checkIsCrashing(){ if(debug) pc.printf("checkIsCrashing()"); return abs(accelerometer.getAccX()) >= crashSensitivity; } -/** 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) pc.printf("toggleLED0()"); TFC_BAT_LED0_TOGGLE; } -/* toggle led 1 */ void toggleLED1(){ if(debug) pc.printf("toggleLED1()"); TFC_BAT_LED1_TOGGLE; } -/* toggle led 2 */ void toggleLED2(){ if(debug) pc.printf("toggleLED2()"); TFC_BAT_LED2_TOGGLE; } -/* toggle led 3 */ void toggleLED3(){ if(debug) pc.printf("toggleLED3()"); TFC_BAT_LED3_TOGGLE; } -/** is Button B pressed */ bool isButtonBPressed(){ if(debug) pc.printf("isButtonBPressed()=",TFC_PUSH_BUTTON_1_PRESSED); return TFC_PUSH_BUTTON_1_PRESSED; } -/** read Potentiometer 0. returns [-1,1] */ float getPot0(){ if(debug) pc.printf("getPot0()= %f", TFC_ReadPot(0)); return TFC_ReadPot(0); } -/** read Potentiometer 1. returns [-1,1] */ float getPot1(){ if(debug) pc.printf("getPot1()= %f", TFC_ReadPot(1)); return TFC_ReadPot(1); } -/** How much batter remains. returns [0,1] */ float batteryLife(){ if(debug) pc.printf("batteryLife()= %f", TFC_ReadBatteryVoltage()); return TFC_ReadBatteryVoltage(); @@ -105,31 +88,26 @@ /******************************** Changing Variables ********************************/ -/** set the base turn offset*/ void setOffset(float _turnOffset){ if(debug) pc.printf("setOffset()= %f", _turnOffset); turnOffset = _turnOffset; } -/** get the base turn offset */ float getOffset(){ if(debug) pc.printf("getOffset()= %f", turnOffset); return turnOffset; } -/** set the base crash sensitivity*/ void setCrashSensitivity(float _sensitivity){ if(debug) pc.printf("setCrashSensitivity()= %f", _sensitivity); crashSensitivity = _sensitivity; } -/** return the crash sensitivity */ float getCrashSensitivity(){ if(debug) pc.printf("getCrashSensitivity()= %f", crashSensitivity); return crashSensitivity; } -/** turn on debugging*/ void setDebug(bool _debug){ if(debug) pc.printf("setDebug()= %d", _debug); debug = _debug;