Eurobot2012_Primary
Dependencies: mbed Eurobot_2012_Primary
Diff: Servo/Servo.cpp
- Revision:
- 26:0995f61cb7b8
- Parent:
- 23:1901cb6d0d95
diff -r 143b19c1fb05 -r 0995f61cb7b8 Servo/Servo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo/Servo.cpp Wed Oct 17 22:22:47 2012 +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