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 Motor by
Revision 1:0efe3050d83e, committed 2016-09-29
- Comitter:
- number_key
- Date:
- Thu Sep 29 16:49:58 2016 +0000
- Parent:
- 0:ebfdfce2d069
- Commit message:
- relayMD
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 Mon Sep 05 00:49:28 2016 +0000
+++ b/motor.cpp Thu Sep 29 16:49:58 2016 +0000
@@ -8,19 +8,10 @@
_pin3 = 0;
}
-void Motor::motor(float n)
+void Motor::motor(double n)
{
- if(n > 0) {
- _pin1=0;
- _pin2=1;
- _pin3=n;
- } else if(n < 0) {
- _pin1=1;
- _pin2=0;
- _pin3=-n;
- } else {
- _pin1=0;
- _pin2=0;
- _pin3=1;
- }
+ _pin1 = (n<0);
+ _pin2 = (n>0);
+ if(n) _pin3 = 1.0;
+ else _pin3 = fabs(n);
}
\ No newline at end of file
--- a/motor.h Mon Sep 05 00:49:28 2016 +0000
+++ b/motor.h Thu Sep 29 16:49:58 2016 +0000
@@ -7,7 +7,7 @@
public:
//pin1,pin2 Digital pin3 Pwm
Motor(PinName pin1, PinName pin2, PinName pin3);
- void motor(float n);
+ void motor(double n);
private:
DigitalOut _pin1;
