Rtc class

Dependencies:   RTC8563 mbed

Fork of rtc_class by HIMBED_3AHELI

Files at this revision

API Documentation at this revision

Comitter:
Andi104
Date:
Thu Apr 30 10:48:30 2015 +0000
Parent:
5:fc8c66a7c87a
Commit message:
RTC Class

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
DateString.cpp Show annotated file Show diff for this revision Revisions of this file
DateString.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 fc8c66a7c87a -r a52551f2f398 Date.cpp
--- a/Date.cpp	Thu Apr 23 09:02:20 2015 +0000
+++ b/Date.cpp	Thu Apr 30 10:48:30 2015 +0000
@@ -35,4 +35,12 @@
 {
     uint8_t day = rtc_read(DAYS);
     return bcdToUint(day & 0x3F);
-}
\ No newline at end of file
+}
+uint8_t Date::GetDay(int value)
+{return value;}
+
+string Date::GetDay(string str)
+{
+    string day = str + " In Date Day: " + toString(GetDay());
+    return day;
+    }
\ No newline at end of file
diff -r fc8c66a7c87a -r a52551f2f398 Date.h
--- a/Date.h	Thu Apr 23 09:02:20 2015 +0000
+++ b/Date.h	Thu Apr 30 10:48:30 2015 +0000
@@ -29,6 +29,6 @@
     Date()  // Standard Konstruktor
     {
     }   
-    uint8_t GetDay();   // Methode
+    virtual string GetDay();   // Methode
 };
 #endif
\ No newline at end of file
diff -r fc8c66a7c87a -r a52551f2f398 DateString.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DateString.cpp	Thu Apr 30 10:48:30 2015 +0000
@@ -0,0 +1,25 @@
+#include "DateString.h"
+#include "RTC8563.h"
+// 2. Methode überschreiben
+uint8_t DateString::GetDay()
+{
+    //uint8_t day = rtc_read(DAYS);
+    //return bcdToUint(day & 0x3F);
+    uint8_t day = Date::GetDay(); //Aufruf der GetDay-Methode aus basisklasse Date mit Scope-Op
+    //3. Erweitern von Methoden der Basisklasse
+    day = day -5;
+    return day;
+}
+
+uint8_t DateString::GetNextDay()
+{
+    uint8_t day = GetDay();
+    return ++day;
+}
+
+string DateString::GetDay(string str)
+{
+    string day = str + " In Date Day: " + toString(GetDay());
+    return day;
+}
+
diff -r fc8c66a7c87a -r a52551f2f398 DateString.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DateString.h	Thu Apr 30 10:48:30 2015 +0000
@@ -0,0 +1,18 @@
+// DateString.h
+#include "mbed.h"
+#include "const.h"
+#include "Date.h"
+#include "string"
+
+#ifndef DATESTRING_H
+#define DATESTRING_H
+class DateString : public Date // DateString abgeleitet von Date
+{
+public:
+    uint8_t GetDay();   // 2. Methode überschreiben
+    uint8_t GetNextDay();
+    using Date::GetDay();
+    string GetDay(string str);
+
+};
+#endif
\ No newline at end of file
diff -r fc8c66a7c87a -r a52551f2f398 main.cpp
--- a/main.cpp	Thu Apr 23 09:02:20 2015 +0000
+++ b/main.cpp	Thu Apr 30 10:48:30 2015 +0000
@@ -15,6 +15,7 @@
 #include "RTC8563.h"
 #include "string"
 #include "Date.h"
+#include "DateString.h"
  
 Serial pc(USBTX, USBRX);
  
@@ -22,10 +23,17 @@
 
 int main()
 {
-    Date rtc;  // instanziieren des Objektes rtc
+    Date *pBoth;    
+    DateString ds;  // instanziieren des Objektes ds
+    Date d;         //Instanziieren des Objektes d
+    pBoth = &d;      //
  
     while(1) {
-        pc.printf("Date.Day: %i\n", rtc.GetDay());
+        //pc.printf("DateString.Day: %i\n", pBoth->GetDay());
+        pBoth = &d
+        pc.printf("Ueberladen GetDay: %s\n",pBoth->GetDay("Where am I?"));
+        pBoth = &ds;
+        pc.printf("Ueberladen GetDay: %s\n",pBoth->GetDay("Where am I?"));
         wait(1);
     }
 }
\ No newline at end of file