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.
Diff: ServoController.hpp
- Revision:
- 1:1b8a9e5b178d
- Parent:
- 0:1703d29e0899
- Child:
- 2:92d4dc70d591
--- a/ServoController.hpp Tue Sep 06 18:05:38 2016 +0000
+++ b/ServoController.hpp Tue Sep 06 22:10:01 2016 +0200
@@ -0,0 +1,37 @@
+#ifndef SERVOCONTROLLER_H
+#define SERVOCONTROLLER_H
+
+//Includes
+#include "mbed.h"
+
+/**
+ * A Servo controller library
+ *
+ * @author CA Bezuidenhout
+ * @section USAGE EXAMPLE
+ */
+class ServoController
+{
+public:
+ /**
+ * @param pwmPin : PWM pin of servo
+ * @param ref : Reference angle in degress (default 90)
+ */
+ ServoController(PinName pwmPin, float ref = 90.0f);
+
+ /**
+ * @return The current angle of the servo
+ */
+ float GetAngle();
+
+private:
+ PWMOut _servo;
+ float _angle;
+ float _ref;
+ static const float DEG2PW = (2.0f-1.0f)/180.0f;
+
+ void SetServo();
+ void SetAbsolute(float angle);
+};
+
+#endif