Erik -
/
Mini_DK_clk
Simple clock program for LPC1768 Mini-DK
main.cpp@0:ab0aec01b38e, 2012-12-30 (annotated)
- Committer:
- Sissors
- Date:
- Sun Dec 30 21:31:56 2012 +0000
- Revision:
- 0:ab0aec01b38e
v0.1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 0:ab0aec01b38e | 1 | #include "Mini_DK.h" |
Sissors | 0:ab0aec01b38e | 2 | #include "mbed.h" |
Sissors | 0:ab0aec01b38e | 3 | #include "RTC.h" |
Sissors | 0:ab0aec01b38e | 4 | |
Sissors | 0:ab0aec01b38e | 5 | DigitalOut led(DK_LED1); |
Sissors | 0:ab0aec01b38e | 6 | |
Sissors | 0:ab0aec01b38e | 7 | TouchScreenADS7843 TFT(TP_SDI ,TP_SDO ,TP_SCK ,TP_CS ,TP_IRQ ,LCD_SDI, LCD_SDO, LCD_SCK, LCD_CS, NC,"TFT"); |
Sissors | 0:ab0aec01b38e | 8 | |
Sissors | 0:ab0aec01b38e | 9 | void displayFunction( void ) |
Sissors | 0:ab0aec01b38e | 10 | { |
Sissors | 0:ab0aec01b38e | 11 | led = !led; |
Sissors | 0:ab0aec01b38e | 12 | TFT.locate(20,50); |
Sissors | 0:ab0aec01b38e | 13 | time_t seconds = time(NULL); |
Sissors | 0:ab0aec01b38e | 14 | char buffer[32]; |
Sissors | 0:ab0aec01b38e | 15 | |
Sissors | 0:ab0aec01b38e | 16 | strftime(buffer, 32, "%H:%M:%S", localtime(&seconds)); |
Sissors | 0:ab0aec01b38e | 17 | TFT.printf("%s", buffer); |
Sissors | 0:ab0aec01b38e | 18 | } |
Sissors | 0:ab0aec01b38e | 19 | |
Sissors | 0:ab0aec01b38e | 20 | int main() |
Sissors | 0:ab0aec01b38e | 21 | { |
Sissors | 0:ab0aec01b38e | 22 | set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37 |
Sissors | 0:ab0aec01b38e | 23 | TFT.TP_Init(); |
Sissors | 0:ab0aec01b38e | 24 | |
Sissors | 0:ab0aec01b38e | 25 | TFT.background(Black); // set background to black |
Sissors | 0:ab0aec01b38e | 26 | TFT.foreground(White); // set chars to white |
Sissors | 0:ab0aec01b38e | 27 | |
Sissors | 0:ab0aec01b38e | 28 | |
Sissors | 0:ab0aec01b38e | 29 | |
Sissors | 0:ab0aec01b38e | 30 | TFT.cls(); |
Sissors | 0:ab0aec01b38e | 31 | TFT.set_font((unsigned char*) Arial28x28); |
Sissors | 0:ab0aec01b38e | 32 | TFT.set_orientation(1); |
Sissors | 0:ab0aec01b38e | 33 | |
Sissors | 0:ab0aec01b38e | 34 | |
Sissors | 0:ab0aec01b38e | 35 | RTC::attach(&displayFunction, RTC::Second); |
Sissors | 0:ab0aec01b38e | 36 | |
Sissors | 0:ab0aec01b38e | 37 | while(1) {} |
Sissors | 0:ab0aec01b38e | 38 | } |