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:
39:4b70d28cb273
Parent:
38:3fe3bafbf0c7
Child:
41:3f2e75e7fbeb
diff -r 3fe3bafbf0c7 -r 4b70d28cb273 clocklogic.h
--- a/clocklogic.h	Thu May 25 19:54:51 2017 +0000
+++ b/clocklogic.h	Fri May 26 08:28:27 2017 +0000
@@ -1,6 +1,6 @@
 int digital_clock_press(){
-    int x = readX();
-    int y = readY();
+    int x = readX(); // read x location 
+    int y = readY(); // read y location
     if (touching == 1) {
        
         if (x > 0 && x < 50 && y > 0 & y < 50) // side button 1 (clock state)
@@ -31,7 +31,7 @@
         {
             //set desired state to 5
             f_alarm = !(f_alarm);
-            f_alarm_sound = false;
+            f_alarm_sound = false;  // flag for the alarm sound
             return -1;
         }
     }
@@ -41,26 +41,27 @@
     
 
 
-void runclock()
+void runclock() // getting time from the clock
 {
-    DigitalOut gnd(PTA4) ;
+    DigitalOut gnd(PTA4) ; // initiating buzzer
     PwmOut buzzer(PTA5);
     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};
+    //time intervals
     int i =0;
     int last = 0;
     draw_state(1);
     while (f_state == 1){
         read_time();
         TFT.set_font((unsigned char*) Arial24x23); //coverup
-        if (tm_c.sec == 0){
+        if (tm_c.sec == 0){      //getting seconds and printing
             TFT.locate(250,40);
             TFT.printf("  ");
-            if (tm_c.min == 0){
+            if (tm_c.min == 0){  //getting minutes and printing
                 TFT.locate(160,40);
                 printf("  ");
-                if (tm_c.hour == 0)
+                if (tm_c.hour == 0)  //getting hours and printing
                 {
                     TFT.locate(70,40);
                     printf("  ");
@@ -69,11 +70,11 @@
         }
             
                 if(f_alarm && tm_c.hour == tm_a_hr && tm_c.min == tm_a_min && tm_c.sec < 3){
-                    f_alarm_sound = true;
+                    f_alarm_sound = true; //alarm buzzes
                 }
                 
       
-                if (f_alarm_sound)
+                if (f_alarm_sound) 
                 {
                     i = i % 26;
                     i++ ;