Dependencies: DigitDisplay PCF8563 mbed
main.cpp@0:aa44e81944cc, 2016-04-01 (annotated)
- Committer:
- ladner
- Date:
- Fri Apr 01 13:15:13 2016 +0000
- Revision:
- 0:aa44e81944cc
Uhr-chip auf Anzeige
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ladner | 0:aa44e81944cc | 1 | #include "mbed.h" |
ladner | 0:aa44e81944cc | 2 | #include "PCF8563.h" |
ladner | 0:aa44e81944cc | 3 | #include "DigitDisplay.h" |
ladner | 0:aa44e81944cc | 4 | |
ladner | 0:aa44e81944cc | 5 | DigitDisplay display(p7, p8); |
ladner | 0:aa44e81944cc | 6 | Serial pc(USBTX, USBRX); |
ladner | 0:aa44e81944cc | 7 | |
ladner | 0:aa44e81944cc | 8 | PCF8563 rtc; |
ladner | 0:aa44e81944cc | 9 | |
ladner | 0:aa44e81944cc | 10 | uint8_t hour, minute, sec; |
ladner | 0:aa44e81944cc | 11 | |
ladner | 0:aa44e81944cc | 12 | int main() { |
ladner | 0:aa44e81944cc | 13 | while(1) |
ladner | 0:aa44e81944cc | 14 | { |
ladner | 0:aa44e81944cc | 15 | hour = rtc.read(HOURS); |
ladner | 0:aa44e81944cc | 16 | minute = rtc.read(MINUTES); |
ladner | 0:aa44e81944cc | 17 | sec = rtc.read(SECONDS); |
ladner | 0:aa44e81944cc | 18 | /* |
ladner | 0:aa44e81944cc | 19 | pc.printf("%x%x:%x%x:%x%x(%x)\n\r", |
ladner | 0:aa44e81944cc | 20 | ((hour >> 4) & 0x03), (hour & 0x0F), |
ladner | 0:aa44e81944cc | 21 | (minute >> 4)- 8, (minute & 0x0F), |
ladner | 0:aa44e81944cc | 22 | (sec >> 4)- 8, (sec & 0x0F),sec ); |
ladner | 0:aa44e81944cc | 23 | */ |
ladner | 0:aa44e81944cc | 24 | display.write(0, (minute >> 4)- 8); |
ladner | 0:aa44e81944cc | 25 | display.write(1, (minute & 0x0F)); |
ladner | 0:aa44e81944cc | 26 | //display.setColon(1); |
ladner | 0:aa44e81944cc | 27 | display.write(2, (sec >> 4)- 8); |
ladner | 0:aa44e81944cc | 28 | display.write(3, (sec & 0x0F)); |
ladner | 0:aa44e81944cc | 29 | |
ladner | 0:aa44e81944cc | 30 | } |
ladner | 0:aa44e81944cc | 31 | } |