Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Servo.cpp@0:e35f0aee6a1f, 2020-06-23 (annotated)
- Committer:
- leonNg
- Date:
- Tue Jun 23 02:47:53 2020 +0000
- Revision:
- 0:e35f0aee6a1f
XP70HV_STM32
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| leonNg | 0:e35f0aee6a1f | 1 | #include "mbed.h" |
| leonNg | 0:e35f0aee6a1f | 2 | #include "Servo.h" |
| leonNg | 0:e35f0aee6a1f | 3 | |
| leonNg | 0:e35f0aee6a1f | 4 | Servo::Servo(PinName pin, double period, double pulseWidth) |
| leonNg | 0:e35f0aee6a1f | 5 | { |
| leonNg | 0:e35f0aee6a1f | 6 | servo = new PwmOut(pin); |
| leonNg | 0:e35f0aee6a1f | 7 | this->period = period; |
| leonNg | 0:e35f0aee6a1f | 8 | this->pulseWidth = pulseWidth; |
| leonNg | 0:e35f0aee6a1f | 9 | init(); |
| leonNg | 0:e35f0aee6a1f | 10 | } |
| leonNg | 0:e35f0aee6a1f | 11 | |
| leonNg | 0:e35f0aee6a1f | 12 | void Servo::servoMove(double width) |
| leonNg | 0:e35f0aee6a1f | 13 | { |
| leonNg | 0:e35f0aee6a1f | 14 | servo->pulsewidth(width); |
| leonNg | 0:e35f0aee6a1f | 15 | } |
| leonNg | 0:e35f0aee6a1f | 16 | |
| leonNg | 0:e35f0aee6a1f | 17 | void Servo::init() |
| leonNg | 0:e35f0aee6a1f | 18 | { |
| leonNg | 0:e35f0aee6a1f | 19 | servo->period(period); |
| leonNg | 0:e35f0aee6a1f | 20 | } |