TB6612FNG用のモータコントロールライブラリ
Dependents: WallbotMotorTest WallbotMouse WallbotR4_BTLE BLE_RCBController_Motor ... more
Fork of TB6612FNG by
Revision 1:051a7ecff13e, committed 2012-11-12
- Comitter:
- jksoft
- Date:
- Mon Nov 12 16:39:11 2012 +0000
- Parent:
- 0:810f315ba3dc
- Commit message:
- API??????
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 |
diff -r 810f315ba3dc -r 051a7ecff13e TB6612.cpp --- a/TB6612.cpp Tue Oct 23 15:24:30 2012 +0000 +++ b/TB6612.cpp Mon Nov 12 16:39:11 2012 +0000 @@ -17,29 +17,22 @@ _rev = 0; _pwm = 0.0; _pwm.period(0.001); - - bspeed = 0.0; - timer_flag = false; } // Speed Control // arg -// float speed -1.0 - 0.0 - 1.0 -void TB6612::speed(float speed) { - - if( timer_flag == true ) return; - - bspeed = speed; - - if( speed > 0.0 ) +// int speed -100 -- 0 -- 100 +void TB6612::speed(int speed) { + + if( speed > 0 ) { - _pwm = speed; + _pwm = ((float)speed) / 100.0; _fwd = 1; _rev = 0; } - else if( speed < 0.0 ) + else if( speed < 0 ) { - _pwm = -speed; + _pwm = -((float)speed) / 100.0; _fwd = 0; _rev = 1; } @@ -53,19 +46,10 @@ // Speed Control with time-out // arg -// float sspeed:-1.0 - 0.0 - 1.0 -// float time :0.0- -void TB6612::move(float sspeed , float time) +// int speed -100 -- 0 -- 100 +// int time 0 +void TB6612::move(int sspeed , int time) { speed(sspeed); - timer_flag = true; - timer.attach(this,&TB6612::timeout,time); + wait_ms(time); } - - -void TB6612::timeout() -{ - timer_flag = false; - speed(bspeed); -} -
diff -r 810f315ba3dc -r 051a7ecff13e TB6612.h --- a/TB6612.h Tue Oct 23 15:24:30 2012 +0000 +++ b/TB6612.h Mon Nov 12 16:39:11 2012 +0000 @@ -14,9 +14,9 @@ class TB6612 { public: TB6612(PinName pwm, PinName fwd, PinName rev); - void speed(float speed); - void move(float speed , float time); - void operator= ( float value ) + void speed(int speed); + void move(int speed , int time); + void operator= ( int value ) { speed(value); } @@ -25,11 +25,6 @@ PwmOut _pwm; DigitalOut _fwd; DigitalOut _rev; - Timeout timer; - float bspeed; - bool timer_flag; - void timeout(); - }; #endif