Wrapper library for ESC PWM throttle control.
Fork of ESC by
esc.cpp
- Committer:
- MitchJCarlson
- Date:
- 2013-06-06
- Revision:
- 0:ec466ef657a2
- Child:
- 1:4c02fede684b
File content as of revision 0:ec466ef657a2:
/** * esc.cpp * UWB Quadcopter Project * * * @Author * Mitch Carlson */ #include "mbed.h" #include "esc.h" ESC::ESC(PwmOut pwmPinOut, int period) : esc(pwmPinOut), period(period), throttle(1000) { esc.period_ms(period); esc.pulsewidth_us(throttle); } bool ESC::setThrottle(int t) { if (t >= 0 && t <= 100) { // qualify range throttle = t*10 + 1000; // map range, 1-2 ms (1000-2000us) return true; } return false; } void ESC::pulse(void) { esc.pulsewidth_us(throttle); }