PES2_mbed_os_6

Dependencies:   Servo

Revision:
2:87ca9b0c9992
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Servo.cpp	Sat Mar 13 11:06:23 2021 +0100
@@ -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(callback(this, &Servo::EndPulse), Position);
+    }
+
+    void Servo::EndPulse() {
+        ServoPin = 0;
+    }
+
+    void Servo::Enable(int StartPos, int Period) {
+        Position = StartPos;
+        Pulse.attach_us(callback(this, &Servo::StartPulse), Period);
+    }
+
+    void Servo::Disable() {
+        Pulse.detach();
+    }
\ No newline at end of file