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

Files at this revision

API Documentation at this revision

Comitter:
MaxScorda
Date:
Thu Jan 14 22:06:58 2016 +0000
Parent:
41:fb612a3936fb
Child:
43:38660090e6e4
Commit message:
Fine Fase 1: Comandi principali implementati; Vedi appunti per step da compiere

Changed in this revision

Functions.h Show annotated file Show diff for this revision Revisions of this file
choiceFunctions.h Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/Functions.h	Sat Jan 09 00:53:41 2016 +0000
+++ b/Functions.h	Thu Jan 14 22:06:58 2016 +0000
@@ -128,9 +128,14 @@
         errp=menuOut(func,string(stringa));
     }
 
-    //Random Activate DA FARE!!!!!!!!!
+    //Random Activate 
     else if (func=="r") {
-        errp=RfuncOut(func, funcnum,param);
+        errp=RfuncOut(func, strIn);
+    }
+
+    //Random Activate 
+    else if (strIn.substr(0,2)=="so"){
+        errp=sensorOut(func, strIn);
     }
 
     //start
@@ -230,7 +235,7 @@
     status=false; //accensione
     randomActivate=false;
     term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS("Off")),11,p16,10,1);
-    term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS("True")),39,p17,10,1);
+    term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS("Off")),39,p17,10,1);
 
     term.readypos();
 }
--- a/choiceFunctions.h	Sat Jan 09 00:53:41 2016 +0000
+++ b/choiceFunctions.h	Thu Jan 14 22:06:58 2016 +0000
@@ -55,15 +55,17 @@
 }
 
 
-void writeFunctionVal(string strIn)
+void writeFunctionVal(string strIn, int fullstampa=1)
 {
     //scrivi a video i valori funzione
     int idx=trovaIndiceFunzione(strIn);
     //stampo
     if (idx<50) { //non dovrebbe servire
-        term.formatPrintf(fnzAdd.string2char(fnzAdd.i2s(function_val[idx][2])),50,16,10); //min
-        term.formatPrintf(fnzAdd.string2char(fnzAdd.i2s(function_val[idx][5])),60,16,10); //start
-        term.formatPrintf(fnzAdd.string2char(fnzAdd.i2s(function_val[idx][3])),70,16,10); //max
+        if (fullstampa==1) {
+            term.formatPrintf(fnzAdd.string2char(fnzAdd.i2s(function_val[idx][2])),50,16,10); //min
+            term.formatPrintf(fnzAdd.string2char(fnzAdd.i2s(function_val[idx][5])),60,16,10); //start
+            term.formatPrintf(fnzAdd.string2char(fnzAdd.i2s(function_val[idx][3])),70,16,10); //max
+        }
         term.formatPrintf(fnzAdd.string2char(fnzAdd.i2s(function_val[idx][6])),70,4+funcidx,10); //valore attuale di fianco alla riga
     }
 }
@@ -207,26 +209,47 @@
 
 
 //************************ Random Out
-bool RfuncOut(string func, string funcnum, string param)
+bool RfuncOut(string func,string sstr)
 {
     bool errp=1;
-    if (funcnum=="1") {
-        if (param=="on ") {
-            term.formatPrintf("ON \n",61,8,99,1); //p22
-            ardser.printf(fnzAdd.string2char(fnzAdd.addEOS("R11\r")));
-            printDisp(dispType,"Random On \n\r");
-            randomActivate=true;
-            errp=0;
-        } else if (param=="off") {
-            term.formatPrintf("OFF\n",61,8,99,1); //p22
-            ardser.printf(fnzAdd.string2char(fnzAdd.addEOS("R10\r")));
-            printDisp(dispType,"Random OFF\n\r");
-            randomActivate=false;
-            errp=0;
-        }
-    }
-    term.formatPrintf("\n",61,p52,99,1); //p52
-    return errp;
+    string funcc;
+    funcc=sstr.substr(1,3);
+
+    if (funcc=="on ") {
+        term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS("On")),39,p17,10,1);
+        ardser.printf(fnzAdd.string2char(fnzAdd.addEOS("ron\r")));
+        printDisp(dispType,"Random On \n\r");
+        randomActivate=true;
+    } else {
+        term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS("Off")),39,p17,10,1);
+        ardser.printf(fnzAdd.string2char(fnzAdd.addEOS("roff\r")));
+        printDisp(dispType,"Random OFF\n\r");
+        randomActivate=false;
+     }
+    errp=0;
+      return errp;
+}
+
+//************************ Sensori Out
+bool sensorOut(string func,string sstr)
+{
+    bool errp=1;
+    string funcc;
+    funcc=sstr.substr(1,3);
+
+    if (funcc=="on ") {
+      //  term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS("On")),39,p17,10,1); ///mettere a video!!!1
+        ardser.printf(fnzAdd.string2char(fnzAdd.addEOS("son\r")));
+        printDisp(dispType,"Sensor On \n\r");
+        randomActivate=true;
+    } else {
+     //   term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS("Off")),39,p17,10,1); ///mettere a video!!!1
+        ardser.printf(fnzAdd.string2char(fnzAdd.addEOS("soff\r")));
+        printDisp(dispType,"Sensor OFF\n\r");
+        randomActivate=false;
+     }
+    errp=0;
+      return errp;
 }
 
 //********************* Start
@@ -260,9 +283,13 @@
     bool errp=1;
     string funcc;
     funcc=sstr.substr(1,1);
-    if ((funcc>="0") && (funcc<="9")) {
-        errp=0;
-    }
+
+    term.formatPrintf("+\n",21,p51,8,1); //p51
+    term.formatPrintf("+\n",61,p52,99,1);   //p52
+    ardser.printf("+\r");
+    printDisp(dispType,"Add Value\n\r");
+
+    errp=0;
     return errp;
 }
 
@@ -273,9 +300,13 @@
     bool errp=1;
     string funcc;
     funcc=sstr.substr(1,1);
-    if ((funcc>="0") && (funcc<="9")) {
-        errp=0;
-    }
+
+    term.formatPrintf("-\n",21,p51,8,1); //p51
+    term.formatPrintf("-\n",61,p52,99,1);   //p52
+    ardser.printf("-\r");
+    printDisp(dispType,"Sub Value\n\r");
+
+    errp=0;
     return errp;
 }
 
@@ -412,6 +443,7 @@
             idx=trovaIndiceFunzione(sstr.substr(3,1)+"."+sstr.substr(4,1));
         }
         function_val[idx][2+atoi(fnzAdd.string2char(sstr.substr(5,1)))] =vval; //tipo
+        if ((sstr.substr(5,1)=="4") || (status==true)) writeFunctionVal(sstr.substr(3,1)+"."+sstr.substr(4,1),0); //stampa solo il 4. da rivedere
         //errp=0;
     }
     return errp;
--- a/mbed.bld	Sat Jan 09 00:53:41 2016 +0000
+++ b/mbed.bld	Thu Jan 14 22:06:58 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96
\ No newline at end of file