チャタリング防止できそうなものです。

Dependents:   2019NHK_A_manual_red 2019NHK_A_manual_red 2019NHK_A_manual_blue

Files at this revision

API Documentation at this revision

Comitter:
ec30109b
Date:
Thu Oct 03 08:32:17 2019 +0000
Parent:
3:dce990775412
Commit message:
less thread

Changed in this revision

chatteringremoval.cpp Show annotated file Show diff for this revision Revisions of this file
chatteringremoval.h Show annotated file Show diff for this revision Revisions of this file
diff -r dce990775412 -r 3c82016a7083 chatteringremoval.cpp
--- a/chatteringremoval.cpp	Mon Sep 23 12:21:09 2019 +0000
+++ b/chatteringremoval.cpp	Thu Oct 03 08:32:17 2019 +0000
@@ -9,7 +9,7 @@
     flag = false;
     flag_ = true;
     mode = true;
-    thread.start(callback(this, &chatteringremoval::threadloop));
+    //thread.start(callback(this, &chatteringremoval::threadloop));
 }
 
 chatteringremoval::chatteringremoval(float time):
@@ -21,7 +21,7 @@
     flag = false;
     flag_ = true;
     mode = false;
-    thread.start(callback(this, &chatteringremoval::threadloop));
+    //thread.start(callback(this, &chatteringremoval::threadloop));
 }
 
 unsigned int chatteringremoval::getCount()
@@ -46,6 +46,8 @@
 void chatteringremoval::assignvalue(bool data)
 {
     _data = data;
+    checkchattering();
+        valuecount();
 }
 
 void chatteringremoval::threadloop()
@@ -68,7 +70,7 @@
     }
     
     
-    if((t.read_us() >= _time*1000*1000) && b){
+    if((t.read() >= _time) && b){
         value = 1;
         flag = false;
     }    
diff -r dce990775412 -r 3c82016a7083 chatteringremoval.h
--- a/chatteringremoval.h	Mon Sep 23 12:21:09 2019 +0000
+++ b/chatteringremoval.h	Thu Oct 03 08:32:17 2019 +0000
@@ -78,7 +78,7 @@
     void valuecount();
     void checkchattering();
     DigitalIn d_in;
-    Thread thread;
+    //Thread thread;
     Timer t;
     unsigned int count;
     bool flag;