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: SoftPWM
Fork of RC_Servo by
Diff: RC_Servo.cpp
- Revision:
- 1:8482eba4d652
- Parent:
- 0:b8dcca3dc509
- Child:
- 6:cf65fc8b0de1
--- a/RC_Servo.cpp Mon May 21 15:55:54 2018 +0000
+++ b/RC_Servo.cpp Mon May 21 16:07:20 2018 +0000
@@ -12,16 +12,22 @@
}
}
+int RC_Servo::setLimits (int Tmin, int Tmax) {
+ if ((Tmin > 400) && (Tmin < Tmax)) _pMin = Tmin;
+ else return Tmin;
+ if ((Tmax < 2400) && (Tmin < Tmax)) _pMax = Tmax;
+ else return Tmax;
+ return 0;
+}
+
void RC_Servo::write (float position)
{
if ((position >= 0) && (position <= 1))
_pwm.pulsewidth_us (_pMin + (int)(position * (_pMax - _pMin)));
}
-/**
- * A short hand for write
- */
RC_Servo& RC_Servo::operator= (float position)
{
write (position);
+ return *this;
}
