Compatible with TB6612FNG motor driver

Dependents:   MobileArcade

Files at this revision

API Documentation at this revision

Comitter:
abraha2d
Date:
Tue Dec 11 06:32:10 2018 +0000
Parent:
2:f265e441bcd9
Commit message:
Add support for short braking

Changed in this revision

Motor.cpp Show annotated file Show diff for this revision Revisions of this file
Motor.h Show annotated file Show diff for this revision Revisions of this file
--- a/Motor.cpp	Tue Nov 23 16:16:43 2010 +0000
+++ b/Motor.cpp	Tue Dec 11 06:32:10 2018 +0000
@@ -32,8 +32,8 @@
     _pwm = 0;
 
     // Initial condition of output enables
-    _fwd = 0;
-    _rev = 0;
+    _fwd = 1;
+    _rev = 1;
 }
 
 void Motor::speed(float speed) {
@@ -42,5 +42,8 @@
     _pwm = abs(speed);
 }
 
-
-
+void Motor::brake(int shortBrake) {
+    _fwd = shortBrake;
+    _rev = shortBrake;
+    _pwm = 0;
+}
--- a/Motor.h	Tue Nov 23 16:16:43 2010 +0000
+++ b/Motor.h	Tue Dec 11 06:32:10 2018 +0000
@@ -45,6 +45,12 @@
      * @param speed The speed of the motor as a normalised value between -1.0 and 1.0
      */
     void speed(float speed);
+    
+    /** Brake the motor
+     * 
+     * @param shortBrake Whether to short brake the motor or not.
+     */
+    void brake(int shortBrake);
 
 protected:
     PwmOut _pwm;