Projeto Mecatrônico
/
ProjetoMecatronico
testando
Diff: main_PM.cpp
- Revision:
- 56:e748b9bd5e3c
- Parent:
- 55:4d071fb49f24
- Child:
- 57:e26deee15b8f
--- a/main_PM.cpp Sat May 30 19:57:40 2020 +0000 +++ b/main_PM.cpp Sat May 30 21:20:23 2020 +0000 @@ -91,7 +91,6 @@ //Funcao de interrupcao void emergencia(){TextLCD lcd(D4, D5, D6, D7, D8, D9); - //while(interrupcao == 0){ rele1 = 0; eixox = 0b0000; eixoy = 0b0000; @@ -103,7 +102,7 @@ lcd.locate(0,2); lcd.printf("Operacao pausada"); wait(5);} - //} + //Funcao de zeramento void zeramento(){ while (fdc_x != 0){for(int i = 0; i < 4; i++){eixox = hor[i];wait(t_motor);est_x = 1;}} @@ -137,6 +136,7 @@ float pos_y_solta=0; int main() { + interrupcao.fall(&emergencia); int volume; bool continuar; int multiplicador; @@ -156,8 +156,7 @@ lcd.locate(0,2); lcd.printf("sistema"); lcd.locate(0,3); - lcd.printf("A - proximo"); - interrupcao.fall(&emergencia); + lcd.printf("A - proximo"); while(1) { tecla = pega_tecla(); printf("\n%s",status_tela); @@ -395,6 +394,8 @@ funcao_inicio(); status_tela = "inicio";} + tecla = 'F'; + wait(1); tecla = pega_tecla(); if(tecla == '1' && status_tela == "forma"){ funcao_pega_forma_quad(); @@ -402,30 +403,32 @@ status_tela ="forma_quad";} else if(tecla == '2' && status_tela == "forma"){ funcao_pega_forma_red(); + tipo_pega = 2; status_tela = "forma_red";} else if(tecla == 'B' && status_tela == "forma"){ - funcao_pega_forma(); + funcao_pega1(); + wait(1); + funcao_pega2(); status_tela = "novo";} tecla = pega_tecla(); if(tecla == 'A' && status_tela == "forma_quad"){ funcao_pega1(); medida_lado_pega = 10; - lcd.locate(18,2);lcd.printf("OK"); + lcd.locate(18,1);lcd.printf("OK"); wait(1); funcao_pega2(); - status_tela ="inicio";} + status_tela ="novo";} else if(tecla == 'B' && status_tela == "forma_quad"){ funcao_pega_forma(); status_tela = "forma";} else if(tecla == 'A' && status_tela == "forma_red"){ medida_lado_pega = 10; - tipo_pega = 2; funcao_pega1(); - lcd.locate(18,2);lcd.printf("OK"); + lcd.locate(18,1);lcd.printf("OK"); wait(1); funcao_pega2(); - status_tela ="inicio";} + status_tela ="novo";} else if(tecla == 'B' && status_tela == "forma_red"){ funcao_pega_forma(); status_tela = "forma";} @@ -435,7 +438,7 @@ lcd.locate(18,2);lcd.printf("OK"); wait(1); funcao_pega2(); - status_tela ="inicio";} + status_tela ="novo";} else if( tecla == 'B' && status_tela == "volume"){ funcao_pega_forma(); status_tela = "forma";} @@ -452,21 +455,21 @@ funcao_pega1(); wait(1); funcao_pega2(); - lcd.locate(18,2);lcd.printf("OK"); - status_tela ="inicio";} + lcd.locate(18,1);lcd.printf("OK"); + wait(1); + status_tela ="novo";} else if(tecla == 'B' && status_tela == "pos_y"){ funcao_pega_forma(); status_tela = "forma";} tecla=pega_tecla(); - if(pos_x_pega!=0 && pos_y_pega!=0 && medida_lado_pega!=0 && volume_pega !=0 && tipo_pega!=0 && status_tela == "inicio"){ + if(pos_x_pega!=0 && pos_y_pega!=0 && medida_lado_pega!=0 && volume_pega !=0 && tipo_pega!=0 && status_tela == "novo"){ funcao_solta1(); wait(3); funcao_solta2(); wait(3); - status_tela="solta"; - } + status_tela="solta";} tecla=pega_tecla(); if(tecla == '1' && status_tela == "solta"){ @@ -524,12 +527,12 @@ wait(3); status_tela="solta"; } - if(tecla=='A' && status_tela=="funcao_solta_pos_x"){ + if(tecla=='A' && status_tela=="solta_pos_x"){ funcao_solta_pos_y(); pos_x_solta = 10; - status_tela="funcao_solta_pos_y"; + status_tela="solta_pos_y"; } - else if(tecla=='B' && status_tela=="funcao_solta_pos_x"){ + else if(tecla=='B' && status_tela=="solta_pos_x"){ funcao_solta1(); wait(3); funcao_solta2(); @@ -554,47 +557,46 @@ wait(3); funcao_solta2(); wait(3); - status_tela="solta"; - } + status_tela="solta";} else if(tecla=='B' && status_tela=="solta_vol_igual"){ funcao_solta_vol(); status_tela="solta_vol"; } if(tecla=='1' && status_tela=="solta_vol_dif"){ volume_solta_1=10; - lcd.locate(12,1);lcd.printf("10"); + lcd.locate(12,0);lcd.printf("10"); } if(tecla=='2' && status_tela=="solta_vol_dif"){ volume_solta_2=20; - lcd.locate(15,1);lcd.printf("20"); + lcd.locate(15,0);lcd.printf("20"); } if(tecla=='3' && status_tela=="solta_vol_dif"){ volume_solta_3=30; - lcd.locate(18,1);lcd.printf("30"); + lcd.locate(18,0);lcd.printf("30"); } if(tecla=='4' && status_tela=="solta_vol_dif"){ volume_solta_4=40; - lcd.locate(12,2);lcd.printf("40"); + lcd.locate(12,1);lcd.printf("40"); } if(tecla=='5' && status_tela=="solta_vol_dif"){ volume_solta_5=50; - lcd.locate(15,2);lcd.printf("50"); + lcd.locate(15,1);lcd.printf("50"); } if(tecla=='6' && status_tela=="solta_vol_dif"){ volume_solta_6=60; - lcd.locate(18,2);lcd.printf("60"); + lcd.locate(18,1);lcd.printf("60"); } if(tecla=='7' && status_tela=="solta_vol_dif"){ volume_solta_7=70; - lcd.locate(12,3);lcd.printf("70"); + lcd.locate(12,2);lcd.printf("70"); } if(tecla=='8' && status_tela=="solta_vol_dif"){ volume_solta_8=80; - lcd.locate(15,3);lcd.printf("80"); + lcd.locate(15,2);lcd.printf("80"); } if(tecla=='9' && status_tela=="solta_vol_dif"){ volume_solta_9=90; - lcd.locate(18,3);lcd.printf("90"); + lcd.locate(18,2);lcd.printf("90"); } if(tecla=='A' && status_tela=="solta_vol_dif"){ funcao_solta1(); @@ -608,7 +610,7 @@ funcao_solta_vol(); status_tela="solta_vol"; } - if(tecla=='A' && status_tela=="funcao_solta_pos_y"){ + if(tecla=='A' && status_tela=="solta_pos_y"){ funcao_solta1(); wait(3); funcao_solta2(); @@ -617,7 +619,7 @@ wait(3); status_tela="solta"; } - else if(tecla=='B' && status_tela=="funcao_solta_pos_y"){ + else if(tecla=='B' && status_tela=="solta_pos_y"){ funcao_solta1(); wait(3); funcao_solta2();