2017 hongo b team

Files at this revision

API Documentation at this revision

Comitter:
Komazawa_sun
Date:
Fri Sep 08 03:31:56 2017 +0000
Commit message:
????

Changed in this revision

BoolProcess.cpp Show annotated file Show diff for this revision Revisions of this file
BoolProcess.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 69948f240c2d BoolProcess.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BoolProcess.cpp	Fri Sep 08 03:31:56 2017 +0000
@@ -0,0 +1,52 @@
+#include "BoolProcess.h"
+
+BoolProcess::BoolProcess()
+:   wait_count()
+{
+    stamp_count = false;
+}
+
+bool BoolProcess::push(int _in_val, unsigned int wait_time_ms)
+{
+    in_val = (bool)_in_val;
+    if(wait_time_ms == 0)
+        out_val = in_val;
+    else
+        wait_count.start();
+        
+    if(in_val == 1)
+    {
+        if(wait_count.read_ms() >= wait_time_ms)
+        {
+            out_val = 1;
+        }
+        else
+            out_val = 0;
+    }
+    else
+    {
+        out_val = 0;
+        wait_count.reset();
+    }
+    
+    return out_val;
+}
+
+bool BoolProcess::stamp(int _in_val)
+{
+    in_val = (bool)_in_val;
+    if(in_val == true && stamp_count == false)
+    {
+        out_val = true != out_val;
+        stamp_count = true;
+    }
+    else if(in_val == false && stamp_count == true)
+        stamp_count = false;
+        
+    return out_val;
+}
+
+void BoolProcess::stamp_reset()
+{
+    out_val = 0;
+}
diff -r 000000000000 -r 69948f240c2d BoolProcess.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BoolProcess.h	Fri Sep 08 03:31:56 2017 +0000
@@ -0,0 +1,20 @@
+#ifndef BOOLPROCESS_H
+#define BOOLPROCESS_H
+
+#include "mbed.h"
+
+class BoolProcess
+{
+    public:
+        BoolProcess();
+        bool push(int _in_val, unsigned int wait_time_ms = 0);
+        bool stamp(int _in_val);
+        void stamp_reset();
+    private:
+        bool stamp_count;
+        Timer wait_count;
+        bool in_val;
+        bool out_val;
+};
+
+#endif
\ No newline at end of file