programme horloge temps réelle
Dependencies: BSP_DISCO_F746NG LCD_DISCO_F746NG mbed
Fork of DS1338 by
Diff: main.cpp
- Revision:
- 2:f65e93dd619c
- Child:
- 3:ec3f4251b6f3
diff -r e77d69913c46 -r f65e93dd619c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 12 14:10:40 2016 +0000 @@ -0,0 +1,53 @@ +#include "mbed.h" +#include "ds1338.h" +#include "LCD_DISCO_F746NG.h" + +LCD_DISCO_F746NG lcd; + +char date [50]; +DigitalOut led1(LED1); + +int main() { + AnalogIn Vpan(A0); + AnalogIn Ipan(A1); + AnalogIn Tpan(A2); + AnalogIn Irr(A3); + AnalogIn Vbat(A4); + AnalogIn Ibat(A5); + + struct tm time; + //int count; + + Serial pc(USBTX, USBRX); + pc.baud(9600); + pc.printf("DS1338 Demo\r\n"); + DS1338 ds1338(D14,D15); +//#ifdef INIT_TIME + + time.tm_sec=0; + time.tm_min=46; + time.tm_hour=13; + time.tm_mday=12; + time.tm_mon=9; + time.tm_year=116; + time.tm_wday=3; + time.tm_yday=0; + time.tm_isdst=0; + ds1338.writeTime(&time); +//#endif + + + while (true) { + wait(0.5); + ds1338.readTime(&time); + //ds1338.read(0,4,(char *)(&count)); + //count++; + //ds1338.write(0,4,(char *)(&count)); + pc.printf("time at %s\r\n",asctime(&time)); + } + lcd.Clear(LCD_COLOR_RED); + lcd.SetBackColor(LCD_COLOR_RED); + lcd.SetTextColor(LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"temps"), LEFT_MODE); + sprintf((char*)date, "Touches: %s", asctime(&time)); +} \ No newline at end of file