alarm with reset

Dependencies:   RTC-DS1307 mbed

Committer:
Owenmatthewmcgowan
Date:
Tue May 23 12:48:09 2017 +0000
Revision:
0:72a2484d36f7
Child:
1:bd4c4722c453
1223

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Owenmatthewmcgowan 0:72a2484d36f7 1 #include "mbed.h"
Owenmatthewmcgowan 0:72a2484d36f7 2 #include "Rtc_Ds1307.h"
Owenmatthewmcgowan 0:72a2484d36f7 3 Rtc_Ds1307 rtc(A4,A5)
Owenmatthewmcgowan 0:72a2484d36f7 4 PwmOut buzzer(PTC9) ;
Owenmatthewmcgowan 0:72a2484d36f7 5 DigitalOut gnd(PTC11) ;
Owenmatthewmcgowan 0:72a2484d36f7 6
Owenmatthewmcgowan 0:72a2484d36f7 7
Owenmatthewmcgowan 0:72a2484d36f7 8 Rtc_Ds1307::Time_rtc tm = ();
Owenmatthewmcgowan 0:72a2484d36f7 9 Rtc_Ds1307::Time_rtc A_tm = ();
Owenmatthewmcgowan 0:72a2484d36f7 10
Owenmatthewmcgowan 0:72a2484d36f7 11 bool f_reset
Owenmatthewmcgowan 0:72a2484d36f7 12 bool f_alarm
Owenmatthewmcgowan 0:72a2484d36f7 13 void setalarm(int min, hour)
Owenmatthewmcgowan 0:72a2484d36f7 14 void checktime(int min, hour)
Owenmatthewmcgowan 0:72a2484d36f7 15
Owenmatthewmcgowan 0:72a2484d36f7 16 //int alarm_on() {
Owenmatthewmcgowan 0:72a2484d36f7 17 // gnd = 0;
Owenmatthewmcgowan 0:72a2484d36f7 18 // buzzer.period(0.1);
Owenmatthewmcgowan 0:72a2484d36f7 19 // buzzer.write(.75);
Owenmatthewmcgowan 0:72a2484d36f7 20 // while(1) {}
Owenmatthewmcgowan 0:72a2484d36f7 21 //}
Owenmatthewmcgowan 0:72a2484d36f7 22
Owenmatthewmcgowan 0:72a2484d36f7 23 void setalarm(int min, int hour){
Owenmatthewmcgowan 0:72a2484d36f7 24 &A_tm.min = min ;
Owenmatthewmcgowan 0:72a2484d36f7 25 &A_tm.hour = hour;
Owenmatthewmcgowan 0:72a2484d36f7 26 }
Owenmatthewmcgowan 0:72a2484d36f7 27
Owenmatthewmcgowan 0:72a2484d36f7 28
Owenmatthewmcgowan 0:72a2484d36f7 29 //void alarmoff (){
Owenmatthewmcgowan 0:72a2484d36f7 30 // gnd=0;
Owenmatthewmcgowan 0:72a2484d36f7 31 // buzzer.period(0);
Owenmatthewmcgowan 0:72a2484d36f7 32 // buzzer.write(0);
Owenmatthewmcgowan 0:72a2484d36f7 33 //}
Owenmatthewmcgowan 0:72a2484d36f7 34
Owenmatthewmcgowan 0:72a2484d36f7 35
Owenmatthewmcgowan 0:72a2484d36f7 36 void alarmon (){
Owenmatthewmcgowan 0:72a2484d36f7 37 gnd = 0;
Owenmatthewmcgowan 0:72a2484d36f7 38 buzzer.period(0.1);
Owenmatthewmcgowan 0:72a2484d36f7 39 buzzer.write(.75);
Owenmatthewmcgowan 0:72a2484d36f7 40 }
Owenmatthewmcgowan 0:72a2484d36f7 41
Owenmatthewmcgowan 0:72a2484d36f7 42 void checktime(int min, int hour){
Owenmatthewmcgowan 0:72a2484d36f7 43 if (&A_tm.hour == &tm.hour) && ( &A_tm.min == &tm.min ){
Owenmatthewmcgowan 0:72a2484d36f7 44 if (f_alarm) {
Owenmatthewmcgowan 0:72a2484d36f7 45 alarm_on()
Owenmatthewmcgowan 0:72a2484d36f7 46 }
Owenmatthewmcgowan 0:72a2484d36f7 47 }
Owenmatthewmcgowan 0:72a2484d36f7 48 }
Owenmatthewmcgowan 0:72a2484d36f7 49
Owenmatthewmcgowan 0:72a2484d36f7 50
Owenmatthewmcgowan 0:72a2484d36f7 51 //void checkreset() {
Owenmatthewmcgowan 0:72a2484d36f7 52 // if (f_reset) {
Owenmatthewmcgowan 0:72a2484d36f7 53 // alarm_off()
Owenmatthewmcgowan 0:72a2484d36f7 54 // }
Owenmatthewmcgowan 0:72a2484d36f7 55 //}