Clear All Beeper To The Wall

Dependencies:   mbed ur_Bertl

Revision:
1:fe621d794c6c
Parent:
0:407bebd23b26
Child:
2:9795f864acac
--- a/uebungen.cpp	Thu Apr 23 12:39:37 2015 +0000
+++ b/uebungen.cpp	Fri Apr 24 09:17:13 2015 +0000
@@ -1,18 +1,82 @@
 #include "uebungen.h"
 #include "mbed.h"
+#include "const.h"
 
 void Task_Bertl :: ClearAllBeeperToTheWall()
 {
     int i = 0;
-    while (!NextToABeeper() || FrontIsClear())
-    {
+    while (!NextToABeeper() || FrontIsClear()) {
         Move();
-        
-        if(NextToABeeper())
-        {
+
+        if(NextToABeeper()) {
             i ++;
             PickBeeper();
             NibbleLeds(i);
         }
     }
+}
+
+void Task_Bertl :: LedAmpel()
+{
+    srand(time(0));
+    
+    int b = 0;
+    
+    while(1) 
+    {
+        //if(!IsButtonPressed(BTN_FM)) 
+        //{
+            NibbleLeds(0xF8);
+            wait(1);
+            NibbleLeds(0xFE);
+            wait(1);
+            NibbleLeds(0xF1);
+            //wait(1);
+
+            if (b == 1)
+            {
+                wait(5);
+            }
+
+            int y = (rand() % 6) +5;
+            
+            if(b == 0)
+            {
+                for(int i = 0; i < y; i++) 
+                {
+                    Move();
+                    if (IsButtonPressed(BTN_FM))
+                    {
+                        b = 1;
+                        ShutOff();
+                        break;
+                    }
+                }
+            }
+            
+            
+            
+            //if(!IsButtonPressed(BTN_FM))
+            //{
+                for(int j = 0; j < 4; j++)
+                {
+                    NibbleLeds(0xF1);
+                    wait_ms(500);
+                    NibbleLeds(0xF0);
+                    wait_ms(500);
+                }
+                
+                NibbleLeds(0xF6);
+                wait_ms(500);
+                NibbleLeds(0xF0);
+                wait_ms(500);
+                NibbleLeds(0xF8);
+            //}
+            //else
+            //{
+            //    ShutOff();
+            //    break;
+            //}
+        //}
+    }
 }
\ No newline at end of file