
Código para o menu no LCD
Dependencies: mbed SDFileSystemSD TextLCD
Fork of TextLCD_HelloWorld2 by
Revision 27:83d2a710cc2f, committed 2018-05-17
- Comitter:
- claraluques
- Date:
- Thu May 17 22:38:03 2018 +0000
- Parent:
- 26:59081efdce79
- Child:
- 28:b3c51076ebe8
- Commit message:
- estamos com as telas de espera do programa funcionando, por?m nos prints nao pode ter wait.; ; criar variavel de tempo para contar
Changed in this revision
classes.h | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/classes.h Wed May 16 16:49:45 2018 +0000 +++ b/classes.h Thu May 17 22:38:03 2018 +0000 @@ -73,11 +73,9 @@ } void set_zero(string axis){ - buffer = ""; - + buffer = ""; buffer.append("z"); buffer+=axis; - send(buffer); } @@ -163,77 +161,77 @@ //x if (cx<=-1 && cx>=-9){ lcd.locate(2,1); - lcd.printf(" %.2f", cx); + lcd.printf(" %.2f ", cx); } if (cx<=-10 && cx>=-99){ lcd.locate(2,1); - lcd.printf(" %.2f", cx); + lcd.printf(" %.2f ", cx); } if (cx<=-100){ lcd.locate(2,1); - lcd.printf("%.2f", cx); + lcd.printf("%.2f ", cx); } if (cx<=9 && cx>=0){ lcd.locate(2,1); - lcd.printf(" %.2f", cx); + lcd.printf(" %.2f ", cx); } if (cx>=10 && cx<=99){ lcd.locate(2,1); - lcd.printf(" %.2f", cx); + lcd.printf(" %.2f ", cx); } if (cx>=100){ lcd.locate(2,1); - lcd.printf(" %.2f", cx); + lcd.printf(" %.2f ", cx); } //y if (cy<=-1 && cy>=-9){ lcd.locate(2,2); - lcd.printf(" %.2f", cy); + lcd.printf(" %.2f ", cy); } if (cy<=-10 && cx>=-99){ lcd.locate(2,2); - lcd.printf(" %.2f", cy); + lcd.printf(" %.2f ", cy); } if (cy<=-100){ lcd.locate(2,2); - lcd.printf("%.2f", cy); + lcd.printf("%.2f ", cy); } if (cy<=9 && cy>=0){ lcd.locate(2,2); - lcd.printf(" %.2f", cy); + lcd.printf(" %.2f ", cy); } if (cy>=10 && cx<=99){ lcd.locate(2,2); - lcd.printf(" %.2f", cy); + lcd.printf(" %.2f ", cy); } if (cy>=100){ lcd.locate(2,2); - lcd.printf(" %.2f", cy); + lcd.printf(" %.2f ", cy); } //z if (cz<=-1 && cz>=-9){ lcd.locate(2,3); - lcd.printf(" %.2f", cz); + lcd.printf(" %.2f ", cz); } if (cz<=-10 && cx>=-99){ lcd.locate(2,3); - lcd.printf(" %.2f", cz); + lcd.printf(" %.2f ", cz); } if (cz<=-100){ lcd.locate(2,3); - lcd.printf("%.2f", cz); + lcd.printf("%.2f ", cz); } if (cz<=9 && cz>=0){ lcd.locate(2,3); - lcd.printf(" %.2f", cz); + lcd.printf(" %.2f ", cz); } if (cz>=10 && cx<=99){ lcd.locate(2,3); - lcd.printf(" %.2f", cz); + lcd.printf(" %.2f ", cz); } if (cz>=100){ lcd.locate(2,3); - lcd.printf(" %.2f", cz); + lcd.printf(" %.2f ", cz); } } //até aqui, para alinhar os números if (Mach.readable()){ @@ -329,6 +327,7 @@ } } else if (linha==2) { + machine.kill_jog(); func = 17; } else if (linha==3) { @@ -365,6 +364,7 @@ void config() { lcd.cls(); bot_enter = 0; + //printf("%d,tela\n\r", penter); lcd.locate(1,0); lcd.printf("Definir velocidade"); lcd.locate(1,1); @@ -382,7 +382,8 @@ func = 14; } else if (linha==2) { - func = 15; + home = 1; + func = 18; } else if (linha==3) { func = 1; @@ -466,7 +467,7 @@ if (linha==2){ machine.kill_jog(); wait(0.1); - machine.start_program(); + //machine.start_program(); exec = 1; func = 9; } @@ -526,10 +527,13 @@ //func 9 void executando(){ //tela de executando lcd.cls(); + machine.start_program(); lcd.locate(4,1); lcd.printf("Executando"); - int contador = 0; - while (exec==1){ + while (exec == 1){ + if (Mach.readable()){ + readSerial(); + }/* lcd.locate(14,1); lcd.printf(". "); wait(0.5); @@ -541,13 +545,10 @@ wait(0.5); lcd.locate(14,1); lcd.printf(" "); - wait(0.5); - contador++; - if (contador>=2){ - exec = 0; - func = 11; - } + wait(0.5);*/ } + printf("saiu\n\r"); + func = 11; } //func 10 @@ -579,6 +580,16 @@ //func 14 //func 15 + void gohome(){ + lcd.cls(); + machine.machine_zero(); + while (home == 1){ + if (Mach.readable()){ + readSerial(); + } + } + func = 19; + } //func 16 void limitepontos(){ //tela para quando acabam os pontos @@ -613,6 +624,34 @@ } } } + + //func 18 + void ctzhome(){ + lcd.cls(); + bot_enter = 0; + lcd.printf("Certifique-se de que a maquina pode se"); + lcd.locate(5,2); + lcd.printf("movimentar"); + lcd.locate(9,3); + lcd.printf("OK"); + movercursor(3,3,8); + if (bot_enter!=penter){ + if (linha==3){ + func = 15; + } + } + } + + //func 19 + void origem(){ + lcd.cls(); + lcd.locate(5,1); + lcd.printf("A MAQUINA"); + lcd.locate(2,2); + lcd.printf("ESTA NA ORIGEM"); + wait(1); + func = 4; + } //função para ler os pontos void readSerial(){ @@ -621,6 +660,7 @@ int pointx = 0; int pointy = 0; int pointz = 0; + int action = 0; string coordx = ""; string coordy = ""; string coordz = ""; @@ -628,11 +668,12 @@ while(1){ recv = Mach.getc(); - // printf("%c\n\r", recv); - if (recv == 'a'){ + printf("%c\n\r", recv); + if (recv == 'a' /*&& points == 0*/){ + home = 0; + exec = 0; printf("oi\n\r"); - wait(0.1); - break; + action = 1; } if (recv == 'p'){ points = 1; @@ -676,7 +717,11 @@ coordz.push_back(recv); } } - + if (action){ + if (recv=='x'){ + break; + } + } } }
--- a/main.cpp Wed May 16 16:49:45 2018 +0000 +++ b/main.cpp Thu May 17 22:38:03 2018 +0000 @@ -81,9 +81,11 @@ case 9: menu.executando(); break; case 10: menu.zerado(); break; case 11: menu.finalizado(); break; - //case 15: menu.gohome(); break; + case 15: menu.gohome(); break; case 16: menu.limitepontos(); break; case 17: menu.salvarprog(); break; + case 18: menu.ctzhome(); break; + case 19: menu.origem(); break; } } } @@ -92,7 +94,7 @@ void botenter_press(void){ penter = bot_enter; bot_enter = !bot_enter; - //printf("enter high"); + //printf("enter high\n\r"); } //função interrupt botão cima