programme horloge temps réelle

Dependencies:   BSP_DISCO_F746NG LCD_DISCO_F746NG mbed

Fork of DS1338 by projet_Laos

main.cpp

Committer:
Asoumy
Date:
2016-10-12
Revision:
2:f65e93dd619c
Child:
3:ec3f4251b6f3

File content as of revision 2:f65e93dd619c:

#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));
}