Servomotor

Dependents:   ServomotorTests NerfUSTarget

Files at this revision

API Documentation at this revision

Comitter:
GaiSensei
Date:
Tue Apr 11 20:00:09 2017 +0000
Parent:
7:a5b6e6d9ad3d
Commit message:
Details final

Changed in this revision

include/RealServomotor.hpp Show annotated file Show diff for this revision Revisions of this file
mbed_source/RealServomotor.cpp Show annotated file Show diff for this revision Revisions of this file
source/Servomotor.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r a5b6e6d9ad3d -r e42a3a06e072 include/RealServomotor.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/RealServomotor.hpp	Tue Apr 11 20:00:09 2017 +0000
@@ -0,0 +1,17 @@
+#ifndef REAL_SERVOMOTOR_HPP
+#define REAL_SERVOMOTOR_HPP
+
+#include "PwmOutInterface.hpp"
+#include "Servomotor.hpp"
+
+class RealServomotor : public Servomotor
+{
+    public:
+        RealServomotor(PwmOutInterface &pwm_out);
+        virtual void set_position_down();
+    
+    private:
+        PwmOutInterface &pwm_out;
+};
+
+#endif
\ No newline at end of file
diff -r a5b6e6d9ad3d -r e42a3a06e072 mbed_source/RealServomotor.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_source/RealServomotor.cpp	Tue Apr 11 20:00:09 2017 +0000
@@ -0,0 +1,15 @@
+#include "RealServomotor.hpp"
+#include "mbed.h"
+
+RealServomotor::RealServomotor(PwmOutInterface &pwm_out) : 
+    Servomotor(pwm_out),
+    pwm_out(pwm_out)
+{
+}
+
+void RealServomotor::set_position_down()
+{
+    set_angle(0);
+    wait_ms(300);
+    pwm_out.pulsewidth_us(0);
+}
diff -r a5b6e6d9ad3d -r e42a3a06e072 source/Servomotor.cpp
--- a/source/Servomotor.cpp	Tue Apr 11 03:48:35 2017 +0000
+++ b/source/Servomotor.cpp	Tue Apr 11 20:00:09 2017 +0000
@@ -1,8 +1,8 @@
 #include "Servomotor.hpp"
 
 Servomotor::Servomotor(PwmOutInterface &pwm_out) : 
-    pwm_out(pwm_out),
-    up_angle(90)
+    up_angle(90),
+    pwm_out(pwm_out)
 {
     
 }
@@ -23,5 +23,5 @@
 
 void Servomotor::set_position_down()
 {
-    set_angle(up_angle - 75);
+    set_angle(up_angle - 90);
 }