Código para o menu no LCD

Dependencies:   mbed SDFileSystemSD TextLCD

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Revision:
40:e70f811c69dc
Parent:
39:fbad08986621
Child:
41:a1ab19cc1387
--- a/main.cpp	Fri Jun 08 20:52:35 2018 +0000
+++ b/main.cpp	Sat Jun 09 18:41:32 2018 +0000
@@ -12,18 +12,17 @@
 Timer cima_debounce_timer;
 Timer baixo_debounce_timer;
 Timer tpontinhos;
-
-// Host PC Communication channels
-Serial pc(USBTX, USBRX); // tx, rx //não apagar
  
 //I2C Communication
 I2C i2c_lcd(D14,D15); // SDA, SCL //não apagar
 
 //Botão push
 InterruptIn botao_enter(D12);
-InterruptIn botao_cima(D8);
+InterruptIn botao_cima(D9);
 InterruptIn botao_baixo(D13);
 
+InterruptIn emergencia(D3);
+
 //LCD instantiation 
 TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); //não apagar
 
@@ -63,6 +62,9 @@
 void botbaixo_press(void);
 void botenter_release(void);
 void botcima_release(void);
+void emergencia_press(void);
+void emergencia_release(void);
+void wifiRx(void);
 
 
 #include "classes.h"
@@ -74,6 +76,7 @@
 Menu menu;  
 
 int main () {
+    printf("Starting...\n\r");
     lcd.setBacklight(TextLCD::LightOn); //liga backlight
     lcd.setCursor(TextLCD::CurOff_BlkOff); //define tipo de cursor
     
@@ -88,7 +91,17 @@
     cima_debounce_timer.start();
     baixo_debounce_timer.start();
        
-    while(1){    
+    emergencia.fall(&emergencia_press);
+    emergencia.rise(&emergencia_release);
+    
+    if(!emergencia.read()){
+        printf("EMERGENCIA PRESSIONADO\n\r");
+        menu.tela_emergencia();
+        while(!emergencia.read());
+        printf("OK\n\r");
+    }
+       
+    while(1){
         switch(menu.func){ //faz com que as telas sejam iniciadas
             case 0: menu.inicializar(); break;
             case 1: menu.menuprincipal(); break;
@@ -120,9 +133,9 @@
             case 28: menu.chegou_limpeza(); break;
             case 29: menu.limpando(); break;
             case 30: menu.limpeza_completa(); break;
-            }
-        } 
-    }             
+        }
+    } 
+}             
         
 //função interrupt botão enter        
     void botenter_press(void){ 
@@ -177,4 +190,22 @@
     void botcima_release(void){
         timer2.stop();
         //printf("%f,%d, timer 2 RISE\n\r", t2, voltar);
-        }
\ No newline at end of file
+        }
+        
+    void wifiRx(void){
+        if(WiFi.readable()){
+            printf("Recv: %c\n\r", WiFi.getc());   
+        }    
+    }
+    
+void emergencia_press(void){
+    printf("Emerg Press\n\r");
+    menu.tela_emergencia();
+    while(!emergencia.read());
+    printf("Emerg Out\n\r");
+    main();
+}
+
+void emergencia_release(void){
+    printf("Emerg Release\n\r");
+}
\ No newline at end of file