testando

Dependencies:   mbed TextLCD2

Revision:
57:e26deee15b8f
Parent:
56:e748b9bd5e3c
Child:
58:d573b618f45a
--- a/main_PM.cpp	Sat May 30 21:20:23 2020 +0000
+++ b/main_PM.cpp	Sat May 30 21:37:01 2020 +0000
@@ -104,6 +104,7 @@
         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;}}
     while (fdc_y != 0){for(int i = 0; i < 4; i++){eixoy = hor[i];wait(t_motor);est_y = 1;}}
@@ -135,6 +136,35 @@
 float pos_x_solta=0;
 float pos_y_solta=0;
 
+//Função IHM - OK
+void funcao_ok_pega(){
+    TextLCD lcd(D4, D5, D6, D7, D8, D9); 
+    if(pos_y_pega !=0){
+    lcd.locate(18,1);lcd.printf("OK");   
+    }
+    if(medida_lado_pega !=0){
+    lcd.locate(18,1);lcd.printf("OK");
+    }
+    if(volume_pega !=0){
+    lcd.locate(18,0);lcd.printf("OK");    
+    }
+}
+
+void funcao_ok_solta(){
+    TextLCD lcd(D4, D5, D6, D7, D8, D9); 
+    if(pos_y_solta !=0){
+    lcd.locate(18,1);lcd.printf("OK");   
+    }
+    if(dimensao_solta !=0){
+    lcd.locate(18,1);lcd.printf("OK");
+    }
+    if(volume_solta_9 !=0){
+    lcd.locate(18,0);lcd.printf("OK");    
+    }  
+}
+
+//main
+
 int main() {
         interrupcao.fall(&emergencia);    
         int volume;
@@ -415,9 +445,10 @@
         if(tecla == 'A' && status_tela == "forma_quad"){
             funcao_pega1();
             medida_lado_pega = 10;
-            lcd.locate(18,1);lcd.printf("OK");
+            funcao_ok_solta();
             wait(1);
             funcao_pega2();
+            funcao_ok_solta();
             status_tela ="novo";}
         else if(tecla == 'B' && status_tela == "forma_quad"){
             funcao_pega_forma();
@@ -425,9 +456,10 @@
         else if(tecla == 'A' && status_tela == "forma_red"){
             medida_lado_pega = 10;
             funcao_pega1();
-            lcd.locate(18,1);lcd.printf("OK");
+            funcao_ok_pega();
             wait(1);
             funcao_pega2();
+            funcao_ok_pega();
             status_tela ="novo";}
         else if(tecla == 'B' && status_tela == "forma_red"){
             funcao_pega_forma();
@@ -435,9 +467,10 @@
         else if(tecla == 'A' && status_tela == "volume"){
             funcao_pega1();
             volume_pega = 12;
-            lcd.locate(18,2);lcd.printf("OK");
+            funcao_ok_pega();
             wait(1);
             funcao_pega2();
+            funcao_ok_pega();
             status_tela ="novo";}
         else if( tecla == 'B' && status_tela == "volume"){
             funcao_pega_forma();
@@ -453,9 +486,10 @@
         tecla = pega_tecla();    
         if(tecla == 'A' && status_tela == "pos_y"){
             funcao_pega1();
+            funcao_ok_pega();
             wait(1);
             funcao_pega2();
-            lcd.locate(18,1);lcd.printf("OK");
+            funcao_ok_pega();
             wait(1);
             status_tela ="novo";}
         else if(tecla == 'B' && status_tela == "pos_y"){
@@ -486,12 +520,10 @@
             }
         else if(tecla == 'B' && status_tela == "solta"){
             funcao_pega1();
-            lcd.locate(18,1);lcd.printf("OK");
-            lcd.locate(18,2);lcd.printf("OK");
+            funcao_ok_solta();
             wait(1);
             funcao_pega2();
-            lcd.locate(18,2);lcd.printf("OK");
-            lcd.locate(18,1);lcd.printf("OK");
+            funcao_ok_solta();
             status_tela="inicio";
             }
         
@@ -499,7 +531,7 @@
         if(tecla=='A' && status_tela=="solta_dimensao"){
             dimensao_solta = 10;
             funcao_solta1();
-            lcd.locate(18,1);lcd.printf("OK");
+            funcao_ok_solta();
             wait(3);
             funcao_solta2();
             wait(3);
@@ -553,9 +585,10 @@
             volume_solta_9=10;
             
             funcao_solta1();
-            lcd.locate(18,2);lcd.printf("OK");
+            funcao_ok_solta();
             wait(3);
             funcao_solta2();
+            funcao_ok_solta();
             wait(3);
             status_tela="solta";}
         else if(tecla=='B' && status_tela=="solta_vol_igual"){
@@ -600,9 +633,10 @@
             }
         if(tecla=='A' && status_tela=="solta_vol_dif"){
             funcao_solta1();
-            lcd.locate(18,2);lcd.printf("OK");
+            funcao_ok_solta();
             wait(3);
             funcao_solta2();
+            funcao_ok_solta();
             wait(3);
             status_tela="solta"; 
             }
@@ -612,9 +646,10 @@
             }
         if(tecla=='A' && status_tela=="solta_pos_y"){
             funcao_solta1();
+            funcao_ok_solta();
             wait(3);
             funcao_solta2();
-            lcd.locate(18,1);lcd.printf("OK");
+            funcao_ok_solta();
             pos_y_solta = 10;
             wait(3);
             status_tela="solta";