Dependents: serial_connected_mcu_nucleo serial_connected_mcu_nucleo
Diff: servo.cpp
- Revision:
- 1:ffc003a37375
- Parent:
- 0:54b8292756b8
- Child:
- 2:58169cf31b49
diff -r 54b8292756b8 -r ffc003a37375 servo.cpp --- a/servo.cpp Fri Feb 26 16:09:01 2016 +0000 +++ b/servo.cpp Fri Feb 26 16:27:25 2016 +0000 @@ -1,4 +1,5 @@ #include "servo.hpp" +#include "mbed_stl.hpp" #include "mbed.h" namespace mbed_stl { @@ -11,7 +12,7 @@ } void servo::set_position(float pos) { - pwm.pulsewidth((1.0f - pos) * min_position_sec + pos * max_position_sec); + pwm_.pulsewidth(linear_algebra::lerp(pos, min_position_sec_, max_position_sec_)); } } /* namespace mbed_stl */