PM2_Lib

Dependencies:   LSM9DS1 RangeFinder FastPWM

Committer:
pmic
Date:
Tue Apr 06 11:21:54 2021 +0000
Revision:
4:9c003c402033
Parent:
0:86129f1b4a93
Child:
10:fe74e8909d3f
Update Libary via copy+past, no idea why it is not working via mbed studio.

Who changed what in which revision?

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