RTC Lib & Output

Dependencies:   LM75B RTC8563 mbed

Files at this revision

API Documentation at this revision

Comitter:
EmilMcDuck
Date:
Thu Apr 23 09:37:34 2015 +0000
Parent:
2:101ad0c50fe1
Commit message:
Publish

Changed in this revision

Date.cpp Show annotated file Show diff for this revision Revisions of this file
Date.h Show annotated file Show diff for this revision Revisions of this file
RTC8563.lib 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 101ad0c50fe1 -r 08812f743fea Date.cpp
--- a/Date.cpp	Thu Apr 16 11:24:40 2015 +0000
+++ b/Date.cpp	Thu Apr 23 09:37:34 2015 +0000
@@ -15,6 +15,10 @@
 {
     return read(YEARS);
 }
+uint8_t Date::getWeekday()
+{
+    return read(WEEKDAYS);
+}
 
 // Time
 uint8_t Date::getHours()
diff -r 101ad0c50fe1 -r 08812f743fea Date.h
--- a/Date.h	Thu Apr 16 11:24:40 2015 +0000
+++ b/Date.h	Thu Apr 23 09:37:34 2015 +0000
@@ -14,7 +14,7 @@
     uint8_t getHours();
     uint8_t getMinutes();
     uint8_t getSeconds();
-    //uint8_t getWeekday();
+    uint8_t getWeekday();
 };
 
 #endif  //_DATE_H
diff -r 101ad0c50fe1 -r 08812f743fea RTC8563.lib
--- a/RTC8563.lib	Thu Apr 16 11:24:40 2015 +0000
+++ b/RTC8563.lib	Thu Apr 23 09:37:34 2015 +0000
@@ -1,1 +1,1 @@
-RTC8563#176b32f7baeb
+http://developer.mbed.org/users/EmilMcDuck/code/RTC8563/#5ce9f1860682
diff -r 101ad0c50fe1 -r 08812f743fea main.cpp
--- 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);
     }
 }