動作確認済み

Dependents:   NewMD2 NewMD3

Files at this revision

API Documentation at this revision

Comitter:
inst
Date:
Thu Aug 25 04:59:47 2016 +0000
Parent:
9:0d8dbe2671cd
Commit message:
????????????

Changed in this revision

GMD.hpp Show annotated file Show diff for this revision Revisions of this file
GMD_impl.hpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0d8dbe2671cd -r 2fa9eeafd727 GMD.hpp
--- a/GMD.hpp	Thu Aug 25 00:01:01 2016 +0000
+++ b/GMD.hpp	Thu Aug 25 04:59:47 2016 +0000
@@ -17,6 +17,7 @@
 private:
     static const float _frequency_to_tick_coeff;
     static const uint32_t _default_frequency_kHz;
+    static const float _threshold;
 
     FastPWM* _pwm[2];
     DigitalOut _shut_down;
diff -r 0d8dbe2671cd -r 2fa9eeafd727 GMD_impl.hpp
--- a/GMD_impl.hpp	Thu Aug 25 00:01:01 2016 +0000
+++ b/GMD_impl.hpp	Thu Aug 25 04:59:47 2016 +0000
@@ -8,6 +8,9 @@
 const uint32_t GMD<MIN, MAX>::_default_frequency_kHz = 20;
 
 template <size_t MIN, size_t MAX>
+const float GMD<MIN, MAX>::_threshold = 0.02f;
+
+template <size_t MIN, size_t MAX>
 GMD<MIN, MAX>::GMD(PinName p0, PinName p1, PinName shut_down) : _shut_down(shut_down, 1) {
     _pwm[0] = new FastPWM(p0);
     _pwm[1] = new FastPWM(p1);
@@ -33,6 +36,13 @@
 
 template <size_t MIN, size_t MAX>
 float GMD<MIN, MAX>::set(float p) {
+    if (abs(p) < _threshold) {
+        _pwm[0]->write(0.0f);
+        _pwm[1]->write(0.0f);
+        _shut_down = 1;
+        return p;
+    }
+    
     p = std::max(-1.0f, std::min(p, 1.0f));
 
     p = (abs(p) * (MAX - MIN) + MIN) * sign(p);