Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed BufferedSerial AserialIOFuncLib SSD1306 TerminalPlusV2
Fork of SerialIO by
Diff: choiceFunctions.h
- Revision:
- 38:d88296cbb39c
- Parent:
- 36:9ecb98d7c2cd
- Child:
- 39:0d7165083e7a
diff -r befd2fe96ee3 -r d88296cbb39c choiceFunctions.h
--- a/choiceFunctions.h Fri Nov 06 22:31:17 2015 +0000
+++ b/choiceFunctions.h Thu Dec 24 01:38:56 2015 +0000
@@ -1,25 +1,117 @@
-
-//********************* Serial 4 real
-bool Sfunc(string func, string funcnum, string param)
+bool funcOut(string func, string funcnum, string param, string sstr)
{
+ //fare
bool errp=1;
- if (param=="on ") {
- realExtraSerial=true;
- term.formatPrintf("ON \n",21,10,3,1); //p31
- term.formatPrintf("RS Attiva \n",61,14,99,1); //p52
- printDisp(dispType,"RS Attiva \n\r");
- errp=0;
- }
- if (param=="off") {
- realExtraSerial=false;
- term.formatPrintf("OFF\n",21,10,3,1); //p31
- term.formatPrintf("RS Disattivata \n",61,14,99); //p52
- if (realExtraSerial==false) ardser.printf("\nRS OFF \n\r");
- printDisp(dispType,"RS Disattivata \n\r");
+ char funcc;
+ int tempcc=0;
+ funcc=*fnzAdd.string2char(fnzAdd.addEOS(funcnum));
+
+ if ((funcnum>="0") && (funcnum<="9")) {
+ while (menu_funcChoice[tempcc]!="z") {
+ tempcc++;
+ }
+ if (menu_funcChoice[tempcc]=="z") tempcc--;
+ funcidx=tempcc;
+
errp=0;
}
return errp;
}
+//********************* Init: chiama Arduino al boot e chiama i paramtri
+bool initFunc(string func, string funcnum, string param)
+{
+ bool errp=1;
+
+ if (funcnum=="1") {
+ // errp=menuIn("0", param);
+
+ }
+ return errp;
+}
+
+
+//********************* Led
+bool Lfunc(string func, string funcnum, string param)
+{
+ bool errp=1;
+
+ if (funcnum=="1") {
+ if (param=="on ") {
+ term.formatPrintf("Led ACCESO \n",61,p52,99,1); //p52
+ if (realExtraSerial==false) ardser.printf("\nLed ACCESO \n\r");
+ printDisp(dispType,"Led ACCESO \n\r");
+ led.onOff(1); //Accende il led
+ errp=0;
+ }
+ if (param=="off") {
+ term.formatPrintf("Led SPENTO! \n",61,p52,99,1); //p52
+ if (realExtraSerial==false) ardser.printf("\nLed SPENTO! \n\r");
+ printDisp(dispType,"Led SPENTO \n\r");
+ led.onOff(0); //Spegne il led
+ errp=0;
+ }
+ }
+ return errp;
+}
+
+
+//********************** cambio menu
+
+bool funcfromMenu(string func, string funcnum, string param, string sstr)
+{
+// funzione di load funzioni da menu scelto
+ bool errp=1;
+ char funcc;
+ char tempm;
+ int ccmenu=0;
+ int ccfun=0;
+ string funzionen;
+ funcc=*fnzAdd.string2char(fnzAdd.addEOS(funcnum));
+
+ //filtro vettore funzioni in base la menu
+ do {
+ // confronto il primo carattere dell vettore funzioni col primo carattere del menu
+ funzionen=menu_function[ccmenu];
+ tempm=*fnzAdd.string2char(funzionen.substr(0,1));
+ // se = metto il valore del vettore funzioni nel vettore funzioni scelte
+ if (tempm==funcc) {
+ menu_funcChoice[ccfun]=menu_function[ccmenu];
+ ccfun++;
+ }
+ ccmenu++;
+ } while ((ccmenu<10) && (funcc!='z')) ;
+ funcidx=0;
+ //azzero da dove sono in giu'
+ for (int i = fnzAdd.c2i(funcc)+1; i <=funcidx ; i++) {
+ term.formatPrintf("\n",42,4+i,38);
+ }
+ //scrico dalla prima allo scelto
+ for (int i = 0; i <=fnzAdd.c2i(funcc) ; i++) {
+ term.formatPrintf(fnzAdd.string2char(menu_funcChoice[i]),42,4+i,38);
+ }
+ errp=0; //per ora non fa nulla, vedere se tenere a uso futuro
+ return errp;
+}
+
+
+bool menuOut(string func, string funcnum, string param, string sstr)
+{
+ bool errp=1;
+ char funcc;
+ funcc=*fnzAdd.string2char(fnzAdd.addEOS(funcnum));
+ if ((funcnum>="0") && (funcnum<="9")) {
+ //azzero
+ term.formatPrintf(" \n",2,4+menuidx,1);
+ // scrivo
+ menuidx= fnzAdd.c2i(funcc);
+ term.formatPrintf("*\n",2,4+menuidx,1);
+ printDisp(dispType,fnzAdd.string2char(fnzAdd.addEOS("Menu "+funcnum+"\r")));
+ //chiama la cernita delle funzioni
+ errp=funcfromMenu(func, funcnum, param, sstr); //ritorna sempre 0 (e va bene cosi)
+ }
+ return errp;
+}
+
//************************ Random Out
bool RfuncOut(string func, string funcnum, string param)
@@ -32,8 +124,7 @@
printDisp(dispType,"Random On \n\r");
randomActivate=true;
errp=0;
- }
- if (param=="off") {
+ } 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");
@@ -41,83 +132,17 @@
errp=0;
}
}
- term.formatPrintf("\n",61,14,99,1); //p52
- return errp;
-}
-
-//********************* Led
-bool Lfunc(string func, string funcnum, string param)
-{
- bool errp=1;
-
- if (funcnum=="1") {
- if (param=="on ") {
- term.formatPrintf("Led ACCESO \n",61,14,99,1); //p52
- if (realExtraSerial==false) ardser.printf("\nLed ACCESO \n\r");
- printDisp(dispType,"Led ACCESO \n\r");
- led.onOff(1); //Accende il led
- errp=0;
- }
- if (param=="off") {
- term.formatPrintf("Led SPENTO! \n",61,14,99,1); //p52
- if (realExtraSerial==false) ardser.printf("\nLed SPENTO! \n\r");
- printDisp(dispType,"Led SPENTO \n\r");
- led.onOff(0); //Spegne il led
- errp=0;
- }
- }
+ term.formatPrintf("\n",61,p52,99,1); //p52
return errp;
}
-//********************* Synth Tracce
-bool s09funcOut(string func, string funcnum, string param, char sstr)
-{
- bool errp=1;
- int funcn;
- if ((funcnum>="0") && (funcnum<="9")) {
- term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS(func+"-"+funcnum+"-"+param)),21,14,8,1); //p51
- // vale la pena creare una funzione di parametri da formalizzare
- funcn=fnzAdd.c2i(sstr);
- funcn=fnzAdd.constrain(funcn,0,2);
- term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS(func+"-"+funcnum+"-"+param)),21+(funcn%2)*40,6+(2*(funcn/2)),8,1); //p11 //p12 //p21
- term.formatPrintf("Tracks Command \n",61,14,99,1); //p52
- ardser.printf(fnzAdd.string2char(fnzAdd.addEOS(func+funcnum+param+"\r")));
- printDisp(dispType,"Tracks Command \n\r");
- printDisp(dispType,fnzAdd.string2char(fnzAdd.addEOS(" "+func+funcnum+param+"\r")));
- //ardser.printf(fnzAdd.string2char(fnzAdd.addEOS(func+"-"+funcnum+"-"+param)));
- errp=0;
- }
- return errp;
-}
-
-//********************* Synth Note
-bool NfuncOut(string func, string funcnum, string param, char* arr)
-{
- bool errp=1;
- int funcn;
-
- if ((funcnum>="0") && (funcnum<="9")) {
- if (((arr[2]>='0') && (arr[2]<='9')) || (arr[2]=='-')) {
- term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS(func+"-"+funcnum+"-"+param)),21,14,8,1); //p51
- // vale la pena creare una funzione di parametri da formalizzare
- funcn=fnzAdd.c2i(arr[2]);
- //funcn=fnzAdd.constrain(funcn,0,2);
- term.formatPrintf("Note Command \n",61,14,99,1); //p52
- ardser.printf(fnzAdd.string2char(fnzAdd.addEOS(func+funcnum+param+"\r")));
- printDisp(dispType,"Note Command \n\r");
- printDisp(dispType,fnzAdd.string2char(fnzAdd.addEOS(" "+func+funcnum+param+"\r")));
- errp=0;
- }
- }
- return errp;
-}
//********************* Start
bool StartfuncOut()
{
- term.formatPrintf("Start\n",21,14,8,1); //p51
- term.formatPrintf("Start H-Ard\n",61,14,99,1); //p52
+ term.formatPrintf("Start\n",21,p51,8,1); //p51
+ term.formatPrintf("Start H-Ard\n",61,p52,99,1); //p52
ardser.printf("start\r");
printDisp(dispType,"Start H-Ard\n\r");
return 0;
@@ -126,83 +151,91 @@
//********************* Stop
bool StopfuncOut()
{
- term.formatPrintf("Stop\n",21,14,8,1); //p51
- term.formatPrintf("Stop H-Ard\n",61,14,99,1); //p52
+ term.formatPrintf("Stop\n",21,p51,8,1); //p51
+ term.formatPrintf("Stop H-Ard\n",61,p52,99,1); //p52
ardser.printf("stop\r");
printDisp(dispType,"Stop H-Ard\n\r");
return 0;
}
-//********************* Delay Stop
-bool DelayStopfuncOut()
-{
- term.formatPrintf("DStop\n",21,14,8,1); //p51
- term.formatPrintf("Delay Stop H-Ard\n",61,14,99,1); //p52
- ardser.printf("dstop\r");
- printDisp(dispType,"DlyStop H-Ard\n\r");
- return 0;
-}
-
-
-/************************ IN Function *****************************/
+/************************ IN Function *****************************/
/******************************************************************/
/******************************************************************/
-//************************ Random
-
-
-bool RfuncIn(string func, string funcnum, string param)
+//********************* Menu In
+bool menuIn(string func, string sstr)
{
bool errp=1;
- if (funcnum=="1") {
- if (param=="on ") {
- printDisp(dispType,"Random On \n\r");
- term.formatPrintf("ON \n",65,8,99,1); //p22
- printDisp(dispType,"RfuncInOn \n\r");
- errp=0;
- }
- if (param=="off") {
- term.formatPrintf("OFF\n",65,8,99,1); //p22
- printDisp(dispType,"RfuncInOFF\n\r");
- errp=0;
- }
+ int funcn;
+ // char funcc=fnzAdd.string2char(sstr.substr(2,1));
+ char funcc;
+ funcc=*fnzAdd.string2char(fnzAdd.addEOS(sstr.substr(2,1)));
+ if (funcc!='z') {
+ //trasformo in intero
+ funcn=fnzAdd.c2i(funcc);
+ //assegno menu al vettore
+ menu_main[funcn]=fnzAdd.addEOS(sstr);
+ //stampo in posizione
+ term.formatPrintf(fnzAdd.string2char(menu_main[funcn]),2,4+funcn,38);
+ //display
+ printDisp(dispType,"Menu In \n\r");
+ printDisp(dispType,fnzAdd.string2char(fnzAdd.addEOS(" "+sstr.substr(0,3)+"\r")));
+ errp=0;
}
return errp;
}
-//********************* Synth Tracce
-bool s09funcIn(string func, string funcnum, string param, char sstr)
+//********************* Function In
+bool functionIn(string func, string sstr)
{
bool errp=1;
int funcn;
+ char funcc= *fnzAdd.string2char(sstr.substr(2,1));
- if ((funcnum>="0") && (funcnum<="9")) {
- term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS(func+"-"+funcnum+"-"+param)),21,14,8,1); //p51
- // vale la pena creare una funzione di parametri da formalizzare
- funcn=fnzAdd.c2i(sstr);
- funcn=fnzAdd.constrain(funcn,0,2);
- //azzera flag di ricezione
- for (int i = 0; i < 3; i++) term.formatPrintf(" \n",31+(i%2)*40,6+(2*(i/2)),8,1); //p11 //p12 //p21
- term.formatPrintf("*\n",31+(funcn%2)*40,6+(2*(funcn/2)),8,1); //p11 //p12 //p21
- printDisp(dispType,"s09funcIn \n\r");
- printDisp(dispType,fnzAdd.string2char(fnzAdd.addEOS(" "+func+funcnum+param+"\r")));
+ if (funcc!='z') {
+ //trasformo in intero
+ funcn=fnzAdd.c2i(funcc);
+ //assegno menu al vettore
+ menu_function[funcn]=fnzAdd.addEOS(sstr.substr(2,1)); //??? sicuri?
+ //display
+ printDisp(dispType,"Function In \n\r");
+ printDisp(dispType,fnzAdd.string2char(fnzAdd.addEOS(" "+sstr.substr(0,3)+"\r")));
errp=0;
}
return errp;
}
+//********************* Start
+bool StartfuncIn()
+{
+ term.formatPrintf("*\n",26,p51,8,1); //p51
+ // term.formatPrintf("Start H-Ard\n",61,p52,99,1); //p52
+ // printDisp(dispType,"InStart H-Ard\n\r");
+ return 1;
+}
+
+//********************* Start
+bool StopfuncIn()
+{
+ term.formatPrintf("*\n",26,p51,8,1); //p51
+ // term.formatPrintf("Start H-Ard\n",61,p52,99,1); //p52
+// printDisp(dispType,"InStop H-Ard\n\r");
+ return 1;
+}
+
+
//********************* Synth Note
bool NfuncIn(string func, string funcnum, string param, char* arr)
{
bool errp=1;
int funcn;
if ((funcnum>="0") && (funcnum<="9")) {
- term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS(param)),21,14,8,1); //p51
+ term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS(param)),21,p51,8,1); //p51
// vale la pena creare una funzione di parametri da formalizzare
funcn=fnzAdd.c2i(arr[2]+arr[3]);
- for (int i = 0; i < 6; i++) term.formatPrintf(" ",23+(i*4),12,1,1);
+ for (int i = 0; i < 6; i++) term.formatPrintf(" ",23+(i*4),12,1,1);
term.formatPrintf(fnzAdd.string2char(param.substr(0,2)+"*"),21+(fnzAdd.c2i(arr[1])*4),12,1,1); //p11 //p12 //p21
printDisp(dispType,"NFuncIn\n\r");
printDisp(dispType,fnzAdd.string2char(fnzAdd.addEOS(" "+func+funcnum+param+"\r")));
@@ -213,39 +246,12 @@
return errp;
}
-//********************* Start
-bool StartfuncIn()
-{
- term.formatPrintf("*\n",26,14,8,1); //p51
- // term.formatPrintf("Start H-Ard\n",61,14,99,1); //p52
- // printDisp(dispType,"InStart H-Ard\n\r");
- return 1;
-}
-
-//********************* Start
-bool StopfuncIn()
-{
- term.formatPrintf("*\n",26,14,8,1); //p51
- // term.formatPrintf("Start H-Ard\n",61,14,99,1); //p52
- // printDisp(dispType,"InStop H-Ard\n\r");
- return 1;
-}
-
-//********************* Start
-bool DelayStopfuncIn()
-{
- term.formatPrintf("*\n",26,14,8,1); //p51
- // term.formatPrintf("Start H-Ard\n",61,14,99,1); //p52
- // printDisp(dispType,"InStop H-Ard\n\r");
- return 1;
-}
-
-//********************* Start
+//********************* Boot
bool bootfuncIn()
{
- term.formatPrintf("*\n",26,14,8,1); //p51
- term.formatPrintf("boot\n",21,14,8,1); //p51
- term.formatPrintf("Arduino Boot\n",61,14,99,1); //p52
+ term.formatPrintf("*\n",26,p51,8,1); //p51
+ term.formatPrintf("boot\n",21,p51,8,1); //p51
+ term.formatPrintf("Arduino Boot\n",61,p52,99,1); //p52
ardser.printf("rl\r");
return 1;
}
\ No newline at end of file
