to move servo
Dependents: mbed-for-McuComm RTOS_Controller RTOS_Controller_v2 RTOS_Controller_v3 ... more
Revision 4:80a784fc179c, committed 2012-11-28
- Comitter:
- matsu
- Date:
- Wed Nov 28 10:41:04 2012 +0000
- Parent:
- 3:36b69a7ced07
- Commit message:
- I want you to permit using Servo class . If you have a something to say I will cancel publish my prigram using your Servo class . thank you
Changed in this revision
| Servo.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Servo.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Servo.cpp Thu Sep 02 17:34:43 2010 +0000
+++ b/Servo.cpp Wed Nov 28 10:41:04 2012 +0000
@@ -39,6 +39,7 @@
write(0.5);
}
+// _range = 0.0005
void Servo::write(float percent) {
float offset = _range * 2.0 * (percent - 0.5);
_pwm.pulsewidth(0.0015 + clamp(offset, -_range, _range));
@@ -48,6 +49,8 @@
void Servo::position(float degrees) {
float offset = _range * (degrees / _degrees);
_pwm.pulsewidth(0.0015 + clamp(offset, -_range, _range));
+ _pwm.pulsewidth(0.0015 + clamp(offset, -_range, _range));
+ _pwm.pulsewidth(0);
}
void Servo::calibrate(float range, float degrees) {
@@ -55,6 +58,7 @@
_degrees = degrees;
}
+
float Servo::read() {
return _p;
}
--- a/Servo.h Thu Sep 02 17:34:43 2010 +0000
+++ b/Servo.h Wed Nov 28 10:41:04 2012 +0000
@@ -82,6 +82,7 @@
* @param degrees Angle from centre to maximum/minimum position in degrees
*/
void calibrate(float range = 0.0005, float degrees = 45.0);
+
/** Shorthand for the write and read functions */
Servo& operator= (float percent);
@@ -95,4 +96,8 @@
float _p;
};
+
+
+
+
#endif