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