Sandro Juca
/
RTC_ArmBrazilPrintUSB
Set internal Arm RTC Mbed via USB. For more details: http://www.youtube.com/watch?v=v_dIJBSjnuM
main.cpp@0:7386564b4098, 2013-09-18 (annotated)
- Committer:
- sandrojuca
- Date:
- Wed Sep 18 23:47:04 2013 +0000
- Revision:
- 0:7386564b4098
Set internal Arm RTC Mbed via USB. For more details: http://www.youtube.com/watch?v=v_dIJBSjnuM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sandrojuca | 0:7386564b4098 | 1 | #include "mbed.h" //Set internal Arm RTC Mbed via USB. For more details: http://www.youtube.com/watch?v=v_dIJBSjnuM |
sandrojuca | 0:7386564b4098 | 2 | //#include "TextLCD.h" |
sandrojuca | 0:7386564b4098 | 3 | //TextLCD lcd(p19, p20, p21, p22, p23, p24); // rs, e, d0-d3 // www.sanusb.blogspot.com.br |
sandrojuca | 0:7386564b4098 | 4 | |
sandrojuca | 0:7386564b4098 | 5 | DigitalOut led(LED1); |
sandrojuca | 0:7386564b4098 | 6 | |
sandrojuca | 0:7386564b4098 | 7 | char time_stamp[18];//as our lcd is of 16 character it is so |
sandrojuca | 0:7386564b4098 | 8 | |
sandrojuca | 0:7386564b4098 | 9 | int main() |
sandrojuca | 0:7386564b4098 | 10 | { |
sandrojuca | 0:7386564b4098 | 11 | set_time(1379546354); // Set RTC time http://www.epochconverter.com/ |
sandrojuca | 0:7386564b4098 | 12 | |
sandrojuca | 0:7386564b4098 | 13 | while (true) |
sandrojuca | 0:7386564b4098 | 14 | { |
sandrojuca | 0:7386564b4098 | 15 | time_t seconds = time(NULL) - 10800; // time(null) gives the GMT time; Brazil(- 3hours = 10.800s): http://www.epochconverter.com/ |
sandrojuca | 0:7386564b4098 | 16 | strftime(time_stamp, 17, "%d.%m.%y %H:%M:%S", localtime(&seconds)); |
sandrojuca | 0:7386564b4098 | 17 | //this converts the value in seconds obtained above to human readable format and assigns it to the timestamp |
sandrojuca | 0:7386564b4098 | 18 | |
sandrojuca | 0:7386564b4098 | 19 | wait(1); |
sandrojuca | 0:7386564b4098 | 20 | led =! led; |
sandrojuca | 0:7386564b4098 | 21 | printf("%s\r\n",time_stamp);//displays via USB |
sandrojuca | 0:7386564b4098 | 22 | //lcd.locate(0,0);//start displaying from zeroth column,zeroth row |
sandrojuca | 0:7386564b4098 | 23 | //lcd.printf("%s",time_stamp);//diplays the human readable time |
sandrojuca | 0:7386564b4098 | 24 | } |
sandrojuca | 0:7386564b4098 | 25 | } |