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.
Fork of Motor2 by
Revision 11:87a73d40ce5b, committed 2014-10-19
- Comitter:
- Reiko
- Date:
- Sun Oct 19 08:31:18 2014 +0000
- Parent:
- 10:b0e6051a6109
- Child:
- 12:1d3fb22bbdf9
- Commit message:
- Removed second direction pin
Changed in this revision
| motor.cpp | Show annotated file Show diff for this revision Revisions of this file |
| motor.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/motor.cpp Sun Nov 03 11:41:40 2013 +0000
+++ b/motor.cpp Sun Oct 19 08:31:18 2014 +0000
@@ -1,7 +1,7 @@
#include "motor.h"
-Motor::Motor(PinName PWMpin, PCA9555 *ioExt, unsigned int dir1Pin, unsigned int dir2Pin, PinName encA, PinName encB)
- : pwm(PWMpin), extIO(ioExt), dir1(dir1Pin), dir2(dir2Pin), qed(encA, encB) {
+Motor::Motor(PinName PWMpin, PCA9555 *ioExt, unsigned int dirPin, PinName encA, PinName encB)
+ : pwm(PWMpin), extIO(ioExt), dir(dirPin), qed(encA, encB) {
pwmPeriod = 2500;
PwmOut pwm(PWMpin);
@@ -32,13 +32,11 @@
currentPWM = newPWM;
if (newPWM < 0) {
pwm.pulsewidth_us(-1 * newPWM);
- extIO->setPin(dir1);
- extIO->clearPin(dir2);
+ extIO->setPin(dir);
} else {
pwm.pulsewidth_us(newPWM);
- extIO->clearPin(dir1);
- extIO->setPin(dir2);
- }
+ extIO->clearPin(dir);
+ }
}
int Motor::getSpeed() {
--- a/motor.h Sun Nov 03 11:41:40 2013 +0000
+++ b/motor.h Sun Oct 19 08:31:18 2014 +0000
@@ -21,7 +21,7 @@
* @param encA Encoder pin
* @param encB Encoder pin
*/
- Motor(PinName PWMpin, PCA9555 *ioExt, unsigned int dir1Pin, unsigned int dir2Pin, PinName encA, PinName encB);
+ Motor(PinName PWMpin, PCA9555 *ioExt, unsigned int dirPin, PinName encA, PinName encB);
/** Set speed setpoint
*
@@ -70,8 +70,7 @@
private:
PwmOut pwm;
PCA9555 *extIO;
- unsigned int dir1;
- unsigned int dir2;
+ unsigned int dir;
QED qed;
int currentSpeed;
