x

Dependencies:   mbed ihm_L476_full

Revision:
0:ec600fef44bc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri May 15 14:36:28 2020 +0000
@@ -0,0 +1,48 @@
+//#include "mbed.h"
+#include "ihm_L476.h"
+#define PI 3.14f
+Serial pc(SERIAL_TX, SERIAL_RX);
+CircularBuffer <unsigned char,1024> buf;
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+IHM_L476 ihm;
+
+void serial_receive()
+{
+    unsigned char  c=pc.getc(); // attention à protéger les appels pc
+    buf.push(c);
+}
+//
+int main()
+{
+    char l1,l2;
+    pc.baud(9600);
+    pc.printf("Hello World !\n");
+    pc.attach(&serial_receive);     // isr sur reception char
+    float f=10;
+    int j=0;
+    char str[20];
+    while(1) {
+        while(!buf.empty()) {
+            unsigned char c;
+            buf.pop(c);
+            switch(c) {
+                case '\r' :  // fin de message on traite
+                    str[j]=NULL;  // fin de chaine
+                    j=0;
+                    // debut traitement chaine recue
+                    sscanf(str,"%d %d %f",&l1,&l2,&f);
+                    led1=l1;
+                    led2=l2;
+                    ihm.LCD_printf("%f",f);
+                    // fin traitement chaine recue
+                    break;
+                case '\n':  // on ignore
+                    break;
+                default :   // on stocke
+                    str[j]=c;
+                    j++;
+            }
+        }
+    }
+}
\ No newline at end of file