
Código para o menu no LCD
Dependencies: mbed SDFileSystemSD TextLCD
Fork of TextLCD_HelloWorld2 by
Revision 31:77eb51d4ee18, committed 2018-05-22
- Comitter:
- claraluques
- Date:
- Tue May 22 18:49:32 2018 +0000
- Parent:
- 30:614dcbd74cdc
- Child:
- 32:c293f89170b0
- Commit message:
- na tela de sele??o de nome, est? apertando duas vezes os botoes!
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 22 13:58:18 2018 +0000 +++ b/classes.h Tue May 22 18:49:32 2018 +0000 @@ -299,7 +299,7 @@ lcd.locate(col,min); lcd.printf("%c", 0x3E); while (bot_enter==penter){ - if (bot_cima==1){ + if (bot_cima==0){ if (linha==min){ lcd.locate(col,min); lcd.printf(" "); @@ -314,9 +314,9 @@ lcd.locate(col, linha); lcd.printf("%c", 0x3E); } - bot_cima = 0; + bot_cima = 1; } - else if (bot_baixo==1){ + else if (bot_baixo==0){ if (linha==max){ lcd.locate(col,max); lcd.printf(" "); @@ -331,10 +331,10 @@ lcd.locate(col, linha); lcd.printf("%c", 0x3E); } - bot_baixo = 0; + bot_baixo = 1; } //função para printar as coordenadas nas telas 2 e 8 - else if (func==2 || func==8){ + /*else if (func==2 || func==8){ //x if (cx<=-1 && cx>=-9){ lcd.locate(2,1); @@ -413,7 +413,7 @@ } //até aqui, para alinhar os números if (Mach.readable()){ readSerial(); - } + }*/ } } @@ -447,7 +447,7 @@ //func 1 void menuprincipal(){ //função menu principal - bot_enter = 0; + bot_enter = penter; lcd.cls(); lcd.locate(1,0); lcd.printf("Modo JOG"); @@ -476,11 +476,11 @@ //func 2 void jog(){ //função tela jog - bot_enter = 0; + lcd.cls(); + bot_enter = penter; machine.kill_jog(); wait(0.1); machine.jog(); - lcd.cls(); lcd.locate(4,0); lcd.printf("Coordenadas:"); lcd.locate(0,1); @@ -498,7 +498,7 @@ movercursor(1,3,10); if (bot_enter!=penter){ if (linha==1){ - if (pontos==0 && maxpontos>=1){ + /*if (pontos==0 && maxpontos>=1){ cx_salva = 0; cy_salva = 0; cz_salva = 0; @@ -510,13 +510,13 @@ cx_salva = cx; cy_salva = cy; cz_salva = cz; - pontos++; + */pontos++; maxpontos--; - func = 5; + func = 5;/* } else if (maxpontos==0){ func = 16; - } + }*/ } else if (linha==2) { machine.kill_jog(); @@ -535,7 +535,7 @@ //func 3 void automatico(){ //tela modo automatico lcd.cls(); - bot_enter = 0; + bot_enter = penter; lcd.printf("Modo automatico"); lcd.locate(7,2); lcd.printf("OK"); @@ -555,7 +555,7 @@ //func 4 void config() { lcd.cls(); - bot_enter = 0; + bot_enter = penter; //printf("%d,tela\n\r", penter); lcd.locate(1,0); lcd.printf("Definir velocidade"); @@ -612,7 +612,7 @@ //func 6 void telacola(){ //tela para escolher o tipo de sequencia da cola lcd.cls(); - bot_enter = 0; + bot_enter = penter; lcd.printf("P/ o proximo ponto:"); lcd.locate(3,1); lcd.printf("Sem cola"); @@ -641,7 +641,7 @@ //func 7 void executarprograma() { //tela para selecionar se deseja executar o programa lcd.cls(); - bot_enter = 0; + bot_enter = penter; lcd.locate(2,0); lcd.printf("VOCE CONCLUIU SEU"); lcd.locate(5,1); @@ -673,7 +673,7 @@ //func 8 void telazerar(){ //tela para zerar a máquina lcd.cls(); - bot_enter = 0; + bot_enter = penter; machine.kill_jog(); machine.jog(); lcd.locate(2,0); @@ -798,7 +798,7 @@ //func 17 void salvarprog(){ lcd.cls(); - bot_enter = 0; + bot_enter = penter; lcd.printf("Voce deseja salvar este programa?"); lcd.locate(5,2); lcd.printf("Sim"); @@ -809,11 +809,11 @@ if (linha==2){ salvar = 1; printf("salvar\n\r"); - //func = 20; + func = 20; } if (linha==3){ salvar = 0; - //func = 7; + func = 7; } } } @@ -821,7 +821,7 @@ //func 18 void ctzhome(){ lcd.cls(); - bot_enter = 0; + bot_enter = penter; lcd.printf("Certifique-se de que a maquina pode se"); lcd.locate(5,2); lcd.printf("movimentar"); @@ -849,7 +849,7 @@ //func 20 void nomeprog(){ lcd.cls(); - bot_enter = 0; + bot_enter = penter; lcd.printf("oieeee"); printf("tela\n\r"); escrever(3); @@ -867,27 +867,26 @@ int imin = 0; int i = 0; printf("entrou\n\r"); - //while (){ - while (bot_enter==penter){ - if (bot_cima == 1){ - if (i==imin){ - i = imax; - } - else if (i>imin && i<=imax){ + while (bot_enter==penter){ + if (bot_cima == 0){ + if (i==imin){ + i = imax; + } + else if (i>imin && i<=imax){ i--; - } - bot_cima = 0; } - else if (bot_baixo == 1){ - if (i==imax){ - i = imin; - } - else if (i<imax && i>=imin){ - i++; - } - bot_baixo = 0; - } - // } + bot_cima = 1; + } + else if (bot_baixo == 0){ + if (i==imax){ + i = imin; + } + else if (i<imax && i>=imin){ + i++; + } + bot_baixo = 1; + } + lcd.locate(coluna, 1); lcd.printf("%c", alfabeto[i]); //lcd.printf("oi");
--- a/main.cpp Tue May 22 13:58:18 2018 +0000 +++ b/main.cpp Tue May 22 18:49:32 2018 +0000 @@ -14,19 +14,19 @@ //Botão push InterruptIn botao_enter(D13); -InterruptIn botao_cima(D10); +InterruptIn botao_cima(D12); InterruptIn botao_baixo(D9); //LCD instantiation TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); //não apagar //variáveis int -int bot_enter; -int bot_cima; -int bot_baixo; -int penter = 0; -int pcima = 0; -int pbaixo = 0; +int bot_enter = 0; +int bot_cima = 0; +int bot_baixo = 0; +int penter = 1; +int pcima = 1; +int pbaixo = 1; int cola; int exec; int select = 0; @@ -65,9 +65,9 @@ lcd.setBacklight(TextLCD::LightOn); //liga backlight lcd.setCursor(TextLCD::CurOff_BlkOff); //define tipo de cursor - botao_enter.rise(&botenter_press); //chama função botao enter - botao_cima.rise(&botcima_press); //chama função botao para cima - botao_baixo.rise(&botbaixo_press); //chama função bota para baixo + botao_enter.fall(&botenter_press); //chama função botao enter + botao_cima.fall(&botcima_press); //chama função botao para cima + botao_baixo.fall(&botbaixo_press); //chama função bota para baixo while(1){ switch(menu.func){ //faz com que as telas sejam iniciadas @@ -97,7 +97,7 @@ void botenter_press(void){ penter = bot_enter; bot_enter = !bot_enter; - printf("enter high\n\r"); + printf("%d, %d, enter high\n\r", penter, bot_enter); } //função interrupt botão cima