RTC Lib & Output
Dependencies: LM75B RTC8563 mbed
Diff: main.cpp
- Revision:
- 3:08812f743fea
- Parent:
- 2:101ad0c50fe1
--- a/main.cpp Thu Apr 16 11:24:40 2015 +0000 +++ b/main.cpp Thu Apr 23 09:37:34 2015 +0000 @@ -4,32 +4,24 @@ #include "Date.h" #include "string.h" -char year, month, day, week; -char hour, minute, sec; char day_a, hour_a, minute_a, week_a; char week_chr[7][4] = {"MON","TUE","WED","THU","FRI","SAT","SUN"}; Serial pc(USBTX, USBRX); RTC8563 rtc(p28, p27); +Date date; + int main() { rtc.init(15, 4, 16, 12, 16, 0, 4); // years, months, days, hours, minutes, seconds, weekday (1 == Monday) rtc.alarm(16, 12, 10, 4); // day, hour, min, weekday while(1) { - + // RTC Zeit Ausgabe pc.printf("RTC8563 TIME AND DATE:\n" ); - year = rtc.read(YEARS); - month = rtc.read(MONTHS); - day = rtc.read(DAYS); - week = rtc.read(WEEKDAYS); - hour = rtc.read(HOURS); - minute = rtc.read(MINUTES); - sec = rtc.read(SECONDS); - - pc.printf("%02d.%02d.20%02d %s\n", day, month, year, week_chr[week]); // Date - pc.printf("%02d:%02d:%02d\n", hour, minute, sec); // Time + pc.printf("%02d.%02d.20%02d | %s\n", date.getDay(), date.getMonth(), date.getYear(), week_chr[date.getWeekday()]); // Date + pc.printf("%02d:%02d:%02d\n", date.getHours(), date.getMinutes(), date.getSeconds()); // Time // RTC Alarm day_a = rtc.read(DAY_ALARM); @@ -39,7 +31,8 @@ pc.printf("RTC8563 ALARM:\n" ); pc.printf("DAY: %02dth | %02d:%02d %s\n", day_a, hour_a, minute_a, week_chr[week_a]); // Alarm - + + pc.printf("##############################################\n" ); wait(0.5); } }