Simplified pwm pinout to ESC control library for the KL25Z

Files at this revision

API Documentation at this revision

Comitter:
MitchJCarlson
Date:
Sun Jun 09 22:23:45 2013 +0000
Parent:
0:ec466ef657a2
Commit message:
refactor

Changed in this revision

esc.cpp Show annotated file Show diff for this revision Revisions of this file
esc.h Show annotated file Show diff for this revision Revisions of this file
diff -r ec466ef657a2 -r 4c02fede684b esc.cpp
--- a/esc.cpp	Thu Jun 06 18:57:02 2013 +0000
+++ b/esc.cpp	Sun Jun 09 22:23:45 2013 +0000
@@ -1,11 +1,3 @@
-/**
- * esc.cpp
- * UWB Quadcopter Project
- *
- *
- * @Author
- * Mitch Carlson
- */
 #include "mbed.h"
 #include "esc.h"
 
@@ -16,8 +8,9 @@
     }
 
 bool ESC::setThrottle(int t) {
-    if (t >= 0 && t <= 100) {     // qualify range
-        throttle = t*10 + 1000;     // map range, 1-2 ms (1000-2000us)
+    if (t >= 0 && t <= 100) {       // qualify range, 0-100
+        throttle = t*10 + 1000;     // map to range, 1-2 ms (1000-2000us)
+        esc.pulsewidth_us(throttle);
         return true;
     }
     return false;
diff -r ec466ef657a2 -r 4c02fede684b esc.h
--- a/esc.h	Thu Jun 06 18:57:02 2013 +0000
+++ b/esc.h	Sun Jun 09 22:23:45 2013 +0000
@@ -1,11 +1,3 @@
-/**
- * esc.h
- * UWB Quadcopter Project
- *
- *
- * @Author
- * Mitch Carlson
- */
 #ifndef UWBQuad__ESC__H
 #define UWBQuad__ESC__H
 
@@ -69,7 +61,7 @@
     ESC(PwmOut,int=20);         // Constructor(pwmPinOut,period_ms)
     bool setThrottle(int);      // range 0-100
     void pulse(void);
-    
+        
 private:
     PwmOut esc;                 // pinout from MCU
     int period;