Servo library based on Timer instead of PWM. Fork of original https://os.mbed.com/users/jdenkers/code/Servo/ and modified for compatibility with MbedOS6+
Servo.h@0:30b972d2dcec, 2010-10-17 (annotated)
- Committer:
- jdenkers
- Date:
- Sun Oct 17 13:13:50 2010 +0000
- Revision:
- 0:30b972d2dcec
- Child:
- 1:352133517ccc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jdenkers | 0:30b972d2dcec | 1 | #ifndef MBED_SERVO_H |
jdenkers | 0:30b972d2dcec | 2 | #define MBED_SERVO_H |
jdenkers | 0:30b972d2dcec | 3 | |
jdenkers | 0:30b972d2dcec | 4 | #include "mbed.h" |
jdenkers | 0:30b972d2dcec | 5 | |
jdenkers | 0:30b972d2dcec | 6 | class Servo { |
jdenkers | 0:30b972d2dcec | 7 | |
jdenkers | 0:30b972d2dcec | 8 | public: |
jdenkers | 0:30b972d2dcec | 9 | Servo(PinName Pin); |
jdenkers | 0:30b972d2dcec | 10 | void SetPosition(int NewPos); |
jdenkers | 0:30b972d2dcec | 11 | void Enable(int StartPos, int Period); |
jdenkers | 0:30b972d2dcec | 12 | void Disable(); |
jdenkers | 0:30b972d2dcec | 13 | |
jdenkers | 0:30b972d2dcec | 14 | private: |
jdenkers | 0:30b972d2dcec | 15 | void StartPulse(); |
jdenkers | 0:30b972d2dcec | 16 | void EndPulse(); |
jdenkers | 0:30b972d2dcec | 17 | |
jdenkers | 0:30b972d2dcec | 18 | int Position; |
jdenkers | 0:30b972d2dcec | 19 | DigitalOut ServoPin; |
jdenkers | 0:30b972d2dcec | 20 | Ticker Pulse; |
jdenkers | 0:30b972d2dcec | 21 | Timeout PulseStop; |
jdenkers | 0:30b972d2dcec | 22 | }; |
jdenkers | 0:30b972d2dcec | 23 | |
jdenkers | 0:30b972d2dcec | 24 | #endif |