Servomotor
Dependents: ServomotorTests NerfUSTarget
Revision 8:e42a3a06e072, committed 2017-04-11
- Comitter:
- GaiSensei
- Date:
- Tue Apr 11 20:00:09 2017 +0000
- Parent:
- 7:a5b6e6d9ad3d
- Commit message:
- Details final
Changed in this revision
--- /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
--- /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);
+}
--- 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);
}