Control an H-Bridge using a PwmOut (enable) and two DigitalOuts (direction select). Does not change PWM Frequency

Dependents:   Confetti_Launcher

Files at this revision

API Documentation at this revision

Comitter:
jdonnal
Date:
Mon Sep 23 19:48:36 2019 +0000
Parent:
2:f265e441bcd9
Commit message:
Remove PWM frequency setting and added = operator as alias to speed function

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	Tue Nov 23 16:16:43 2010 +0000
+++ b/Motor.cpp	Mon Sep 23 19:48:36 2019 +0000
@@ -28,7 +28,7 @@
         _pwm(pwm), _fwd(fwd), _rev(rev) {
 
     // Set initial condition of PWM
-    _pwm.period(0.001);
+    //_pwm.period(0.001);
     _pwm = 0;
 
     // Initial condition of output enables
@@ -42,5 +42,11 @@
     _pwm = abs(speed);
 }
 
+Motor& Motor::operator= (float val) { 
+    speed(val);
+    return *this;
+}
 
 
+
+
--- a/Motor.h	Tue Nov 23 16:16:43 2010 +0000
+++ b/Motor.h	Mon Sep 23 19:48:36 2019 +0000
@@ -46,6 +46,8 @@
      */
     void speed(float speed);
 
+    Motor& operator= (float speed);
+    operator float();
 protected:
     PwmOut _pwm;
     DigitalOut _fwd;