First import from throwbot

Files at this revision

API Documentation at this revision

Comitter:
Throwbot
Date:
Sun Oct 05 12:20:47 2014 +0000
Parent:
0:5b2bf6e79b07
Commit message:
Motors code

Changed in this revision

motors.cpp Show annotated file Show diff for this revision Revisions of this file
motors.h Show annotated file Show diff for this revision Revisions of this file
diff -r 5b2bf6e79b07 -r 201d986498c7 motors.cpp
--- a/motors.cpp	Thu May 08 19:11:31 2014 +0000
+++ b/motors.cpp	Sun Oct 05 12:20:47 2014 +0000
@@ -14,4 +14,14 @@
 
     Left->scale *= -1;
     Right->scale *= -1;              
-}    
\ No newline at end of file
+}    
+void Motors::reverse(bool m)
+{
+    if(m)
+        Right->scale *= -1; //reverse right motor
+    else
+        Left->scale *= -1;  //reverse left motor
+}
+
+//TODO: write in a function that automatically sets the motors to be oriented properly. Use the
+//gyroscopes and accelerometer to do this.
\ No newline at end of file
diff -r 5b2bf6e79b07 -r 201d986498c7 motors.h
--- a/motors.h	Thu May 08 19:11:31 2014 +0000
+++ b/motors.h	Sun Oct 05 12:20:47 2014 +0000
@@ -18,6 +18,7 @@
     
     Motors(TB6612 * L, TB6612 * R, PinName STBY);
     
-    void flip();                 
+    void flip();                
+    void reverse(bool m);   //reverse one of the motors (0=right, 1=left) 
 };
 #endif
\ No newline at end of file