Multi-Function Clock

Dependencies:   Clock DHT22 DigitDisplay mbed my8x8RGB

Files at this revision

API Documentation at this revision

Comitter:
mmoodevil
Date:
Tue Dec 08 20:56:58 2015 +0000
Parent:
0:1ef228e02562
Commit message:
Final

Changed in this revision

Clock.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
my8x8RGB.lib Show annotated file Show diff for this revision Revisions of this file
--- a/Clock.lib	Mon Dec 07 11:24:49 2015 +0000
+++ b/Clock.lib	Tue Dec 08 20:56:58 2015 +0000
@@ -1,1 +1,1 @@
-Clock#47ccd6ffe435
+https://developer.mbed.org/users/mmoodevil/code/Clock/#47ccd6ffe435
--- a/main.cpp	Mon Dec 07 11:24:49 2015 +0000
+++ b/main.cpp	Tue Dec 08 20:56:58 2015 +0000
@@ -59,6 +59,7 @@
 #define enemy_size3 20
 #define bullet_speed 50
 #define btn_delay 0.02
+#define mooBTN 0.1
 uint8_t player_location=1; // in Colum
 bullet mybullet[10];
 enemy wave1[enemy_size1];
@@ -101,7 +102,7 @@
 InterruptIn KS(PB_2);  // Change mode
 DigitalOut Beep(PC_5); // Buzzer
 int M=0,H=0,N=0,I=0;  // Cache Alarm
-int SetH = 0 , SetM = 0; // Cache Alarm
+int SetH = 99 , SetM = 0; // Cache Alarm
 int mode=3; // Init Mode = 0 (Default) 
 int flag = 0; // Init Flag for Alarm
 int temperature; //Init for Memmory Temp
@@ -119,18 +120,18 @@
         return 0;        
 }
 
-void sent() // Set time
+void sentoo() // Set time
 {
-    wait(0.3);
+    //wait(0.3);
     SetM = (N*10) + M ;
     SetH = (I*10) + H ;
     //alarmset(SetH,int SetM)
     printf("%d:%d",SetH,SetM);
 }
 
-void minU(){
+void minUoo(){
     M++;
-    wait(0.3);
+   // wait(0.3);
     if(M>9 && N<5){
     M = 0;
     N++;
@@ -142,9 +143,9 @@
     }
 }
 
-void hoursU(){
+void hoursUoo(){
     H++;
-    wait(0.3);
+  //  wait(0.3);
     if(H>9 && I<2){
     H = 0;
     I++;
@@ -156,17 +157,45 @@
     }
 }
 
-void modep(){
-    wait(0.5);
+void modepoo(){
+   // wait(0.5);
     screen_off();
     mode++;
+    printf("%d\n",mode);
+    if(mode==3){
+        newSetting();
+        gameLevel=1;
+        genarate_enemy(wave1,enemy_size1,t_ms_easy);
+        
+        }
     if(mode == 4)
     { mode = 0 ;}
-    wait(0.5);
+  //  wait(0.5);
     
 }
 
+void sent(){
+    w8.attach(&sentoo,mooBTN);
+    }
+    void minU(){
+    w8.attach(&minUoo,mooBTN);
+    }
+    void hoursU(){
+    w8.attach(&hoursUoo,mooBTN);
+    }
+    void modep(){
+    w8.attach(&modepoo,mooBTN);
+    }
+
+void aalm(){
+    Beep=1;
+    }
+void aalm_off(){
+    Beep=0;
+    }
+
 int main(){
+    //Clk.settime2bcd(0,19,01,0,0,0,0);
     KS.rise(&modep);
     K1.rise(&minU);
     K2.rise(&hoursU);
@@ -178,18 +207,17 @@
         Clk.displays();
         wait(1);
         flag = alarmset(SetH,SetM);
+        
+        if(flag==1){
+            UpdateScreen.attach(&aalm,0.1);
+            TCK_player.attach(&aalm_off,0.2);
+            newSetting();
+            gameLevel=1;
+            genarate_enemy(wave1,enemy_size1,t_ms_easy);
+            }
+        
         while(flag == 1){
-        flag = alarmset(SetH,SetM);
-        Clk.displays();
-        Beep = 1;
-        wait(0.2);
-        Beep = 0;
-        wait(0.2);
-        Beep = 1;
-        wait(0.2);
-        Beep = 0;
-        wait(0.5);
-        alarmset(SetH,SetM);
+            TomaToloop();
         }
     }
     
@@ -201,7 +229,7 @@
     }
     while(mode == 2){
      dht.sample();
-     wait(0.5);  
+     wait(0.5);
      temperature = dht.getTemperature();
      temperature = temperature/10;
      Dis.clear();
@@ -380,9 +408,20 @@
     wait_ms(500);
         gameLevel++;
         newSetting();
-        if(gameLevel==2)genarate_enemy(wave2,enemy_size2,t_ms_normal);
+        if(gameLevel==2){
+            genarate_enemy(wave2,enemy_size2,t_ms_normal);
+            }
     if(gameLevel==3)genarate_enemy(wave3,enemy_size2,t_ms_hard);
-    if(gameLevel==4)genarate_enemy_rand(wave4,enemy_size1,t_ms_easy);
+    if(gameLevel==4){
+        genarate_enemy_rand(wave4,enemy_size1,t_ms_easy);
+        flag=0;
+        UpdateScreen.detach();
+        TCK_player.detach();
+        SetH=99;
+        SetM=99;
+        screen_off();
+        createWall();
+        }
     if(gameLevel==5)genarate_enemy_rand(wave5,enemy_size2,t_ms_normal);
     if(gameLevel==6){
         genarate_enemy_rand(wave5,enemy_size3,t_ms_normal);
--- a/my8x8RGB.lib	Mon Dec 07 11:24:49 2015 +0000
+++ b/my8x8RGB.lib	Tue Dec 08 20:56:58 2015 +0000
@@ -1,1 +1,1 @@
-my8x8RGB#c01d67879eb2
+https://developer.mbed.org/users/mmoodevil/code/my8x8RGB/#c01d67879eb2