alarm with reset
Dependencies: RTC-DS1307 mbed
Revision 1:bd4c4722c453, committed 2017-05-23
- Comitter:
- Owenmatthewmcgowan
- Date:
- Tue May 23 14:14:49 2017 +0000
- Parent:
- 0:72a2484d36f7
- Commit message:
- 156
Changed in this revision
debug.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 72a2484d36f7 -r bd4c4722c453 debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debug.h Tue May 23 14:14:49 2017 +0000 @@ -0,0 +1,16 @@ +#ifndef __DEBUG_H__ +#define __DEBUG_H__ + + +#ifdef DEBUG +#define INFO(x, ...) std::printf("[INFO: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__); +#define WARN(x, ...) std::printf("[WARN: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__); +#define ERR(x, ...) std::printf("[ERR: %s:%d]"x"\r\n", __FILE__, __LINE__, ##__VA_ARGS__); +#else +#define INFO(x, ...) +#define WARN(x, ...) +#define ERR(x, ...) +#endif + + +#endif \ No newline at end of file
diff -r 72a2484d36f7 -r bd4c4722c453 main.cpp --- a/main.cpp Tue May 23 12:48:09 2017 +0000 +++ b/main.cpp Tue May 23 14:14:49 2017 +0000 @@ -1,42 +1,37 @@ #include "mbed.h" #include "Rtc_Ds1307.h" -Rtc_Ds1307 rtc(A4,A5) -PwmOut buzzer(PTC9) ; -DigitalOut gnd(PTC11) ; - +Rtc_Ds1307 rtc(A4,A5); +DigitalOut buzzer(PTC9); +DigitalOut gnd(PTC11); Rtc_Ds1307::Time_rtc tm = (); Rtc_Ds1307::Time_rtc A_tm = (); -bool f_reset -bool f_alarm -void setalarm(int min, hour) -void checktime(int min, hour) - -//int alarm_on() { - // gnd = 0; - // buzzer.period(0.1); - // buzzer.write(.75); - // while(1) {} -//} +bool f_reset ; +bool f_alarm ; +void setalarm(int min, int hour); +void checktime(int min, int hour); void setalarm(int min, int hour){ - &A_tm.min = min ; - &A_tm.hour = hour; - } + &A_tm.min = min + &A_tm.hour = hour + ; } -//void alarmoff (){ - // gnd=0; +void alarmoff (){ + gnd=0; // buzzer.period(0); // buzzer.write(0); -//} + buzzer = 0; +} void alarmon (){ gnd = 0; - buzzer.period(0.1); - buzzer.write(.75); + // buzzer.period(0.1); + // buzzer.write(.75); + buzzer = 1 ; + } void checktime(int min, int hour){ @@ -45,11 +40,11 @@ alarm_on() } } -} +;} -//void checkreset() { - // if (f_reset) { - // alarm_off() - // } -//} +void checkreset() { + if (f_reset) { + alarm_off() + } +} \ No newline at end of file