Functions from rtc_func are programmed in a class

Dependencies:   RTC8563 mbed

Fork of rtc_class by Johannes Mayerhofer

main.cpp

Committer:
Cartillius
Date:
2015-04-30
Revision:
2:254db37497ac
Parent:
1:becf3f1612d4

File content as of revision 2:254db37497ac:

#include "mbed.h"
#include "const.h"
#include "RTC8563.h"
#include "string"
#include "Date.h"
 
Serial pc(USBTX, USBRX);
//I2C i2c(p28, p27);
 
uint8_t year, month, day, week;
uint8_t hour, minute, sec;
char week_chr[7][4] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
 
int main()
{
    Date rtc;  // instanziieren des Objektes rtc
 
    pc.printf("Setting up RTC\n");
    //rtc.rtc_init();
 
    while(1) {
        
        pc.printf("Date: %s 20%02i/%02i/%02i\n", week_chr[rtc.GetWeek()], rtc.GetYear(), rtc.GetMonth(), rtc.GetDay());
        pc.printf("Time: %02i:%02i:%02i\n\n", rtc.GetHour(), rtc.GetMinute(), rtc.GetSecond());
        
        /*
        //printTime();           
        year = rtc.rtc_read(YEARS);   // Aufruf der Methode rtc_read der Instanz (Objekt) rtc
        month = rtc.rtc_read(MONTHS);
        day = rtc.rtc_read(DAYS);
        week = rtc.rtc_read(WEEKDAYS);
        hour = rtc.rtc_read(HOURS);
        minute = rtc.rtc_read(MINUTES);
        sec = rtc.rtc_read(SECONDS);
 
        //Datum Ausgabe
        pc.printf("20%x%x/%x%x/%x%x %s\n",
                  ((year >> 4) & 0x03) , (year & 0x0F) ,
                  ((month >> 4) & 0x01), (month & 0x0F) ,
                  ((day >> 4) & 0x03), (day & 0x0F) ,
                  week_chr[week & 0x07]);
 
        //Zeit Ausgabe
        pc.printf("%x%x:%x%x:%x%x\n",
                  ((hour >> 4) & 0x03), (hour & 0x0F),
                  (minute >> 4), (minute & 0x0F) ,
                  (sec >> 4), (sec & 0x0F) );
        */
        wait(1);
    }
}