/ TB6612FNG2

Fork of TB6612FNG2 by Junichi Katsu

Files at this revision

API Documentation at this revision

Comitter:
Throwbot
Date:
Thu May 08 19:11:04 2014 +0000
Parent:
1:051a7ecff13e
Child:
3:cb336a5cf19e
Commit message:
1

Changed in this revision

TB6612.cpp Show annotated file Show diff for this revision Revisions of this file
TB6612.h Show annotated file Show diff for this revision Revisions of this file
--- a/TB6612.cpp	Mon Nov 12 16:39:11 2012 +0000
+++ b/TB6612.cpp	Thu May 08 19:11:04 2014 +0000
@@ -11,7 +11,7 @@
 
 // TB6612 Class Constructor
 TB6612::TB6612(PinName pwm, PinName fwd, PinName rev):
-        _pwm(pwm), _fwd(fwd), _rev(rev) {
+        scale(1), _pwm(pwm), _fwd(fwd), _rev(rev) {
 
     _fwd = 0;
     _rev = 0;
@@ -23,16 +23,18 @@
 //  arg
 //   int speed -100 -- 0 -- 100
 void TB6612::speed(int speed) {
-        
+    
+    speed *= scale;
+    
     if( speed > 0 )
     {
-        _pwm = ((float)speed) / 100.0;
+        _pwm = ((float)speed)/ 100.0;
         _fwd = 1;
         _rev = 0;
     }
     else if( speed < 0 )
     {
-        _pwm = -((float)speed) / 100.0;
+        _pwm = -((float)speed)/ 100.0;
         _fwd = 0;
         _rev = 1;
     }
@@ -42,14 +44,3 @@
         _rev = 1;
     }
 }
-
-
-// Speed Control with time-out
-//  arg
-//   int speed -100 -- 0 -- 100
-//   int time  0
-void TB6612::move(int sspeed , int time)
-{
-    speed(sspeed);
-    wait_ms(time);
-}
--- a/TB6612.h	Mon Nov 12 16:39:11 2012 +0000
+++ b/TB6612.h	Thu May 08 19:11:04 2014 +0000
@@ -13,9 +13,12 @@
 
 class TB6612 {
 public:
+
+    int scale;
+
     TB6612(PinName pwm, PinName fwd, PinName rev);
+    
     void speed(int speed);
-    void move(int speed , int time);
     void operator= ( int value )
     {
         speed(value);