Console Serial IO con display OLED e seriale asincrona

Dependencies:   mbed BufferedSerial AserialIOFuncLib SSD1306 TerminalPlusV2

Fork of SerialIO by Max Scordamaglia

Console Serial IO con display OLED e seriale asincrona

Revision:
23:b7bd85345617
Parent:
21:a867c9454f21
Child:
24:1603f5b23d98
--- a/main.cpp	Thu Aug 20 00:18:38 2015 +0000
+++ b/main.cpp	Thu Aug 20 08:28:57 2015 +0000
@@ -1,16 +1,20 @@
 #include "mbed.h"
 #include "config.h"
 #include "IOFuncLib.h"
+#include "BufferedSerial.h"
 
 
 //init standard
 InterruptIn mybutton(USER_BUTTON);
 Serial pc(SERIAL_TX, SERIAL_RX); //Apertura della seriale 2
 Serial ardser(PA_11, PA_12); //Apertura della seriale 1 *opzionale vedi sotto
+//BufferedSerial pc(SERIAL_TX, SERIAL_RX); //Apertura della seriale 2
+//BufferedSerial ardser(PA_11, PA_12); //Apertura della seriale 1 *opzionale vedi sotto
 //init funzioni personal lib
 Flasher led(LED1);
 Screen sc(&pc);
 genFunctions fnz;
+Ticker ScreenSaver;
 
 //var
 int cont=0;
@@ -38,6 +42,7 @@
     //pc.format(int bits=8, Parity parity=SerialBase::None, int stop_bits=1)
 
     mybutton.fall(&pressed);
+    ScreenSaver.attach(&scsa,60);
     sc.emptyFrame();
     sc.banner();
     //ardser
@@ -48,10 +53,24 @@
     bannerDisp(dispType);
 
     while(1) {
+        /*
+          Timer s;
+        
+          s.start();
+          pc.printf("Hello World - buffered\n");
+          int buffered_time = s.read_us();
+          wait(0.1f); // give time for the buffer to empty
+ *        
+ *          s.reset();
+ *          printf("Hello World - blocking\n");
+ *          int polled_time = s.read_us();
+ *          s.stop();
+ *          wait(0.1f); // give time for the buffer to empty
+ */
+        
         ardser.attach(&callback);
         //seriale interna
         c=pc.getc(); //legge un carattere dalla seriale
-        inverseDisp(dispType);
         if (c != 13) {
             buffer[i]=c; // se il carattere è diverso da CarriageReturn (ASCII 13) lo memorizza nel buffer
             i++; // incrementa il puntatore al buffer