![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Totale Testversion
Dependencies: mbed
Fork of DrehungMitStopp by
Servo.cpp@5:24350e6fc9d7, 2017-05-21 (annotated)
- Committer:
- freunjor
- Date:
- Sun May 21 15:29:46 2017 +0000
- Revision:
- 5:24350e6fc9d7
- Parent:
- 3:cfb0b6bcf568
mainmix_1 pro min;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
EHess | 3:cfb0b6bcf568 | 1 | #include "Servo.h" |
EHess | 3:cfb0b6bcf568 | 2 | #include "mbed.h" |
EHess | 3:cfb0b6bcf568 | 3 | |
EHess | 3:cfb0b6bcf568 | 4 | Servo::Servo(PinName Pin) : ServoPin(Pin) {} |
EHess | 3:cfb0b6bcf568 | 5 | |
EHess | 3:cfb0b6bcf568 | 6 | void Servo::SetPosition(int Pos) { |
EHess | 3:cfb0b6bcf568 | 7 | Position = Pos; |
EHess | 3:cfb0b6bcf568 | 8 | } |
EHess | 3:cfb0b6bcf568 | 9 | |
EHess | 3:cfb0b6bcf568 | 10 | void Servo::StartPulse() { |
EHess | 3:cfb0b6bcf568 | 11 | ServoPin = 1; |
EHess | 3:cfb0b6bcf568 | 12 | PulseStop.attach_us(this, &Servo::EndPulse, Position); |
EHess | 3:cfb0b6bcf568 | 13 | } |
EHess | 3:cfb0b6bcf568 | 14 | |
EHess | 3:cfb0b6bcf568 | 15 | void Servo::EndPulse() { |
EHess | 3:cfb0b6bcf568 | 16 | ServoPin = 0; |
EHess | 3:cfb0b6bcf568 | 17 | } |
EHess | 3:cfb0b6bcf568 | 18 | |
EHess | 3:cfb0b6bcf568 | 19 | void Servo::Enable(int StartPos, int Period) { |
EHess | 3:cfb0b6bcf568 | 20 | Position = StartPos; |
EHess | 3:cfb0b6bcf568 | 21 | Pulse.attach_us(this, &Servo::StartPulse, Period); |
EHess | 3:cfb0b6bcf568 | 22 | } |
EHess | 3:cfb0b6bcf568 | 23 | |
EHess | 3:cfb0b6bcf568 | 24 | void Servo::Disable() { |
EHess | 3:cfb0b6bcf568 | 25 | Pulse.detach(); |
EHess | 3:cfb0b6bcf568 | 26 | } |