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
00001 #include "Servo.h" 00002 #include "mbed.h" 00003 00004 Servo::Servo(PinName Pin) : ServoPin(Pin) {} 00005 00006 void Servo::SetPosition(int Pos) { 00007 Position = Pos; 00008 } 00009 00010 void Servo::StartPulse() { 00011 ServoPin = 1; 00012 PulseStop.attach(callback(this, &Servo::EndPulse), std::chrono::microseconds(Position)); 00013 } 00014 00015 void Servo::EndPulse() { 00016 ServoPin = 0; 00017 } 00018 00019 void Servo::Enable(int StartPos, int Period) { 00020 Position = StartPos; 00021 Pulse.attach(callback(this, &Servo::StartPulse), std::chrono::microseconds(Period)); 00022 } 00023 00024 void Servo::Disable() { 00025 Pulse.detach(); 00026 }
Generated on Thu Jul 14 2022 22:15:28 by
