Projet_S5 / Mbed 2 deprecated Repo_Noeud_Mobile_refactor

Dependencies:   mbed-rtos mbed

Fork of Repo_Noeud_Mobile by Projet_S5

Revision:
1:601d2922ff06
Child:
3:a77d02cb5694
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CountDown/CountDown.cpp	Wed Mar 04 19:42:35 2015 +0000
@@ -0,0 +1,45 @@
+#include "CountDown.h"
+
+CountDown::CountDown(int time)
+    // initialisation list
+    : t(time>>2) /// division par 4 pour temps entre ch. LED. 
+{
+    led[0] = new DigitalOut(LED1);
+    led[1] = new DigitalOut(LED2);
+    led[2] = new DigitalOut(LED3);
+    led[3] = new DigitalOut(LED4);
+    
+}
+
+CountDown::~CountDown()
+{
+    for(int i(0); i<NBRE_LED; i++){
+        delete led[i];
+    }
+}
+
+bool CountDown::run()
+{
+    int j(NBRE_LED);
+    
+    for(int i(0); i<j ; i++){ // ALL ON. 
+        led[i]->write(1);
+    }
+
+    while(j) // Actual CountDown. 
+    {
+        Thread::wait(t);
+        j--;
+        led[j] = 0;
+    }
+    
+    for(int u(0); u<NBRE_LED; u++) // Flashing State
+    {
+        Thread::wait(100);
+        for(int i(0); i<NBRE_LED ; i++){
+            led[i]->write(u%2);
+        }
+    }
+        
+    return true;
+}
\ No newline at end of file