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
Diff: clocklogic.h
- Revision:
- 32:56f59b79720c
- Parent:
- 31:3255668e6b08
- Child:
- 38:3fe3bafbf0c7
diff -r 3255668e6b08 -r 56f59b79720c clocklogic.h --- a/clocklogic.h Thu May 25 15:32:20 2017 +0000 +++ b/clocklogic.h Thu May 25 15:43:31 2017 +0000 @@ -31,6 +31,7 @@ { //set desired state to 5 f_alarm = !(f_alarm); + f_alarm_sound = false; return -1; } } @@ -42,6 +43,12 @@ void runclock() { + DigitalOut gnd(PTA4) ; + 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}; + int i =0 draw_state(1); while (f_state == 1){ read_time(); @@ -60,8 +67,21 @@ } } - - + 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; + i++ ; + buzzer.period(1/(frequency[i])); // set PWM period + buzzer=0.5; + wait(0.1*beat[i]); + // + //hold for beat period ; + } TFT.locate(70,40); TFT.printf("%d",tm_c.hour); TFT.locate(160,40);