Console Serial IO con display OLED e seriale asincrona
Dependencies: mbed BufferedSerial AserialIOFuncLib SSD1306 TerminalPlusV2
Fork of SerialIO by
Console Serial IO con display OLED e seriale asincrona
Diff: Functions.h
- Revision:
- 38:d88296cbb39c
- Parent:
- 37:befd2fe96ee3
- Child:
- 39:0d7165083e7a
--- a/Functions.h Fri Nov 06 22:31:17 2015 +0000 +++ b/Functions.h Thu Dec 24 01:38:56 2015 +0000 @@ -2,6 +2,9 @@ #include "IOFuncLib.h" #include "choiceFunctions.h" +//Valori di Menu +int p01, p02, p03; +int p51, p52; void bannerAdv() { @@ -11,58 +14,62 @@ term.frame(0, 0, 79, 22,1); term.forgcol(3); term.bold(); - term.formatPrintf("_____ Glass Project Console _____\n",22,1); - term.formatPrintf("___ Nucleo Scorda IO Terminal ___\n",22,2); + term.formatPrintf("_____ H-Ard Synth Project Console _____\n",19,1); + term.formatPrintf("______ Nucleo Scorda IO Terminal ______\n",19,2); term.resetattrib(); term.forgcol(7); //3-4 term.formatPrintf(fnzAdd.string2char(fnzAdd.padstr("\n",78,char(196))),1,3,1); //top 1/2 term.forgcol(6); - term.formatPrintf("Funzione \n",2,4); //p01 - term.formatPrintf("Numero \n",32,4); //p02 - term.formatPrintf("Parametro \n",51,4); //p03 -//5-6 + /* + //5-6 term.formatPrintf("Pattern 0......... \n",2,6); //p11 term.formatPrintf("Pattern 1......... \n",42,6); //p12 -//7-8 + //7-8 term.formatPrintf("Pattern 2......... \n",2,8); //p21 term.formatPrintf("Random Act (r1o/f) \n",42,8); //p22 -//9-10 + //9-10 term.formatPrintf("Serial Real(sro/f) \n",2,10); //p31 -//11-12 + //11-12 term.formatPrintf("Note Pattern......\n",2,12,99); //p41 -//13-14 - term.formatPrintf("Input string...... \n",2,14); //p51 - term.formatPrintf("Command Type...... \n",42,14); //p52 -//15-16 + */ +//18-19 + p51=18; + p52=18; + term.formatPrintf("Input string...... \n",2,p51); //p51 + term.formatPrintf("Command Type \n",48,p52); //p52 + p01=19; + p02=19; + p03=19; + term.formatPrintf("Funzione \n",2,p01); //p01 + term.formatPrintf("Numero \n",32,p02); //p02 + term.formatPrintf("Parametro \n",51,p03); //p03 +//21 term.forgcol(7); term.formatPrintf("Serial Feedback \n",2,21); // grigino + /* + term.formatPrintf(fnzAdd.string2char(fnzAdd.padstr("\n",78,char(196))),1,5); //top 3/4 + term.formatPrintf(fnzAdd.string2char(fnzAdd.padstr("\n",78,char(196))),1,9); //top 7/8 + term.formatPrintf(fnzAdd.string2char(fnzAdd.padstr("\n",78,char(196))),1,13); //top 11/12 - term.formatPrintf(fnzAdd.string2char(fnzAdd.padstr("\n",78,char(196))),1,5); //top 3/4 - term.formatPrintf(fnzAdd.string2char(fnzAdd.padstr("\n",78,char(196))),1,9); //top 7/8 - term.formatPrintf(fnzAdd.string2char(fnzAdd.padstr("\n",78,char(196))),1,13); //top 11/12 - term.formatPrintf(fnzAdd.string2char(fnzAdd.padstr("\n",78,char(196))),1,15,1); //bottom pot - term.formatPrintf(fnzAdd.string2char(fnzAdd.padstr("\n",78,char(196))),1,20); //azzo funziona... + - term.forgcol(2); - term.formatPrintf("Pattern: da 031 a 252 - Traccia 0-2, Note 3-6, Len 1-2 \n",2,16); //help - term.formatPrintf("Stato random: r1on-r1off \n",2,17); //help - term.formatPrintf("Cambia Note: da n01 a n53 - Nota 0-5, Val 1-3 \n",2,18); //help - term.formatPrintf("start, stop, dstop (delay) - rl: reload value\n",2,19); //help - term.forgcol(7); + term.forgcol(2); + term.formatPrintf("Pattern: da 031 a 252 - Traccia 0-2, Note 3-6, Len 1-2 \n",2,16); //help + term.formatPrintf("Stato random: r1on-r1off \n",2,17); //help + term.formatPrintf("Cambia Note: da n01 a n53 - Nota 0-5, Val 1-3 \n",2,18); //help + term.formatPrintf("start, stop, dstop (delay) - rl: reload value\n",2,19); //help + term.forgcol(7); + */ + term.formatPrintf(fnzAdd.string2char(fnzAdd.padstr("\n",78,char(196))),1,17,1); //bottom pot + term.formatPrintf(fnzAdd.string2char(fnzAdd.padstr("\n",78,char(196))),1,20); //azzo funziona... term.locate(0, 23); printf("Command: > "); - // extra da attivare forse - // formatPrintf("Pattern \n",2,5); - // formatPrintf(string2char(padstr("\n",78,char(196))),1,7); //top 5/6 - // formatPrintf(string2char(padstr("\n",78,char(196))),1,11); //top 9/10 - // formatPrintf("Serial \n",2,9); - // formatPrintf("HELP \n",2,15); //help } @@ -96,36 +103,35 @@ funcnum=strIn.substr(1,1); param=strIn.substr(2,3); //write param - term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS(func)),11,4,10,1); //p01 - term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS(funcnum)),39,4,10,1); //p02 - term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS(param)),61,4,10,1); //p03 + term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS(func)),11,p01,10,1); //p01 + term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS(funcnum)),39,p02,10,1); //p02 + term.formatPrintf(fnzAdd.string2char(fnzAdd.addEOS(param)),61,p03,10,1); //p03 //write input string - term.formatPrintf(fnzAdd.string2char(strIn),21,14,10,1); //p51 + term.formatPrintf(fnzAdd.string2char(strIn),21,p51,10,1); //p51 //term.formatPrintf(((char*)func.c_str() ,02,07); funziona anche cosi' - //extra serial output (output reale su arduino default true) - if ((func=="s") && (funcnum=="r") ) { - errp=Sfunc(func, funcnum,param); + //command Cambia Funzione + if (func=="f") { + errp=funcOut(func, funcnum,param, string(stringa)); } - //Random Activate - else if (func=="r") { - errp=RfuncOut(func, funcnum,param); + //init: al boot chiedi ad arduino i codici + else if (func=="i") { + errp=initFunc(func, funcnum,param); } - //led for test else if (func=="l") { errp=Lfunc(func, funcnum,param); } - //command SYNTH Tracce - else if ((func>="0") && (func<="9")) { - errp=s09funcOut(func, funcnum,param,stringa[0]); + //command Cambia menu + else if (func=="m") { + errp=menuOut(func, funcnum,param, string(stringa)); } - //command SYNTH Note - else if (func=="n") { - errp=NfuncOut(func, funcnum,param, stringa); + //Random Activate DA FARE!!!!!!!!! + else if (func=="r") { + errp=RfuncOut(func, funcnum,param); } //start @@ -138,21 +144,16 @@ errp=StopfuncOut(); } - //delay stop - else if (strIn.substr(0,5)=="dstop") { - errp=DelayStopfuncOut(); - } - // comando fuori parsing if (errp==1) { term.forgcol(1); - term.formatPrintf("Bad Command\n",61,14,99,1); //p52 + term.formatPrintf("Bad Command\n",61,p52,99,1); //p52 term.forgcol(9); if (realExtraSerial==false) ardser.printf("Bad command\n\r"); printDisp(dispType,"** Bad command ** \n\r"); } - + term.readypos(); } @@ -164,26 +165,20 @@ string param; //parametro on, off string strIn = string(stringa); bool errp=1; - //pad a 4 - strIn=fnzAdd.padstr(strIn,5,' '); + strIn=fnzAdd.padstr(strIn,5,' '); //non dovrebbe servire strIn=fnzAdd.addEOS(strIn); //split func=strIn.substr(0,1); funcnum=strIn.substr(1,1); param=strIn.substr(2,3); - //Random Activate - if (func=="r") { - errp=RfuncIn(func, funcnum,param); + //Descrizione Menu in input + if (func=="m") { + errp=menuIn(func, stringa); } - //command SYNTH Tracce - else if ((func>="0") && (func<="9")) { - errp=s09funcIn(func, funcnum,param,stringa[0]); - //ardser.printf(strIn+" \n\r"); - } - //command SYNTH Note - else if (func=="n") { - errp=NfuncIn(func, funcnum,param, stringa); + //Descrizione funzione in input + else if (func=="f") { + errp=functionIn(func, stringa); } //start else if (strIn.substr(0,4)=="start") { @@ -194,16 +189,6 @@ errp=StopfuncIn(); } - //delay stop - else if (strIn.substr(0,4)=="dstop") { - errp=DelayStopfuncIn(); - } - - //Boot - else if (strIn.substr(0,4)=="boot") { - errp=bootfuncIn(); - } - term.formatPrintf(fnzAdd.string2char(">"+fnzAdd.subEOS(string(stringa))+"<"),18,21,99,1); term.readypos(); } @@ -215,7 +200,20 @@ string param; //parametro on, off string strIn; + //azzero vettori + for (int i = 0; i < 10; i++) { + menu_main[i]=""; + menu_funcChoice[i]=""; + } + for (int i = 0; i < 100; i++) { + menu_function[i]=""; + } + menu_main[0]="z.z"; //invero e' sbagliato. controllare cosa usa di stop + menu_funcChoice[0]="z.z"; + menu_function[0]="z.z"; + //pattern + /* for (int i = 0; i < 3; i++) { strIn=fnzAdd.i2s(i)+"-"+fnzAdd.i2s(i+3)+"-"+fnzAdd.i2s(2); term.formatPrintf(fnzAdd.string2char(strIn),21+(i%2)*40,6+(2*(i/2)),8,1); //p11 //p12 //p21 @@ -226,6 +224,7 @@ term.formatPrintf("ON\n",61,8,99,1); //p22 // note term.formatPrintf("60 64 67 71 74 77\n",21,12,99,1); //p41 + */ term.readypos(); } @@ -234,8 +233,8 @@ void pressed() { ardser.printf("rl\r"); - term.formatPrintf("rl\n",21,14,8,1); //p51 - term.formatPrintf("Ask for reload\n",61,14,99,1); //p52 + term.formatPrintf("rl\n",21,p51,8,1); //p51 + term.formatPrintf("Ask for reload\n",61,p52,99,1); //p52 led.flash(2); }