Récupération de trame NMEA

Dependencies:   C12832-font

Committer:
grimwald
Date:
Thu Dec 03 16:26:49 2020 +0000
Revision:
11:983e4b214c0c
Parent:
10:8895b56c630c
gps

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gr91 0:3aa4ba0ada56 1 #include "mbed.h"
grimwald 11:983e4b214c0c 2 #include "C12832.h"
grimwald 11:983e4b214c0c 3 #include "Fonts/Arial12x12.h"
grimwald 11:983e4b214c0c 4
gr91 8:23fca4edc6b9 5 // lien serie via USB avec Terarerm
gr91 6:a58f18b765cd 6 // Universite Paris-Saclay - IUT Cachan
gr91 8:23fca4edc6b9 7 RawSerial pc_raw(USBTX, USBRX); // ou SERIAL-TX, SERIAL_RX ou PA_2,PA_3
grimwald 11:983e4b214c0c 8 C12832 lcd(D11, D13, D12, D7, D10);
gr91 8:23fca4edc6b9 9 DigitalOut ledB(D8);
grimwald 11:983e4b214c0c 10
gr91 8:23fca4edc6b9 11 void reception_symbole(void);
grimwald 11:983e4b214c0c 12 void affichage(void);
grimwald 11:983e4b214c0c 13
grimwald 11:983e4b214c0c 14 char DataChar[50];
grimwald 11:983e4b214c0c 15
grimwald 11:983e4b214c0c 16 int hh,mm,ss;
grimwald 11:983e4b214c0c 17 int JJ,MM,AAAA;
grimwald 11:983e4b214c0c 18 static int i=0;
grimwald 11:983e4b214c0c 19 static int c;
grimwald 11:983e4b214c0c 20 volatile int flag=0;
grimwald 11:983e4b214c0c 21
gr91 0:3aa4ba0ada56 22 int main()
gr91 0:3aa4ba0ada56 23 {
grimwald 11:983e4b214c0c 24
grimwald 11:983e4b214c0c 25
grimwald 11:983e4b214c0c 26 lcd.cls();
grimwald 11:983e4b214c0c 27 lcd.set_font((unsigned char*)Arial12x12);
gr91 8:23fca4edc6b9 28 pc_raw.baud(115200);
gr91 8:23fca4edc6b9 29 pc_raw.attach(&reception_symbole);
grimwald 11:983e4b214c0c 30
gr91 0:3aa4ba0ada56 31 while(1) {
grimwald 11:983e4b214c0c 32 if(flag==1){
grimwald 11:983e4b214c0c 33 flag=0;
grimwald 11:983e4b214c0c 34 affichage();
grimwald 11:983e4b214c0c 35
gr91 10:8895b56c630c 36 }
grimwald 11:983e4b214c0c 37
gr91 8:23fca4edc6b9 38 }
grimwald 11:983e4b214c0c 39
grimwald 11:983e4b214c0c 40
gr91 8:23fca4edc6b9 41 }
gr91 8:23fca4edc6b9 42 void reception_symbole(void)
gr91 8:23fca4edc6b9 43 {
grimwald 11:983e4b214c0c 44
grimwald 11:983e4b214c0c 45 c=pc_raw.getc();
grimwald 11:983e4b214c0c 46 pc_raw.putc(c);
grimwald 11:983e4b214c0c 47 if(c=='\n') {
grimwald 11:983e4b214c0c 48 DataChar[i]=NULL;
grimwald 11:983e4b214c0c 49 flag=1;
grimwald 11:983e4b214c0c 50 i=0;
gr91 0:3aa4ba0ada56 51 }
grimwald 11:983e4b214c0c 52
grimwald 11:983e4b214c0c 53 else {
grimwald 11:983e4b214c0c 54
grimwald 11:983e4b214c0c 55 DataChar[i]=c;
grimwald 11:983e4b214c0c 56 i++;
grimwald 11:983e4b214c0c 57 }
grimwald 11:983e4b214c0c 58
grimwald 11:983e4b214c0c 59
grimwald 11:983e4b214c0c 60
grimwald 11:983e4b214c0c 61 }
grimwald 11:983e4b214c0c 62 void affichage(void)
grimwald 11:983e4b214c0c 63 {
grimwald 11:983e4b214c0c 64 sscanf(DataChar,"$GPZDA,%2d%2d%2d,%d,%d,%d,,*4B",&hh,&mm,&ss,&JJ,&MM,&AAAA);
grimwald 11:983e4b214c0c 65 lcd.locate(0,0);
grimwald 11:983e4b214c0c 66 lcd.printf("%02d:%02d:%02d %d/%d/%d",hh,mm,ss,JJ,MM,AAAA);
grimwald 11:983e4b214c0c 67
gr91 0:3aa4ba0ada56 68 }
gr91 7:37ea12f2b18f 69