Dependents:   serial_connected_mcu_nucleo serial_connected_mcu_nucleo

Files at this revision

API Documentation at this revision

Comitter:
inst
Date:
Sat Jun 25 09:35:38 2016 +0000
Parent:
4:31ed2ce96ca3
Commit message:
sec => msec;

Changed in this revision

servo.cpp Show annotated file Show diff for this revision Revisions of this file
servo.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/servo.cpp	Sat Jun 25 09:16:14 2016 +0000
+++ b/servo.cpp	Sat Jun 25 09:35:38 2016 +0000
@@ -1,8 +1,8 @@
 #include "servo.hpp"
 #include "mbed.h"
 
-const float servo::_min_position_sec = 0.85f * 0.001f;
-const float servo::_max_position_sec = 2.15f * 0.001f;
+const float servo::_min_position_msec = 0.75f;
+const float servo::_max_position_msec = 2.15f;
 
 servo::servo(PinName pin) : _pwm(pin) {
     _pwm.period(20.0f * 0.001f);
@@ -16,5 +16,7 @@
     }
     pos += 1.0f;
     pos *= 0.5f;
-    _pwm.pulsewidth((1.0f - pos) * _min_position_sec + pos * _max_position_sec);
+    
+    float msec = (1.0f - pos) * _min_position_msec + pos * _max_position_msec;
+    _pwm.pulsewidth(msec * 0.001f);
 }
--- a/servo.hpp	Sat Jun 25 09:16:14 2016 +0000
+++ b/servo.hpp	Sat Jun 25 09:35:38 2016 +0000
@@ -9,9 +9,11 @@
     void set_position(float pos);
 
 private:
-    static const float _min_position_sec;
-    static const float _max_position_sec;
+    static const float _min_position_msec;
+    static const float _max_position_msec;
     PwmOut _pwm;
 };
 
+//#include "servo_impl.hpp"
+
 #endif