Yuta Kozaki / Mbed 2 deprecated winkey_1_3_11U24_smd

Dependencies:   mbed Servo LSM9DS1_Library_

Files at this revision

API Documentation at this revision

Comitter:
kzkyuta
Date:
Wed Feb 26 03:01:40 2020 +0000
Parent:
0:f66784158dab
Child:
2:bb491c4aa97b
Commit message:
This version is for spontaneous blink detection ;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Feb 26 02:49:19 2020 +0000
+++ b/main.cpp	Wed Feb 26 03:01:40 2020 +0000
@@ -33,7 +33,7 @@
 unsigned short counter_wait;
 unsigned short position;
 
-#define THRESHOLD  800
+#define THRESHOLD  500
 #define THRESHOLD_VOL  -100
 
 DigitalOut rled(P0_15);
@@ -81,9 +81,12 @@
     position ++;
     int tempPos = position % ARRAY_SIZE;
     
-    array_0[tempPos] = (val_0 + array_0[ARRAY_SIZE - 1] + array_0[ARRAY_SIZE - 2] + array_0[ARRAY_SIZE - 3])/3;
-    array_1[tempPos] = (val_1 + array_1[ARRAY_SIZE - 1] + array_1[ARRAY_SIZE - 2] + array_1[ARRAY_SIZE - 3])/3;
-    array_2[tempPos] = (val_2 + array_2[ARRAY_SIZE - 1] + array_2[ARRAY_SIZE - 2] + array_2[ARRAY_SIZE - 3])/3;
+    //array_0[tempPos] = (val_0 + array_0[ARRAY_SIZE - 1] + array_0[ARRAY_SIZE - 2] + array_0[ARRAY_SIZE - 3])/3;
+//    array_1[tempPos] = (val_1 + array_1[ARRAY_SIZE - 1] + array_1[ARRAY_SIZE - 2] + array_1[ARRAY_SIZE - 3])/3;
+//    array_2[tempPos] = (val_2 + array_2[ARRAY_SIZE - 1] + array_2[ARRAY_SIZE - 2] + array_2[ARRAY_SIZE - 3])/3;
+    array_0[tempPos] = val_0;
+    array_1[tempPos] = val_1;
+    array_2[tempPos] = val_2;
     
     // calcurate the differenciation.
     if(tempPos == ARRAY_SIZE - 1){
@@ -215,15 +218,14 @@
                     isAutoActuation = true;
             }
         }
-    }
-    //else{
-//        if((diff_0 > THRESHOLD) || (diff_1 > THRESHOLD) || (diff_2 > THRESHOLD)){
-//            if((diff_0 < 3000) || (diff_1 < 3000) || (diff_2 < 3000)){
-//                    pc.printf("detected");
-//                    isAutoActuation = true;
-//            }
-//        }
-//    }    
+    }else{
+        if((diff_0 > THRESHOLD) || (diff_1 > THRESHOLD) || (diff_2 > THRESHOLD)){
+            if((diff_0 < 3000) || (diff_1 < 3000) || (diff_2 < 3000)){
+                    pc.printf("detected");
+                    isAutoActuation = true;
+            }
+        }
+    }    
 }
 
 int main() {