Código para o menu no LCD

Dependencies:   mbed SDFileSystemSD TextLCD

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Revision:
42:48096cfdea78
Parent:
41:a1ab19cc1387
Child:
43:4684aba69ba6
--- a/classes.h	Sun Jun 10 06:18:14 2018 +0000
+++ b/classes.h	Sun Jun 10 21:52:12 2018 +0000
@@ -297,6 +297,15 @@
                 func = 31;
                 break;
             }
+            if(func == 13){
+                if(clean_wifi.read()>6.0){
+                    lcd.locate(0,1);
+                    lcd.printf("                    ");    
+                }
+                if(WiFi.readable()){
+                    wifiRx();    
+                }    
+            }
             if (bot_cima==0){
                 if (linha==min){
                     lcd.locate(col,min);
@@ -358,7 +367,6 @@
     
     //func 1    
     void menuprincipal(){ //função menu principal
-        WiFi.attach(wifiRx, Serial::RxIrq);
         bot_enter = penter;
         sair = 0;
         lcd.cls();
@@ -389,7 +397,7 @@
         
     //func 2    
     void jog(){ //função tela jog
-        WiFi.attach(NULL, Serial::RxIrq);
+        
         lcd.cls();
         bot_enter = penter;
         machine.kill_jog();
@@ -443,7 +451,7 @@
         
     //func 3
     void automatico(){ //tela modo automatico
-        WiFi.attach(NULL, Serial::RxIrq);
+        
         lcd.cls();
         f = 0;
         sair = 0;
@@ -458,26 +466,26 @@
     
     //func 4
     void config() {
-        WiFi.attach(NULL, Serial::RxIrq);
+        
         lcd.cls();
         bot_enter = penter;
+        lcd.locate(1,2);
+        lcd.printf("Modo WiFi");
         lcd.locate(1,0);
-        lcd.printf("Definir velocidade");
+        lcd.printf("Limpar seringa cola");
         lcd.locate(1,1);
-        lcd.printf("Limpar seringa cola");
-        lcd.locate(1,2);
         lcd.printf("Origem maquina");
         lcd.locate(1,3);
         lcd.printf("Voltar");
         movercursor(0,3,0);
         if (bot_enter!=penter){
-            if (linha==0) {
+            if (linha==2) {
                 func = 13;
                 }
             else if (linha==1) {
                 func = 14;
                 }
-            else if (linha==2) {
+            else if (linha==0) {
                 home = 1;
                 func = 18;
                 }
@@ -489,7 +497,7 @@
         
     //func 5
     void telasalvamento(){ //função para quando salvar um ponto
-        WiFi.attach(NULL, Serial::RxIrq);
+        
         lcd.cls();
         lcd.locate(0,0);
         lcd.printf("Voce salvou");
@@ -516,7 +524,7 @@
         
     //func 6
     void telacola(){ //tela para escolher o tipo de sequencia da cola
-        WiFi.attach(NULL, Serial::RxIrq);
+        
         lcd.cls();
         bot_enter = penter;
         lcd.printf("P/ o proximo ponto:");
@@ -644,7 +652,7 @@
     
     //func 7        
     void executarprograma() { //tela para selecionar se deseja executar o programa
-        WiFi.attach(NULL, Serial::RxIrq);
+        
         lcd.cls();
         bot_enter = penter;
         lcd.locate(2,0);
@@ -677,7 +685,7 @@
     
     //func 8
     void telazerar(){ //tela para zerar a máquina
-        WiFi.attach(NULL, Serial::RxIrq);
+        
         lcd.cls();
         bot_enter = penter;
         machine.kill_jog();
@@ -720,6 +728,7 @@
         
     //func 9
     void executando(){ //tela de executando
+        
         lcd.cls();
         machine.start_program();
         printf("start program, %s\n\r", arquivo);
@@ -727,6 +736,10 @@
         lcd.printf("Executando");
         //tpontinhos.start();
         while (exec == 1){
+            if(emerg){
+                func = 31;
+                break;
+            }
             if (Mach.readable()){
                 readSerial();
                 }
@@ -737,6 +750,7 @@
     
     //func 10
     void zerado() { //tela avisando que a máquina foi zerada
+        
         lcd.cls();
         lcd.locate(5,1);
         lcd.printf("Voce zerou");
@@ -748,6 +762,7 @@
         
     //func 11
     void finalizado() { //tela aviso programa finalizado
+        
         lcd.cls();
         lcd.locate(6,1);
         lcd.printf("PROGRAMA");
@@ -759,6 +774,7 @@
         
     //func 12
     void limpeza_livre(){
+        
         lcd.cls();
         bot_enter = penter;
         lcd.printf("Certifique-se de que a maquina pode se");
@@ -777,6 +793,13 @@
         }
     
     //func 13
+    void wifi(){
+        bot_enter = penter;
+        lcd.cls();
+        lcd.locate(0,0);
+        lcd.printf("Modo WiFi Ativo"); 
+        movercursor(3,3,0);   
+    }
     
     //func 14
     void limparcola(){
@@ -804,10 +827,15 @@
     
     //func 15
     void gohome(){
+        
         lcd.cls();
         //escrever a tela
         machine.machine_zero();
         while (home == 1){
+            if(emerg){
+                func = 31;
+                break;
+            }
             if (Mach.readable()){
                 readSerial();
                 }
@@ -817,6 +845,7 @@
     
     //func 16
     void limitepontos(){ //tela para quando acabam os pontos
+        
         lcd.cls();
         lcd.printf(" Voce atingiu o n%c   maximo de pontos", 0xDF);
         lcd.locate(9,2);
@@ -829,6 +858,7 @@
     
     //func 17
     void salvarprog(){
+        
         lcd.cls();
         bot_enter = penter;
         nome = "";
@@ -853,6 +883,7 @@
     
     //func 18
     void ctzhome(){
+        
         lcd.cls();
         bot_enter = penter;
         lcd.printf("Certifique-se de que a maquina pode se");
@@ -871,6 +902,7 @@
         
     //func 19
     void origem(){
+        
         lcd.cls();
         lcd.locate(5,1);
         lcd.printf("A MAQUINA");
@@ -882,6 +914,7 @@
         
     //func 20
     void nomeprog(){
+        
         lcd.cls();
         sair = 0;
         bot_enter = penter;
@@ -927,6 +960,7 @@
         
     //func 21
     void mudar_nome(){
+        
         lcd.cls();
         lcd.printf("ESCOLHA OUTRO NOME");
         wait(1);
@@ -935,6 +969,7 @@
         
     //func 22
     void salva2(){
+        
         lcd.cls();
         lcd.locate(0,0);
         lcd.printf("Voce salvou o ponto:");
@@ -1025,6 +1060,7 @@
     
     //func 23
     void deletepoint(){
+        
         lcd.cls();
         lcd.locate(1,1);
         lcd.printf("Você removeu o ultimo ponto");
@@ -1036,6 +1072,7 @@
         
     //func 24
     void sempontos(){
+        
         lcd.cls();
         lcd.locate(1,1);
         lcd.printf("Nao existem pontos para remover");
@@ -1047,6 +1084,7 @@
         
     //func 25
     void salvando_arq(){
+        
         lcd.locate(5,1);
         lcd.printf("Salvando");
         lcd.locate(1,2);
@@ -1057,6 +1095,7 @@
     
     //func 26
     void exec_auto(){
+        
         lcd.cls();
         bot_enter = penter;
         lcd.locate(2,0);
@@ -1085,12 +1124,17 @@
         
     //func 27
     void indo_limpeza(){
+        
         lcd.cls();
         lcd.locate(2,1);
         printf("indo home\n\r");
         lcd.printf("Movimentando...");
         machine.machine_zero();
         while (home == 1){
+            if(emerg){
+                func = 31;
+                break;
+            }
             if (Mach.readable()){
                 readSerial();
                 }
@@ -1100,6 +1144,7 @@
     
     //func 28
     void chegou_limpeza(){
+        
         lcd.cls();
         bot_enter = penter;
         printf("foi home\n\r");
@@ -1122,12 +1167,17 @@
     
     //func 29
     void limpando(){
+        
         lcd.cls();
         lcd.locate(3,1);
         printf("indo cola\n\r");
         lcd.printf("Limpando...");
         machine.clean_glue();
         while (limpar_cola == 1){
+            if(emerg){
+                func = 31;
+                break;
+            }
             if (Mach.readable()){
                 readSerial();
                 }
@@ -1137,6 +1187,7 @@
     
     //func 30
     void limpeza_completa(){
+        
         lcd.cls();
         lcd.locate(1,1);
         printf("foi cola\n\r");
@@ -1148,6 +1199,7 @@
         
     //função ler arquivos
     void arquivos(){
+        
         exec = 0;
         int nomearq;
         nomearq = sdcard.get_file_names();
@@ -1155,6 +1207,10 @@
         int fmax = ftamanho - 1;
         int fant = 1;
         while (sair==0){
+            if(emerg){
+                func = 31;
+                break;
+            }
             if (bot_cima==0){
                 fant = f;
                 f--;
@@ -1195,6 +1251,7 @@
                 
     //função para escrever nome arquivo
     void escrever(){
+        
         char alfabeto[38] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
         '0','1','2','3','4','5','6','7','8','9','-','_'};
         int imax = 37;
@@ -1202,6 +1259,10 @@
         nome = "";
         //lcd.locate(1,1); 
         while (sair==0){
+            if(emerg){
+                func = 31;
+                break;
+            }
             voltar = 0;
             int i = 0;
             //lcd.locate(0,2);
@@ -1209,6 +1270,10 @@
             lcd.locate(1,1);
             lcd.printf("%s", nome);
             while (bot_enter==penter){
+                if(emerg){
+                    func = 31;
+                    break;
+                }
                 if (bot_cima == 0){
                     if (i==imin){
                         i = imax;
@@ -1279,6 +1344,7 @@
             }
         }
     void tela_emergencia(void){
+        
         lcd.cls();
         lcd.printf("EMERGENCIA");  
         printf("Waiting release...");
@@ -1306,6 +1372,11 @@
         while(1){
             recv = Mach.getc();
             
+            if(emerg){
+                func = 31;
+                break;
+            }
+            
             if (recv == 'a'){
                 home = 0;
                 exec = 0;