TB6612FNG用のモータコントロールライブラリ
Dependents: BLE_WALLBOT_BLE net_trap_noBLE MoveTest Avoid ... more
Revision 4:95d5e9ee8c15, committed 2014-08-29
- Comitter:
- jksoft
- Date:
- Fri Aug 29 04:40:40 2014 +0000
- Parent:
- 3:34ddc9038d9d
- Commit message:
- test
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 34ddc9038d9d -r 95d5e9ee8c15 TB6612.cpp --- a/TB6612.cpp Mon Jul 07 14:44:34 2014 +0000 +++ b/TB6612.cpp Fri Aug 29 04:40:40 2014 +0000 @@ -33,6 +33,7 @@ _fwd = 0; _rev = 0; _pwm = 0.0; + stat = 0; _pwm.period(0.001); } @@ -47,17 +48,20 @@ _pwm = speed; _fwd = 1; _rev = 0; + stat = 1; } else if( speed < 0.0 ) { _pwm = -speed; _fwd = 0; _rev = 1; + stat = -1; } else { _fwd = 1; _rev = 1; + stat = 0; } return speed==0 ? 0 : speed > 0 ? 1 : -1; } \ No newline at end of file
diff -r 34ddc9038d9d -r 95d5e9ee8c15 TB6612.h --- a/TB6612.h Mon Jul 07 14:44:34 2014 +0000 +++ b/TB6612.h Fri Aug 29 04:40:40 2014 +0000 @@ -77,11 +77,16 @@ { speed(value); } + operator int() + { + return(stat); + } protected: PwmOut _pwm; DigitalOut _fwd; DigitalOut _rev; + int stat; }; #endif