Grupo T / Mbed OS GRUPOT
Revision:
24:92f612ca218b
Parent:
23:d64d37561b4a
Child:
25:7b3826dddcba
diff -r d64d37561b4a -r 92f612ca218b main.cpp
--- a/main.cpp	Tue May 15 15:31:29 2018 +0000
+++ b/main.cpp	Tue May 15 18:38:50 2018 +0000
@@ -1,13 +1,11 @@
 // LIBs ------------------------------------------------------------------------------------
 #include "mbed.h"
 #include "string"
+#include "classes.h"
 
 // MACHINE SETUP ---------------------------------------------------------------------------
-#define tx PC_10
-#define rx PC_11
-
-Serial ihm(tx, rx); //tx e rx (D1 e D0)
 Timer t;
+IHM ihm_class;
 
 // drivers output signal
 DigitalOut enable(D2);
@@ -27,8 +25,6 @@
 InterruptIn endY(A3);
 InterruptIn endZ(A4);
 
-InterruptIn user(USER_BUTTON);
-
 // JOG Controls
 AnalogIn joyX(A0);
 AnalogIn joyY(A1);
@@ -71,7 +67,7 @@
 int z_block_max = 0;
 int z_block_min = 0;
 
-float ppsMax = 600.0;
+float ppsMax = 1000.0;
 
 int totalX = 0;
 int totalY = 0;
@@ -118,8 +114,6 @@
 void jog(void);
 void killJog(void);
 
-void x(void);
-
 void automatic_run(int);
 
 void move(int pps, int x_dir, int y_dir, int z_dir, int x_step, int y_step, int z_step);
@@ -151,8 +145,7 @@
     printf("\nStarting...\r\n");
     
     enable = 0;
-    
-    user.rise(&x);
+    t.start();
     
     //  interrupções de fim de curso
     /*
@@ -173,9 +166,6 @@
 }  
 
 // FUNCTIONS ----------------------------------------------------------------
-void x(void){
-    printf("User\n\r");    
-}
 
 void endX_press(void){
     printf("X - press\n\r");
@@ -395,9 +385,10 @@
 
 void jog(void){
     kill_jog = 0;
-    int contador = 0;
     printf("JOG Selected %d\n\r", kill_jog);
     
+    t.reset();
+    
     while(1){  
         if(ihm.readable()){
             readSerial();    
@@ -467,13 +458,15 @@
         Y = steps_to_distance(totalY, yPitch);
         Z = steps_to_distance(totalZ, zPitch);
         
-        if(contador > 10000){
+        if(t.read() > sendTime){
             printf("X: %.2f     Y: %.2f     Z: %.2f\r\n", X, Y, Z);
-            contador = 0;
+            X = steps_to_distance(totalX, xPitch);
+            Y = steps_to_distance(totalY, yPitch);
+            Z = steps_to_distance(totalZ, zPitch);
+            ihm_class.send_position(X, Y, Z);
+            t.reset();
         }
         
-        contador+=1;
-        
         if(kill_jog){
             break;
         }
@@ -581,7 +574,6 @@
     printf("\n\nReceiving...\n\r");
     
     t.reset();
-    t.start();
     
     while(1){
         if(t.read()>0.2){
@@ -644,4 +636,5 @@
             kill_jog_mode = 1;    
         }
     }
+    t.reset();
 }
\ No newline at end of file