Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 6:8f0bbf0076ca, committed 2019-04-01
- Comitter:
- Gaetan_Andrieu
- Date:
- Mon Apr 01 16:16:43 2019 +0000
- Parent:
- 5:3110b9209d3c
- Commit message:
- projet
Changed in this revision
motordriver.cpp | Show annotated file Show diff for this revision Revisions of this file |
motordriver.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/motordriver.cpp Thu Nov 25 13:34:15 2010 +0000 +++ b/motordriver.cpp Mon Apr 01 16:16:43 2019 +0000 @@ -120,6 +120,19 @@ return -3;//error } +float Motor::direction(void) { + if ((_fwd == _rev) && (_pwm > 0)) { + return -2;//braking + } else if (_pwm == 0) { + return 2;//coasting + } else if ((_fwd == 0) && (_rev == 1)) { + return -1;//reversing + } else if ((_fwd == 1) && (_rev == 0)) { + return 1;//fowards + } else + return -3;//error +} + /* test code, this demonstrates working motor drivers.
--- a/motordriver.h Thu Nov 25 13:34:15 2010 +0000 +++ b/motordriver.h Mon Apr 01 16:16:43 2019 +0000 @@ -74,6 +74,7 @@ * @return state of motor, -1 to 1 is speed, -2 is braking, 2 is coasting. -3 is error. */ float state(void); + float direction(void); protected: PwmOut _pwm;