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

Files at this revision

API Documentation at this revision

Comitter:
mlin
Date:
Fri May 26 08:45:43 2017 +0000
Parent:
45:d8091d711d9c
Parent:
44:1c516642c34e
Child:
48:76ac309a2bd9
Commit message:
pont init

Changed in this revision

--- a/analoglogic.h	Fri May 26 08:44:21 2017 +0000
+++ b/analoglogic.h	Fri May 26 08:45:43 2017 +0000
@@ -1,8 +1,10 @@
 int ana_clock_press(){
     int x = readX();
     int y = readY();
+        //setting x,y variables from TFT input
     if (touching == 1) {
        
+       
         if (x > 0 && x < 50 && y > 0 & y < 50) // side button 1 (clock state)
         {
             //set desired state to 1 
@@ -39,7 +41,7 @@
     }
     return -1;
 }
-        
+    //Testing where screen has been pushed using TFT input and setting state accordingly
     
 
 
@@ -47,9 +49,11 @@
 {
     DigitalOut gnd(PTA4) ;
     PwmOut buzzer(PTA5);
+    //setting low/high pins across buzzer at PWM output
     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};
+    //pulse duration array
     int i =0;
     int last_h  = 0;
     int last_m = 0;
@@ -61,6 +65,7 @@
         if(f_alarm && tm_c.hour == tm_a_hr && tm_c.min == tm_a_min && tm_c.sec < 3){
             f_alarm_sound = true;
         }
+        //if testing for both alarm flag and checking current time against alarm to flag the alarm sound
                 
         if (last_h != tm_c.hour && last_m != tm_c.min){
             draw_hands( 150, 100 , 90 , last_m , last_h ,Black) ;
@@ -77,8 +82,7 @@
                 buzzer.period(1/(frequency[i])); // set PWM period
                 buzzer=0.5;
                 wait(0.1*beat[i]);
-            //
-            //hold for beat period ;
+            //hold for 0.1*beat period
             } else buzzer = 0;
         TFT.set_orientation(0);
         TFT.set_font((unsigned char*) Arial24x23);
--- a/buzzer.h	Fri May 26 08:44:21 2017 +0000
+++ b/buzzer.h	Fri May 26 08:45:43 2017 +0000
@@ -3,34 +3,33 @@
 DigitalOut gnd(PTA4)
 gnd = 0;
 PwmOut
-buzzer(PTA5);
-float frequency[]={659,554,659,554,550,494,554,587,494,659,554,440};
-//frequency array
-float beat[]={1,1,1,1,1,0.5,0.5,1,1,1,1,2};
-//beat array
-int
-main() {
-while (1) {
-for (
-int
-i
-=0;
-i
-<=11;
-i
-++) {
-buzzer.period
-(1/(frequency[
-i
-])); // set PWM period
-buzzer=0.5;
-//
-set duty cycle
-wait(0.5*beat[
-i
-]);
-//
-hold for beat period
-}
-}
+    buzzer(PTA5);
+            float frequency[]={659,554,659,554,550,494,554,587,494,659,554,440};
+            //frequency array
+            float beat[]={1,1,1,1,1,0.5,0.5,1,1,1,1,2};
+            //beat array
+    int
+    main() {
+    while (1) {
+    for (
+        int
+        i
+        =0;
+        i
+        <=11;
+        i
+        ++) {
+            buzzer.period
+            (1/(frequency[
+            i
+            ])); 
+            // set PWM period
+                buzzer=0.5;
+                set duty cycle
+                wait(0.5*beat[
+                i
+                ]);
+                hold for beat period
+                }
+        }
 }
\ No newline at end of file