Código para o menu no LCD

Dependencies:   mbed SDFileSystemSD TextLCD

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Revision:
19:2c890ae2d187
Parent:
18:5338b83b4de9
Child:
20:ccbd80b668ce
--- a/classes.h	Tue May 15 12:15:29 2018 +0000
+++ b/classes.h	Tue May 15 13:07:03 2018 +0000
@@ -2,7 +2,7 @@
 #define rx PC_11
 
 Serial Mach(tx, rx);
-SDFileSystem sd(PB_5, PB_4, PB_3, PB_10, "sd"); //MOSI - D4, MISO - D5, SCLK - D3, CS - D6
+//SDFileSystem sd(PB_5, PB_4, PB_3, PB_10, "sd"); //MOSI - D4, MISO - D5, SCLK - D3, CS - D6
 
 class Machine { 
     int n;
@@ -80,6 +80,10 @@
             send(buffer);    
         }
         
+        void jog(void){
+            send("j");
+        }
+        
         private:
             
             // PRIVATE FUNCTIONS ----------------------------------------------------------------------------------------------------------------------------------------
@@ -96,6 +100,8 @@
 
 //criar classe "menu" (funções para as telas)
 class Menu{
+    
+    Machine machine;
     public:
     int linha;
     int func;
@@ -139,7 +145,7 @@
                     }
                 bot_baixo = 0;
                 }
-            if (func==2){
+            else if (func==2 || func==8){
                 lcd.locate(2,1);
                 lcd.printf("%.3f", cx);
                 lcd.locate(2,2);
@@ -147,9 +153,6 @@
                 lcd.locate(2,3);
                 lcd.printf("%.3f", cz);
                 }
-            //cx = cx + 0.1;
-            //cy = cy + 0.1;
-            //cz = cz + 0.1;
             }          
         }
                        
@@ -197,6 +200,7 @@
     void jog(){ //função tela jog
         bot_enter = 0;
         coords = 0;
+        machine.jog();
         lcd.cls();
         lcd.locate(4,0);
         lcd.printf("Coordenadas:");
@@ -212,21 +216,11 @@
         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++;
-           // }         
+        movercursor(1,3,10);       
         if (bot_enter!=penter){
-            coords = 1;
-            if (linha==1){                
+            //coords = 1;
+            if (linha==1){ 
+                machine.save_point(1,2);               
                 if (pontos>0){
                     pontos--;
                     cx_salva = cx;
@@ -370,6 +364,7 @@
         movercursor(2,3,13);
         if (bot_enter!=penter) {
             if (linha==2){
+                machine.start_program();
                 exec = 1;
                 func = 9;
                 }
@@ -385,18 +380,37 @@
         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);
+        lcd.printf("Zerar:");
+        lcd.locate(0,1);
+        lcd.printf("X:");
+        lcd.locate(0,2);
+        lcd.printf("Y:");
+        lcd.locate(0,3);
+        lcd.printf("Z:");
+        lcd.locate(13,0);
+        lcd.printf("X");
+        lcd.locate(13,1);
+        lcd.printf("Y");
+        lcd.locate(13,2);
+        lcd.printf("Z");  
+        lcd.locate(13,3);
+        lcd.printf("Voltar");          
+        movercursor(0,3,12);
         if (bot_enter!=penter) {
-            if (linha==2){
+            if (linha==0){
                 cx = 0;
+                func = 10;
+                machine.set_zero("X");
+                }
+            else if (linha==1){
                 cy = 0;
+                func = 10;
+                machine.set_zero("Y");
+                }
+            else if (linha==2){
                 cz = 0;
                 func = 10;
+                machine.set_zero("Z");
                 }
             else if (linha==3){
                 func = 1;
@@ -436,8 +450,8 @@
         lcd.cls();
         lcd.locate(5,1);
         lcd.printf("Voce zerou");
-        lcd.locate(5,2);
-        lcd.printf("a maquina!");
+        lcd.locate(6,2);
+        lcd.printf("o eixo!");
         wait(1);
         func = 8;
         }