Código para o menu no LCD

Dependencies:   mbed SDFileSystemSD TextLCD

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Files at this revision

API Documentation at this revision

Comitter:
claraluques
Date:
Tue May 15 12:15:29 2018 +0000
Parent:
17:0b8e489fac36
Child:
19:2c890ae2d187
Commit message:
arquivo classes, sem integrar

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
classes.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/SDFileSystem.lib	Tue May 15 12:05:45 2018 +0000
+++ b/SDFileSystem.lib	Tue May 15 12:15:29 2018 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/neilt6/code/SDFileSystem/#12f368c2370e
+https://os.mbed.com/users/neilt6/code/SDFileSystem/#e4d2567200db
--- a/classes.h	Tue May 15 12:05:45 2018 +0000
+++ b/classes.h	Tue May 15 12:15:29 2018 +0000
@@ -91,4 +91,385 @@
                     wait_ms(15);   
                 }
             }       
+};
+
+
+//criar classe "menu" (funções para as telas)
+class Menu{
+    public:
+    int linha;
+    int func;
+    
+    void movercursor(int min, int max, int col){ //função para mover cursor de seleção
+        linha = min;
+        lcd.locate(col,min);
+        lcd.printf("%c", 0x3E);
+        while (bot_enter==penter){
+            if (bot_cima==1){
+                if (linha==min){
+                    lcd.locate(col,min);
+                    lcd.printf(" ");
+                    linha=max;
+                    lcd.locate(col, linha);
+                    lcd.printf("%c", 0x3E);
+                    } 
+                else {
+                    lcd.locate(col,linha);
+                    lcd.printf(" ");
+                    linha--;
+                    lcd.locate(col, linha);
+                    lcd.printf("%c", 0x3E);
+                    }  
+                bot_cima = 0;
+                }
+            else if (bot_baixo==1){
+                if (linha==max){
+                    lcd.locate(col,max);
+                    lcd.printf(" ");
+                    linha=min;
+                    lcd.locate(col, linha);
+                    lcd.printf("%c", 0x3E);
+                    }
+                else {
+                    lcd.locate(col,linha);
+                    lcd.printf(" ");
+                    linha++;
+                    lcd.locate(col, linha);
+                    lcd.printf("%c", 0x3E);
+                    }
+                bot_baixo = 0;
+                }
+            if (func==2){
+                lcd.locate(2,1);
+                lcd.printf("%.3f", cx);
+                lcd.locate(2,2);
+                lcd.printf("%.3f", cy);
+                lcd.locate(2,3);
+                lcd.printf("%.3f", cz);
+                }
+            //cx = cx + 0.1;
+            //cy = cy + 0.1;
+            //cz = cz + 0.1;
+            }          
+        }
+                       
+    //func 0
+    void inicializar(){ //função tela incial de boas-vindas
+        lcd.cls();
+        lcd.locate(4,0);
+        lcd.printf("Bem-vindo(a)");
+        lcd.locate(0,1);
+        lcd.printf("Utilize seu EPI para operar a maquina.");
+        wait(1);
+        func = 1;
+        }
+    
+    //func 1    
+    void menuprincipal(){ //função menu principal
+        bot_enter = 0;
+        lcd.cls();
+        lcd.locate(1,0);
+        lcd.printf("Modo JOG");
+        lcd.locate(1,1);
+        lcd.printf("Modo Automatico");
+        lcd.locate(1,2);
+        lcd.printf("Config");
+        lcd.locate(1,3);
+        lcd.printf("Zerar");
+        movercursor(0,3,0);
+        if (bot_enter!=penter){
+            if (linha==0){
+                func = 2;
+                }
+            else if (linha==1) {
+                func = 3;
+                }
+            else if (linha==2) {
+                func = 4;
+                }
+            else if (linha==3) {
+                func = 8;
+                }
+            }
+        } 
+        
+    //func 2    
+    void jog(){ //função tela jog
+        bot_enter = 0;
+        coords = 0;
+        lcd.cls();
+        lcd.locate(4,0);
+        lcd.printf("Coordenadas:");
+        lcd.locate(0,1);
+        lcd.printf("X:");
+        lcd.locate(0,2);
+        lcd.printf("Y:");
+        lcd.locate(0,3);
+        lcd.printf("Z:");
+        lcd.locate(11,1);
+        lcd.printf("Salvar");
+        lcd.locate(11,2);
+        lcd.printf("Concluir");
+        lcd.locate(11,3);
+        lcd.printf("Cancelar");        
+        //while (bot_enter==penter){            
+            //lcd.locate(2,1);
+            //lcd.printf("%.3f", cx);
+            //lcd.locate(2,2);
+            //lcd.printf("%.3f", cy);
+            //lcd.locate(2,3);
+            //lcd.printf("%.3f", cz); 
+            movercursor(1,3,10);
+            //cx++;
+            //cy++;
+            //cz++;
+           // }         
+        if (bot_enter!=penter){
+            coords = 1;
+            if (linha==1){                
+                if (pontos>0){
+                    pontos--;
+                    cx_salva = cx;
+                    cy_salva = cy;
+                    cz_salva = cz;
+                    func = 5;
+                    }
+                else if (pontos==0){
+                    func = 16;
+                    }
+                }
+            else if (linha==2) {
+                func = 7;
+                }
+            else if (linha==3) {
+                func = 1;
+                pontos = 10;
+                }
+            }    
+        }
+        
+    //func 3
+    void automatico(){ //tela modo automatico
+        lcd.cls();
+        bot_enter = 0;
+        lcd.printf("Modo automatico");
+        lcd.locate(7,2);
+        lcd.printf("OK");
+        lcd.locate(7,3);
+        lcd.printf("Voltar");
+        movercursor(2,3,6);
+        if (bot_enter!=penter) {
+            if (linha==2){
+                func = 12;
+                }
+            else if (linha==3){
+                func = 1;
+                }
+            }
+        }
+    
+    //func 4
+    void config() {
+        lcd.cls();
+        bot_enter = 0;
+        lcd.locate(1,0);
+        lcd.printf("Definir velocidade");
+        lcd.locate(1,1);
+        lcd.printf("Limpar seringa cola");
+        lcd.locate(1,2);
+        lcd.printf("Desligar a maquina");
+        lcd.locate(1,3);
+        lcd.printf("Voltar");
+        movercursor(0,3,0);
+        if (bot_enter!=penter){
+            if (linha==0) {
+                func = 13;
+                }
+            else if (linha==1) {
+                func = 14;
+                }
+            else if (linha==2) {
+                func = 15;
+                }
+            else if (linha==3) {
+                func = 1;
+                }
+            }        
+        }
+        
+    //func 5
+    void telasalvamento(){ //função para quando salvar um ponto
+        lcd.cls();
+        lcd.locate(0,0);
+        lcd.printf("Voce salvou");
+        lcd.locate(1,1);
+        lcd.printf("X:%.3f", cx_salva);
+        lcd.locate(1,2);
+        lcd.printf("Y:%.3f", cy_salva);
+        lcd.locate(1,3);
+        lcd.printf("Z:%.3f", cz_salva);
+        lcd.locate(13,1);
+        lcd.printf("Pontos");
+        lcd.locate(13,2);
+        lcd.printf("livres");
+        lcd.locate(16,3);
+        lcd.printf("%d", pontos);
+        wait(1);
+        if (pontos>0){
+            func = 6;
+            }
+        else if (pontos==0){
+            func = 2;
+            }
+        }
+        
+    //func 6
+    void telacola(){ //tela para escolher o tipo de sequencia da cola
+        lcd.cls();
+        bot_enter = 0;
+        lcd.printf("P/ o proximo ponto:");
+        lcd.locate(3,1);
+        lcd.printf("Sem cola");
+        lcd.locate(3,2);
+        lcd.printf("Cola no ponto");
+        lcd.locate(3,3);
+        lcd.printf("Cola continua");
+        movercursor(1,3,2);
+        if (bot_enter!=penter){
+            if (linha==1){
+                cola = 0;
+                func = 2;
+                }
+            else if (linha==2) {
+                cola = 1;
+                func = 2;
+                }
+            else if (linha==3) {
+                cola = 2;
+                func = 2;
+                }
+            }
+        }
+    
+    //func 7        
+    void executarprograma() { //tela para selecionar se deseja executar o programa
+        lcd.cls();
+        bot_enter = 0;
+        lcd.locate(2,0);
+        lcd.printf("VOCE CONCLUIU SEU");
+        lcd.locate(5,1);
+        lcd.printf("PROGRAMA.");
+        lcd.locate(0,2);
+        lcd.printf("Deseja");
+        lcd.locate(0,3);
+        lcd.printf("executa-lo?");
+        lcd.locate(14,2);
+        lcd.printf("Sim");
+        lcd.locate(14,3);
+        lcd.printf("Voltar");
+        movercursor(2,3,13);
+        if (bot_enter!=penter) {
+            if (linha==2){
+                exec = 1;
+                func = 9;
+                }
+            else if (linha==3){
+                exec = 0;
+                func = 2;
+                }
+            }
+        }
+    
+    //func 8
+    void telazerar(){ //tela para zerar a máquina
+        lcd.cls();
+        bot_enter = 0;
+        lcd.locate(2,0);
+        lcd.printf("Pressione OK para zerar as coordenadas");
+        lcd.locate(7,2);
+        lcd.printf("OK");
+        lcd.locate(7,3);
+        lcd.printf("Voltar");            
+        movercursor(2,3,6);
+        if (bot_enter!=penter) {
+            if (linha==2){
+                cx = 0;
+                cy = 0;
+                cz = 0;
+                func = 10;
+                }
+            else if (linha==3){
+                func = 1;
+                }
+            }
+        }
+        
+    //func 9
+    void executando(){ //tela de executando
+        lcd.cls();
+        lcd.locate(4,1);
+        lcd.printf("Executando");
+        int contador = 0;
+        while (exec==1){
+            lcd.locate(14,1);
+            lcd.printf(".  ");
+            wait(0.5);
+            lcd.locate(14,1);
+            lcd.printf(".. ");
+            wait(0.5);
+            lcd.locate(14,1);
+            lcd.printf("...");
+            wait(0.5);
+            lcd.locate(14,1);
+            lcd.printf("   ");
+            wait(0.5);
+            contador++;
+            if (contador>=2){
+                exec = 0;
+                func = 11;
+                }
+            }
+        }
+    
+    //func 10
+    void zerado() { //tela avisando que a máquina foi zerada
+        lcd.cls();
+        lcd.locate(5,1);
+        lcd.printf("Voce zerou");
+        lcd.locate(5,2);
+        lcd.printf("a maquina!");
+        wait(1);
+        func = 8;
+        }
+        
+    //func 11
+    void finalizado() { //tela aviso programa finalizado
+        lcd.cls();
+        lcd.locate(6,1);
+        lcd.printf("PROGRAMA");
+        lcd.locate(5,2);
+        lcd.printf("FINALIZADO");
+        wait(1);
+        func = 1;
+        }     
+        
+    //func 12
+    
+    //func 13
+    
+    //func 14
+    
+    //func 15
+    
+    //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(0,3);
+        lcd.printf("Conclua seu programa");
+        wait(1);
+        func = 2;
+        }      
+    
+    Menu(); //não apagar
 };
\ No newline at end of file
--- a/main.cpp	Tue May 15 12:05:45 2018 +0000
+++ b/main.cpp	Tue May 15 12:15:29 2018 +0000
@@ -49,7 +49,7 @@
 void botbaixo_solto(void);
 
 //criar classe "menu" (funções para as telas)
-class Menu{
+/*class Menu{
     public:
     int linha;
     int func;
@@ -433,6 +433,7 @@
     }
 
 Menu menu;  
+Machine machine;
 
 int main () {
     lcd.setBacklight(TextLCD::LightOn); //liga backlight
@@ -480,4 +481,5 @@
               pbaixo = bot_baixo;
               bot_baixo = !bot_baixo;
               printf("baixo high");
-              }         
\ No newline at end of file
+              }   */
+                    
\ No newline at end of file