Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Servo_PWM/Servo_PWM.cpp
- Committer:
- maetugr
- Date:
- 2014-02-14
- Revision:
- 40:2ca410923691
- Parent:
- 29:8b7362a2ee14
File content as of revision 40:2ca410923691:
#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);
}
