
Código para o menu no LCD
Dependencies: mbed SDFileSystemSD TextLCD
Fork of TextLCD_HelloWorld2 by
Revision 26:59081efdce79, committed 2018-05-16
- Comitter:
- claraluques
- Date:
- Wed May 16 16:49:45 2018 +0000
- Parent:
- 25:af1f99666ca9
- Child:
- 27:83d2a710cc2f
- Commit message:
- jog funcionando, sem home ou exec (nao est? recebendo "a");
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 Tue May 15 19:47:37 2018 +0000 +++ b/classes.h Wed May 16 16:49:45 2018 +0000 @@ -69,7 +69,7 @@ } void machine_zero(void){ - send("mz"); + send("zm"); } void set_zero(string axis){ @@ -91,6 +91,10 @@ printf("jk\n\r"); } + void reset (void){ + send("r"); + } + private: @@ -154,22 +158,22 @@ } bot_baixo = 0; } + //função para printar as coordenadas nas telas 2 e 8 else if (func==2 || func==8){ - if (cx<0){ - if (cx<=-1){ - lcd.locate(2,1); - lcd.printf(" %.2f", cx); - } - if (cx<=-10 && cx>=-99){ - lcd.locate(2,1); - lcd.printf(" %.2f", cx); - } - if (cx<=-100){ - lcd.locate(2,1); - lcd.printf("%.2f", cx); - } + //x + if (cx<=-1 && cx>=-9){ + lcd.locate(2,1); + lcd.printf(" %.2f", cx); + } + if (cx<=-10 && cx>=-99){ + lcd.locate(2,1); + lcd.printf(" %.2f", cx); + } + if (cx<=-100){ + lcd.locate(2,1); + lcd.printf("%.2f", cx); } - if (cx<=9){ + if (cx<=9 && cx>=0){ lcd.locate(2,1); lcd.printf(" %.2f", cx); } @@ -181,21 +185,20 @@ lcd.locate(2,1); lcd.printf(" %.2f", cx); } - if (cy<0){ - if (cy<=-1){ - lcd.locate(2,2); - lcd.printf(" %.2f", cy); - } - if (cy<=-10 && cx>=-99){ - lcd.locate(2,2); - lcd.printf(" %.2f", cy); - } - if (cy<=-100){ - lcd.locate(2,2); - lcd.printf("%.2f", cy); - } + //y + if (cy<=-1 && cy>=-9){ + lcd.locate(2,2); + lcd.printf(" %.2f", cy); + } + if (cy<=-10 && cx>=-99){ + lcd.locate(2,2); + lcd.printf(" %.2f", cy); + } + if (cy<=-100){ + lcd.locate(2,2); + lcd.printf("%.2f", cy); } - if (cy<=9){ + if (cy<=9 && cy>=0){ lcd.locate(2,2); lcd.printf(" %.2f", cy); } @@ -207,21 +210,20 @@ lcd.locate(2,2); lcd.printf(" %.2f", cy); } - if (cz<0){ - if (cz<=-1){ - lcd.locate(2,3); - lcd.printf(" %.2f", cz); - } - if (cz<=-10 && cx>=-99){ - lcd.locate(2,3); - lcd.printf(" %.2f", cz); - } - if (cz<=-100){ - lcd.locate(2,3); - lcd.printf("%.2f", cz); - } - } - if (cz<=9){ + //z + if (cz<=-1 && cz>=-9){ + lcd.locate(2,3); + lcd.printf(" %.2f", cz); + } + if (cz<=-10 && cx>=-99){ + lcd.locate(2,3); + lcd.printf(" %.2f", cz); + } + if (cz<=-100){ + lcd.locate(2,3); + lcd.printf("%.2f", cz); + } + if (cz<=9 && cz>=0){ lcd.locate(2,3); lcd.printf(" %.2f", cz); } @@ -233,22 +235,17 @@ lcd.locate(2,3); lcd.printf(" %.2f", cz); } - } - /*} - - lcd.locate(2,2); - lcd.printf("%.2f", cy); - lcd.locate(2,3); - lcd.printf("%.2f", cz); - }*/ + } //até aqui, para alinhar os números if (Mach.readable()){ readSerial(); } } + } //func 0 void inicializar(){ //função tela incial de boas-vindas + machine.reset(); lcd.cls(); lcd.locate(4,0); lcd.printf("Bem-vindo(a)"); @@ -267,9 +264,9 @@ lcd.locate(1,1); lcd.printf("Modo Automatico"); lcd.locate(1,2); - lcd.printf("Config"); + lcd.printf("Zerar"); lcd.locate(1,3); - lcd.printf("Zerar"); + lcd.printf("Config"); movercursor(0,3,0); if (bot_enter!=penter){ if (linha==0){ @@ -279,10 +276,10 @@ func = 3; } else if (linha==2) { - func = 4; + func = 8; } else if (linha==3) { - func = 8; + func = 4; } } } @@ -311,22 +308,33 @@ movercursor(1,3,10); if (bot_enter!=penter){ if (linha==1){ - if (pontos>0){ - pontos--; + if (pontos==0 && maxpontos>=1){ + cx_salva = 0; + cy_salva = 0; + cz_salva = 0; + pontos++; + maxpontos--; + func = 5; + } + else if (pontos>=1 && maxpontos>=1){ cx_salva = cx; cy_salva = cy; cz_salva = cz; + pontos++; + maxpontos--; func = 5; } - else if (pontos==0){ + else if (maxpontos==0){ func = 16; } } else if (linha==2) { - func = 7; + func = 17; } else if (linha==3) { machine.kill_jog(); + wait(0.1); + machine.cancel_program(); func = 1; pontos = 10; } @@ -362,7 +370,7 @@ lcd.locate(1,1); lcd.printf("Limpar seringa cola"); lcd.locate(1,2); - lcd.printf("Desligar a maquina"); + lcd.printf("Origem maquina"); lcd.locate(1,3); lcd.printf("Voltar"); movercursor(0,3,0); @@ -398,7 +406,7 @@ lcd.locate(13,2); lcd.printf("livres"); lcd.locate(16,3); - lcd.printf("%d", pontos); + lcd.printf("%d", maxpontos); wait(1); if (pontos>0){ func = 6; @@ -473,6 +481,8 @@ void telazerar(){ //tela para zerar a máquina lcd.cls(); bot_enter = 0; + machine.kill_jog(); + machine.jog(); lcd.locate(2,0); lcd.printf("Zerar:"); lcd.locate(0,1); @@ -508,6 +518,7 @@ } else if (linha==3){ func = 1; + machine.kill_jog(); } } } @@ -572,13 +583,38 @@ //func 16 void limitepontos(){ //tela para quando acabam os pontos lcd.cls(); - lcd.printf(" Voce atingiu o n%c maximo de pontos.", 0xDF); + lcd.printf(" Voce atingiu o n%c maximo de pontos", 0xDF); + lcd.locate(9,2); + lcd.printf("(%d)", pontos); lcd.locate(0,3); lcd.printf("Conclua seu programa"); wait(1); func = 2; } - + + //func 17 + void salvarprog(){ + lcd.cls(); + bot_enter = 0; + lcd.printf("Voce deseja salvar este programa?"); + lcd.locate(5,2); + lcd.printf("Sim"); + lcd.locate(5,3); + lcd.printf("Nao"); + movercursor(2,3,4); + if (bot_enter!=penter){ + if (linha==2){ + salvar = 1; + func = 7; + } + if (linha==3){ + salvar = 0; + func = 7; + } + } + } + + //função para ler os pontos void readSerial(){ char recv; int points = 0; @@ -588,10 +624,16 @@ string coordx = ""; string coordy = ""; string coordz = ""; + while(1){ recv = Mach.getc(); - //printf("%c\n\r", recv); + // printf("%c\n\r", recv); + if (recv == 'a'){ + printf("oi\n\r"); + wait(0.1); + break; + } if (recv == 'p'){ points = 1; } @@ -638,6 +680,7 @@ } } + Menu(); //não apagar }; \ No newline at end of file
--- a/main.cpp Tue May 15 19:47:37 2018 +0000 +++ b/main.cpp Wed May 16 16:49:45 2018 +0000 @@ -28,7 +28,10 @@ int cola; int exec; int select = 0; -int pontos = 10; +int pontos = 0; +int salvar = 0; +int maxpontos = 5; +int home; //variáveis float float cx = 120.458; @@ -78,7 +81,9 @@ case 9: menu.executando(); break; case 10: menu.zerado(); break; case 11: menu.finalizado(); break; + //case 15: menu.gohome(); break; case 16: menu.limitepontos(); break; + case 17: menu.salvarprog(); break; } } }