Récupération de trame NMEA

Dependencies:   C12832-font

Files at this revision

API Documentation at this revision

Comitter:
grimwald
Date:
Thu Dec 03 16:26:49 2020 +0000
Parent:
10:8895b56c630c
Commit message:
gps

Changed in this revision

C12832-font.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/C12832-font.lib	Thu Dec 03 16:26:49 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/SNE-S1S2-prime/code/C12832-font/#b0a871f340ed
--- a/main.cpp	Mon Nov 23 22:19:13 2020 +0000
+++ b/main.cpp	Thu Dec 03 16:26:49 2020 +0000
@@ -1,34 +1,69 @@
 #include "mbed.h"
-// Echo avec buffer circulaire
+#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
-CircularBuffer < char, 1024> mon_buffer;  // buffer circulaire de 1024 char
+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()
 {
-    char symbole;
+
+
+    lcd.cls();
+    lcd.set_font((unsigned char*)Arial12x12);
     pc_raw.baud(115200);
     pc_raw.attach(&reception_symbole);
-    pc_raw.printf("Echo test buffer circulaire\r\n");
-    ledB=0;
-    mon_buffer.reset();
+
     while(1) {
-        while(!mon_buffer.empty()) {
-            mon_buffer.pop(symbole);
-            pc_raw.putc(symbole);
+    if(flag==1){
+        flag=0;
+        affichage();
+        
         }
+
     }
+
+
 }
 void reception_symbole(void)
 {
-    char symbole;
-    if(pc_raw.readable()) {
-        ledB=!ledB;
-        symbole=pc_raw.getc();
-        mon_buffer.push(symbole);
+
+    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);
+
 }
 
-