Jelle Raes / Mbed 2 deprecated VLC_decoder_finished

Dependencies:   mbed

Fork of VLC_decoder_copy_copy_omdatetkan by Jelle Raes

Revision:
5:a9d2050d7a12
Parent:
4:7ef585175a7b
Child:
6:5de275d946a6
diff -r 7ef585175a7b -r a9d2050d7a12 manchester.cpp
--- a/manchester.cpp	Tue May 15 08:31:13 2018 +0000
+++ b/manchester.cpp	Wed May 16 08:19:42 2018 +0000
@@ -10,18 +10,16 @@
 
 manchester::manchester()
 {
-    //pc.printf("object aag-nga-\r\n");
 }
 
 int manchester::decode()
 {
-    //pc.printf("bert zeg et\r\n");
+
     int previous,current,begin,end=0;
     int time=0;
     int i = 0;
     int datas[] = {1,1,1,1,0,0,0,0,0,0};
     notTimedOut = true;
-    //pc.printf("start code\r\n");
     timer.start();
     while(i< DELAY) {
         previous = current;
@@ -34,7 +32,6 @@
     }
     i = 0;
     timeout.attach(callback(this,&manchester::isTimedOut), 3);
-    //pc.printf("start clockcalculation\r\n");
     while(i<4 && notTimedOut) {
         end = begin;
         previous = current;
@@ -47,13 +44,10 @@
             i++;
         }
     }
-    //pc.printf("loop is done\r\n");
     if(notTimedOut == true) {
-        //pc.printf("not timed out\r\n");
         float atime=((float)time/3000000);
         i=4;
         wait(atime/2);
-        //pc.printf("start data\r\n");
         while(i<10) {
             int x = signal.read();
             wait(atime/2);
@@ -72,16 +66,24 @@
         pc.printf("with frequency %f\n\r",1/atime);
         pc.printf("data is:");
         int direction = getDirection(datas);
+        bool stopcode =getStopCode(datas);
         for(int j = 0; j<10; j++) {
             printf("%d",datas[j]);
         }
         printf("with direction:%d\r\n",direction);
         timer.stop();
-        return direction;
+        if(stopcode==true){
+            return direction;
+        }
+        else{
+            return 5;
+        }
+        //return direction;
     } else {
         printf("timed out\r\n");
         return 4;
     }
+//}
 }
 
 int manchester::getDirection(int* data)
@@ -103,25 +105,23 @@
     return direction;
 }
 
-bool manchester::vlcDetected()
-{
-    int i = 0;
-    bool detected = false;
-    while(i<DELAY) {
-        if(signal.read() != 0) {
-            detected = true;
-        }
-        wait_us(100);
-    }
-    return detected;
-}
-
 void manchester::isTimedOut()
 {
     notTimedOut = false;
 }
 
-void manchester::printetwuk()
+bool manchester::getStopCode(int* data)
 {
-    pc.printf("test ng e ki\r\n");
+    bool code= true;
+    int test[] = {0,0,0,0,0,0,0,0,0,1};
+    for(int i = 6; i < 10; i++){
+        if(data[i]==test[i]){
+            code = true;
+        }
+        else{
+            code = false;
+            break;
+        }
+    }    
+    return code;
 }
\ No newline at end of file