![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
my programm rtc_class with functions in Date.cpp
Fork of rtc_func by
main.cpp@2:ce174a86d215, 2015-04-23 (annotated)
- Committer:
- KagerJ
- Date:
- Thu Apr 23 09:42:34 2015 +0000
- Revision:
- 2:ce174a86d215
- Parent:
- 1:554eb6675279
- Child:
- 3:75f5352b387d
added GetWeek() GetDays() GetMonths() GetYears()
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 | 2:ce174a86d215 | 6 | |
bulmecisco | 0:32ae5fd83722 | 7 | Serial pc(USBTX, USBRX); |
KagerJ | 2:ce174a86d215 | 8 | //I2C i2c(p28, p27); |
KagerJ | 2:ce174a86d215 | 9 | |
KagerJ | 2:ce174a86d215 | 10 | uint8_t year, month, day, week; |
KagerJ | 2:ce174a86d215 | 11 | uint8_t hour, minute, sec; |
bulmecisco | 0:32ae5fd83722 | 12 | char week_chr[7][4] = {"MON","TUE","WED","THU","FRI","SAT","SUN"}; |
KagerJ | 2:ce174a86d215 | 13 | |
bulmecisco | 0:32ae5fd83722 | 14 | int main() |
bulmecisco | 0:32ae5fd83722 | 15 | { |
KagerJ | 2:ce174a86d215 | 16 | Date rtc; // instanziieren des Objektes rtc |
KagerJ | 2:ce174a86d215 | 17 | |
KagerJ | 2:ce174a86d215 | 18 | pc.printf("Setting up RTC\n"); |
KagerJ | 2:ce174a86d215 | 19 | //rtc.rtc_init(); |
KagerJ | 2:ce174a86d215 | 20 | |
bulmecisco | 0:32ae5fd83722 | 21 | while(1) { |
KagerJ | 2:ce174a86d215 | 22 | //printTime(); |
KagerJ | 2:ce174a86d215 | 23 | pc.printf(" %i %i . %i . %i.", week_chr[rtc.GetWeek()], rtc.GetDay(), rtc.GetMonth(), rtc.GetYear()); |
KagerJ | 2:ce174a86d215 | 24 | year = rtc.rtc_read(YEARS); // Aufruf der Methode rtc_read der Instanz (Objekt) rtc |
KagerJ | 2:ce174a86d215 | 25 | month = rtc.rtc_read(MONTHS); |
KagerJ | 2:ce174a86d215 | 26 | day = rtc.rtc_read(DAYS); |
KagerJ | 2:ce174a86d215 | 27 | week = rtc.rtc_read(WEEKDAYS); |
KagerJ | 2:ce174a86d215 | 28 | hour = rtc.rtc_read(HOURS); |
KagerJ | 2:ce174a86d215 | 29 | minute = rtc.rtc_read(MINUTES); |
KagerJ | 2:ce174a86d215 | 30 | sec = rtc.rtc_read(SECONDS); |
KagerJ | 2:ce174a86d215 | 31 | |
KagerJ | 2:ce174a86d215 | 32 | //Datum Ausgabe |
KagerJ | 2:ce174a86d215 | 33 | pc.printf("20%x%x/%x%x/%x%x %s\n", |
KagerJ | 2:ce174a86d215 | 34 | ((year >> 4) & 0x03) , (year & 0x0F) , |
KagerJ | 2:ce174a86d215 | 35 | ((month >> 4) & 0x01), (month & 0x0F) , |
KagerJ | 2:ce174a86d215 | 36 | ((day >> 4) & 0x03), (day & 0x0F) , |
KagerJ | 2:ce174a86d215 | 37 | week_chr[week & 0x07]); |
KagerJ | 2:ce174a86d215 | 38 | |
KagerJ | 2:ce174a86d215 | 39 | //Zeit Ausgabe |
KagerJ | 2:ce174a86d215 | 40 | pc.printf("%x%x:%x%x:%x%x\n", |
KagerJ | 2:ce174a86d215 | 41 | ((hour >> 4) & 0x03), (hour & 0x0F), |
KagerJ | 2:ce174a86d215 | 42 | (minute >> 4), (minute & 0x0F) , |
KagerJ | 2:ce174a86d215 | 43 | (sec >> 4), (sec & 0x0F) ); |
bulmecisco | 0:32ae5fd83722 | 44 | wait(1); |
bulmecisco | 0:32ae5fd83722 | 45 | } |
KagerJ | 2:ce174a86d215 | 46 | } |