Contains the main execution of the clock uses headers to import functions

Dependencies:   RTC-DS1307 SPI_TFT_ILI9341 TFT_fonts mbed tsi_sensor

Fork of TFT_Mikroelectronika_IL9341_sketchpad by Oxford CWM Team

Revision:
38:3fe3bafbf0c7
Parent:
32:56f59b79720c
Child:
39:4b70d28cb273
Child:
40:05798eeadd02
--- a/clocklogic.h	Thu May 25 16:01:06 2017 +0000
+++ b/clocklogic.h	Thu May 25 19:54:51 2017 +0000
@@ -48,21 +48,22 @@
     float frequency[]={758, 758, 758, 955, 758, 638, 1276, 955, 1276, 1517, 1136, 1012, 1073, 1136, 1276, 758, 638, 568, 716, 638, 758, 955, 851, 1012, 955};
     //frequency array
     float beat[]={0.2, 0.4, 0.4, 0.2, 0.4, 0.8, 0.8, 0.6, 0.6, 0.6, 0.4, 0.4, 0.2, 0.4, 0.26, 0.26, 0.26, 0.4, 0.2, 0.4, 0.4, 0.2, 0.2, 0.2, 0.4};
-    int i =0
+    int i =0;
+    int last = 0;
     draw_state(1);
     while (f_state == 1){
         read_time();
-        TFT.set_font((unsigned char*) Arial24x23); //set alarm hour
+        TFT.set_font((unsigned char*) Arial24x23); //coverup
         if (tm_c.sec == 0){
             TFT.locate(250,40);
             TFT.printf("  ");
             if (tm_c.min == 0){
                 TFT.locate(160,40);
-                printf("%d",tm_c.min);
+                printf("  ");
                 if (tm_c.hour == 0)
                 {
                     TFT.locate(70,40);
-                    printf("%d",tm_c.hour);
+                    printf("  ");
                 }
             }
         }
@@ -70,8 +71,8 @@
                 if(f_alarm && tm_c.hour == tm_a_hr && tm_c.min == tm_a_min && tm_c.sec < 3){
                     f_alarm_sound = true;
                 }
+                
       
-//int gnd = 0 ;
                 if (f_alarm_sound)
                 {
                     i = i % 26;
@@ -81,7 +82,7 @@
                     wait(0.1*beat[i]);
                 //
                 //hold for beat period ;
-                }    
+                } else buzzer = 0;
         TFT.locate(70,40);
         TFT.printf("%d",tm_c.hour);
         TFT.locate(160,40);
@@ -90,7 +91,10 @@
         TFT.printf("%d",tm_c.sec);
         TFT.locate(60,140);
         TFT.set_font((unsigned char*) Arial12x12);
-        TFT.printf("%s",tm_c.wday);
+        if (last != tm_c.wday) printf("        ");
+        last = tm_c.wday;
+        TFT.locate(60,140);
+        TFT.printf("%s",rtc.weekdayToString(tm_c.wday + 1));
         TFT.set_font((unsigned char*) Arial24x23);
         if (f_alarm) {
             TFT.locate(160,140);
@@ -115,7 +119,7 @@
         
         switch (digital_clock_press()){
             case (-1): break;
-            case (0): f_state = 0; break;
+            case (0): f_state = 1; break;
             case (1): f_state = 2; break;
             case (2): f_state = 3; break;
             case (3): f_state = 4; break;