Josef Kager
/
rtc_class2
added GetDay() GetYear() GetWeek()
Fork of rtc_class by
main.cpp@3:75f5352b387d, 2015-04-30 (annotated)
- Committer:
- KagerJ
- Date:
- Thu Apr 30 10:53:00 2015 +0000
- Revision:
- 3:75f5352b387d
- Parent:
- 2:ce174a86d215
added GetDay() GetYear() GetWeek()
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bulmecisco | 0:32ae5fd83722 | 1 | #include "mbed.h" |
KagerJ | 2:ce174a86d215 | 2 | #include "const.h" |
KagerJ | 2:ce174a86d215 | 3 | #include "RTC8563.h" |
KagerJ | 2:ce174a86d215 | 4 | #include "string" |
KagerJ | 2:ce174a86d215 | 5 | #include "Date.h" |
KagerJ | 3:75f5352b387d | 6 | #include "DateString.h" |
KagerJ | 2:ce174a86d215 | 7 | |
bulmecisco | 0:32ae5fd83722 | 8 | Serial pc(USBTX, USBRX); |
KagerJ | 2:ce174a86d215 | 9 | //I2C i2c(p28, p27); |
KagerJ | 2:ce174a86d215 | 10 | |
KagerJ | 2:ce174a86d215 | 11 | uint8_t year, month, day, week; |
KagerJ | 2:ce174a86d215 | 12 | uint8_t hour, minute, sec; |
bulmecisco | 0:32ae5fd83722 | 13 | char week_chr[7][4] = {"MON","TUE","WED","THU","FRI","SAT","SUN"}; |
KagerJ | 2:ce174a86d215 | 14 | |
bulmecisco | 0:32ae5fd83722 | 15 | int main() |
bulmecisco | 0:32ae5fd83722 | 16 | { |
KagerJ | 2:ce174a86d215 | 17 | Date rtc; // instanziieren des Objektes rtc |
KagerJ | 2:ce174a86d215 | 18 | |
KagerJ | 2:ce174a86d215 | 19 | pc.printf("Setting up RTC\n"); |
KagerJ | 2:ce174a86d215 | 20 | //rtc.rtc_init(); |
KagerJ | 2:ce174a86d215 | 21 | |
bulmecisco | 0:32ae5fd83722 | 22 | while(1) { |
KagerJ | 2:ce174a86d215 | 23 | //printTime(); |
KagerJ | 2:ce174a86d215 | 24 | pc.printf(" %i %i . %i . %i.", week_chr[rtc.GetWeek()], rtc.GetDay(), rtc.GetMonth(), rtc.GetYear()); |
KagerJ | 2:ce174a86d215 | 25 | year = rtc.rtc_read(YEARS); // Aufruf der Methode rtc_read der Instanz (Objekt) rtc |
KagerJ | 2:ce174a86d215 | 26 | month = rtc.rtc_read(MONTHS); |
KagerJ | 2:ce174a86d215 | 27 | day = rtc.rtc_read(DAYS); |
KagerJ | 2:ce174a86d215 | 28 | week = rtc.rtc_read(WEEKDAYS); |
KagerJ | 2:ce174a86d215 | 29 | hour = rtc.rtc_read(HOURS); |
KagerJ | 2:ce174a86d215 | 30 | minute = rtc.rtc_read(MINUTES); |
KagerJ | 2:ce174a86d215 | 31 | sec = rtc.rtc_read(SECONDS); |
KagerJ | 2:ce174a86d215 | 32 | |
KagerJ | 2:ce174a86d215 | 33 | //Datum Ausgabe |
KagerJ | 2:ce174a86d215 | 34 | pc.printf("20%x%x/%x%x/%x%x %s\n", |
KagerJ | 2:ce174a86d215 | 35 | ((year >> 4) & 0x03) , (year & 0x0F) , |
KagerJ | 2:ce174a86d215 | 36 | ((month >> 4) & 0x01), (month & 0x0F) , |
KagerJ | 2:ce174a86d215 | 37 | ((day >> 4) & 0x03), (day & 0x0F) , |
KagerJ | 2:ce174a86d215 | 38 | week_chr[week & 0x07]); |
KagerJ | 2:ce174a86d215 | 39 | |
KagerJ | 2:ce174a86d215 | 40 | //Zeit Ausgabe |
KagerJ | 2:ce174a86d215 | 41 | pc.printf("%x%x:%x%x:%x%x\n", |
KagerJ | 2:ce174a86d215 | 42 | ((hour >> 4) & 0x03), (hour & 0x0F), |
KagerJ | 2:ce174a86d215 | 43 | (minute >> 4), (minute & 0x0F) , |
KagerJ | 2:ce174a86d215 | 44 | (sec >> 4), (sec & 0x0F) ); |
bulmecisco | 0:32ae5fd83722 | 45 | wait(1); |
bulmecisco | 0:32ae5fd83722 | 46 | } |
KagerJ | 2:ce174a86d215 | 47 | } |