Récupération de trame NMEA

Dependencies:   C12832-font

main.cpp

Committer:
grimwald
Date:
2020-12-03
Revision:
11:983e4b214c0c
Parent:
10:8895b56c630c

File content as of revision 11:983e4b214c0c:

#include "mbed.h"
#include "C12832.h"
#include "Fonts/Arial12x12.h"

// lien serie via USB avec Terarerm
// Universite Paris-Saclay - IUT Cachan
RawSerial pc_raw(USBTX, USBRX);  // ou SERIAL-TX, SERIAL_RX  ou PA_2,PA_3
C12832 lcd(D11, D13, D12, D7, D10);
DigitalOut ledB(D8);

void reception_symbole(void);
void affichage(void);

char DataChar[50];

int hh,mm,ss;
int JJ,MM,AAAA;
static int i=0;
static int c;
volatile int flag=0;

int main()
{


    lcd.cls();
    lcd.set_font((unsigned char*)Arial12x12);
    pc_raw.baud(115200);
    pc_raw.attach(&reception_symbole);

    while(1) {
    if(flag==1){
        flag=0;
        affichage();
        
        }

    }


}
void reception_symbole(void)
{

    c=pc_raw.getc();
    pc_raw.putc(c);
    if(c=='\n') {
        DataChar[i]=NULL;
        flag=1;
        i=0;
    }

    else {

        DataChar[i]=c;
        i++;
    }



}
void affichage(void)
{
    sscanf(DataChar,"$GPZDA,%2d%2d%2d,%d,%d,%d,,*4B",&hh,&mm,&ss,&JJ,&MM,&AAAA);
    lcd.locate(0,0);
    lcd.printf("%02d:%02d:%02d %d/%d/%d",hh,mm,ss,JJ,MM,AAAA);

}