udpated n,e,s modeswitch

Dependencies:   TextLCD mbed-rtos mbed

Fork of pacemaker_v5 by Pacemaker

Revision:
2:4ce21a8fc0d5
Parent:
1:ea01c3232c4a
Child:
3:39870b37d0c4
--- a/main.cpp	Wed Dec 03 22:38:41 2014 +0000
+++ b/main.cpp	Wed Dec 03 23:28:06 2014 +0000
@@ -80,8 +80,8 @@
 // functions
 void VP_func(void const *args);
 void AP_func(void const *args);
-void VS_func(void const *args);
-void AS_func(void const *args);
+//void VS_func(void const *args);
+//void AS_func(void const *args);
 void manage_flags(void const *i);
 void send_Apace();
 void send_Vpace();
@@ -119,8 +119,8 @@
     
     // init threads
     disp_thread = new Thread(disp);
-    VS_thread = new Thread(VS_func);
-    AS_thread = new Thread(AS_func);
+//    VS_thread = new Thread(VS_func);
+//    AS_thread = new Thread(AS_func);
     VP_thread = new Thread(VP_func);
     AP_thread = new Thread(AP_func);
     VG_thread = new Thread(listen_Vget);
@@ -202,7 +202,7 @@
         t_mutex.unlock();
     }
 }
-
+/*
 void AS_func(void const *args) {
     while (1) {
         Thread::signal_wait(RUN,osWaitForever);
@@ -211,8 +211,8 @@
         flashLED(4);
         t_mutex.unlock();
     }
-}
-
+}*/
+/*
 void VS_func(void const *args) {
     while (1) {
         Thread::signal_wait(RUN,osWaitForever);
@@ -222,13 +222,18 @@
         t_mutex.unlock();
     }
 }
-
+*/
 void listen_Vget(void const *args) {
     while (1) {
         if (VGet==1) {
             status_mutex.lock();
-            if (!isVRP && waitingForV) VS_thread->signal_set(RUN);
-            status_mutex.unlock();
+            if (!isVRP && waitingForV){
+                t_mutex.lock();
+                blind();
+                flashLED(3);
+                t_mutex.unlock();
+                status_mutex.unlock();
+            }
             while(VGet == 1);
         }
     }
@@ -238,7 +243,17 @@
     while (1) {
         if (AGet == 1) {
             status_mutex.lock();
-            if (!isPVARP && !waitingForV) AS_thread->signal_set(RUN);
+            if (!isPVARP && !waitingForV) {
+                t_mutex.lock();
+                ta.start();
+                tv.reset();
+                tv.stop();
+                
+                waitingForV = 1;
+
+                t_mutex.unlock();
+                flashLED(4);
+            }
             status_mutex.unlock();
             while(AGet == 1);
         }