2 Motores + Joystick

Dependencies:   X_NUCLEO_IHM01A1 TextLCD

Fork of HelloWorld_IHM01A1_2Motors_mbedOS by ST

Files at this revision

API Documentation at this revision

Comitter:
digo1234
Date:
Wed May 23 17:20:50 2018 +0000
Parent:
57:270b6c82d071
Child:
59:8d34a4bfc2b7
Commit message:
IHM com bot?o de emergencia funcional;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed May 23 13:40:44 2018 +0000
+++ b/main.cpp	Wed May 23 17:20:50 2018 +0000
@@ -107,6 +107,7 @@
 DigitalIn botao2  (PC_0); //2
 DigitalIn botao3  (PC_10); //3
 DigitalIn botao4  (PC_12); //4
+DigitalIn emergencia(PC_4);// butão de emergencia
 
 float x;
 float y;
@@ -146,6 +147,7 @@
 bool flagY1=0; 
 
 int safe = 0;
+int safe_emergencia = 0;
 
 unsigned int minspeed = 1300;
 
@@ -321,7 +323,7 @@
             lcd.printf("2-INICIAR PROGRAMA");
  
     while(true) {
-        if (!botao1 && !botao2 && !botao3 && !botao4){
+        if (!botao1 && !botao2 && !botao3 && !botao4 && !emergencia){
             safe = 0;
             }
         count = count +1;
@@ -333,7 +335,6 @@
         sp = botao1.read();
         vc = botao2.read();
         if (count == 50) {
-            printf("seguranca fim de curso =%i \r\n\n", segu_fim_curso);
             //printf("w =%f \r\n\n", w);
             //printf("u =%f \r\n\n", u);
             wait_ms(DELAY_1);
@@ -453,11 +454,35 @@
                         }
                     }
                }
+            
+// botão de emergencia apertado  
+   if(emergencia && safe_emergencia==0){
+           lcd.cls();
+           lcd.setAddress(0,1);
+           lcd.printf("BOTAO DE EMERGENCIA");
+           lcd.setAddress(4,2);
+           lcd.printf("PRESSIONADO");
+           safe_emergencia=1;
+           }
+        if(!emergencia && safe_emergencia==1){
+            lcd.cls();
+            lcd.setAddress(0,0);
+            lcd.printf("PONTOS PERDIDOS");
+            lcd.setAddress(0,1);
+            lcd.printf("MAQUINA REINICIANDO");
+            lcd.setAddress(5,3);
+            lcd.printf("SE FUDEU");
+            wait(2);
+            safe_emergencia=0;      
+            NVIC_SystemReset();
+            }
+            
+            
 // vai caminho de um programa ja salvo depois do menu inicial     
     if (botao2 && menu==0 && safe == 0) {
         lcd.cls();
         if (listaX[0]==0&& listaY[0]==0 && listaZ[0]==0){
-            lcd.setAddress(0,0);
+            lcd.setAddress(0,1);
             lcd.printf("NAO HA PONTOS SALVOS");
             wait(2);
             lcd.cls();