pierre masala
/
Servo
nmbbghgj
Fork of Servo by
Diff: Servo.cpp
- Revision:
- 0:30b972d2dcec
diff -r 000000000000 -r 30b972d2dcec Servo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.cpp Sun Oct 17 13:13:50 2010 +0000 @@ -0,0 +1,26 @@ +#include "Servo.h" +#include "mbed.h" + + Servo::Servo(PinName Pin) : ServoPin(Pin) {} + + void Servo::SetPosition(int Pos) { + Position = Pos; + } + + void Servo::StartPulse() { + ServoPin = 1; + PulseStop.attach_us(this, &Servo::EndPulse, Position); + } + + void Servo::EndPulse() { + ServoPin = 0; + } + + void Servo::Enable(int StartPos, int Period) { + Position = StartPos; + Pulse.attach_us(this, &Servo::StartPulse, Period); + } + + void Servo::Disable() { + Pulse.detach(); + } \ No newline at end of file