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.
Diff: motordriver.cpp
- Revision:
- 6:8f0bbf0076ca
- Parent:
- 5:3110b9209d3c
--- 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.