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.
Dependencies: LSM9DS1 RangeFinder FastPWM
Dependents: PM2_Example_PES_board PM2_Example_PES_board PM2_Example_PES_board PM2_Example_PES_board ... more
Diff: Servo.cpp
- Revision:
- 4:9c003c402033
- Parent:
- 0:86129f1b4a93
- Child:
- 10:fe74e8909d3f
--- a/Servo.cpp Thu Apr 01 14:31:43 2021 +0000
+++ b/Servo.cpp Tue Apr 06 11:21:54 2021 +0000
@@ -1,26 +1,30 @@
#include "Servo.h"
-#include "mbed.h"
+
+Servo::Servo(PinName Pin) : ServoPin(Pin) {}
- Servo::Servo(PinName Pin) : ServoPin(Pin) {}
+void Servo::SetPosition(int Pos)
+{
+ Position = Pos;
+}
- void Servo::SetPosition(int Pos) {
- Position = Pos;
- }
+void Servo::StartPulse()
+{
+ ServoPin = 1;
+ PulseStop.attach_us(callback(this, &Servo::EndPulse), Position);
+}
- void Servo::StartPulse() {
- ServoPin = 1;
- PulseStop.attach_us(callback(this, &Servo::EndPulse), Position);
- }
-
- void Servo::EndPulse() {
- ServoPin = 0;
- }
+void Servo::EndPulse()
+{
+ ServoPin = 0;
+}
- void Servo::Enable(int StartPos, int Period) {
- Position = StartPos;
- Pulse.attach_us(callback(this, &Servo::StartPulse), Period);
- }
+void Servo::Enable(int StartPos, int Period)
+{
+ Position = StartPos;
+ Pulse.attach_us(callback(this, &Servo::StartPulse), Period);
+}
- void Servo::Disable() {
- Pulse.detach();
- }
\ No newline at end of file
+void Servo::Disable()
+{
+ Pulse.detach();
+}
\ No newline at end of file
