Lightweight FlyBed1, structure based on KK-Board Firmware First this one should work, then I can get more complex FlyBed1 working :)
Diff: Servo_PWM/Servo_PWM.cpp
- Revision:
- 0:d51bf879e9df
diff -r 000000000000 -r d51bf879e9df Servo_PWM/Servo_PWM.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo_PWM/Servo_PWM.cpp Mon Apr 29 19:41:06 2013 +0000 @@ -0,0 +1,25 @@ +#include "Servo_PWM.h" +#include "mbed.h" + +Servo_PWM::Servo_PWM(PinName Pin, int frequency) : ServoPin(Pin) { + SetFrequency(frequency); + ServoPin = 0; + initialize(); +} + +void Servo_PWM::SetFrequency(int frequency) { + ServoPin.period(1.0/frequency); +} + +void Servo_PWM::initialize() { + // initialize ESC + SetPosition(0); // zero throttle +} + +void Servo_PWM::SetPosition(int position) { + ServoPin.pulsewidth_us(position+1000); +} + +void Servo_PWM::operator=(int position) { + SetPosition(position); +} \ No newline at end of file