PES2_mbed_os_6

Dependencies:   Servo

Committer:
boro
Date:
Tue Mar 16 17:28:04 2021 +0100
Revision:
3:a292bdaf03f6
Parent:
2:87ca9b0c9992
controller updated

Who changed what in which revision?

UserRevisionLine numberNew contents of line
boro 2:87ca9b0c9992 1 #include "Servo.h"
boro 2:87ca9b0c9992 2 #include "mbed.h"
boro 2:87ca9b0c9992 3
boro 2:87ca9b0c9992 4 Servo::Servo(PinName Pin) : ServoPin(Pin) {}
boro 2:87ca9b0c9992 5
boro 2:87ca9b0c9992 6 void Servo::SetPosition(int Pos) {
boro 2:87ca9b0c9992 7 Position = Pos;
boro 2:87ca9b0c9992 8 }
boro 2:87ca9b0c9992 9
boro 2:87ca9b0c9992 10 void Servo::StartPulse() {
boro 2:87ca9b0c9992 11 ServoPin = 1;
boro 2:87ca9b0c9992 12 PulseStop.attach_us(callback(this, &Servo::EndPulse), Position);
boro 2:87ca9b0c9992 13 }
boro 2:87ca9b0c9992 14
boro 2:87ca9b0c9992 15 void Servo::EndPulse() {
boro 2:87ca9b0c9992 16 ServoPin = 0;
boro 2:87ca9b0c9992 17 }
boro 2:87ca9b0c9992 18
boro 2:87ca9b0c9992 19 void Servo::Enable(int StartPos, int Period) {
boro 2:87ca9b0c9992 20 Position = StartPos;
boro 2:87ca9b0c9992 21 Pulse.attach_us(callback(this, &Servo::StartPulse), Period);
boro 2:87ca9b0c9992 22 }
boro 2:87ca9b0c9992 23
boro 2:87ca9b0c9992 24 void Servo::Disable() {
boro 2:87ca9b0c9992 25 Pulse.detach();
boro 2:87ca9b0c9992 26 }