Projeto_Mecatronico_Team / Mbed 2 deprecated Projeto_Mecatronico

Dependencies:   mbed filesystem TextLCD

Fork of Projeto_Mecatronico by Fernando Sakabe

Files at this revision

API Documentation at this revision

Comitter:
ricardoparanhos
Date:
Wed May 11 11:20:10 2022 +0000
Parent:
20:ed2094eb0687
Child:
22:7c38592facf5
Commit message:
11/05/22 - 8h20

Changed in this revision

analog.cpp Show annotated file Show diff for this revision Revisions of this file
analog.h Show annotated file Show diff for this revision Revisions of this file
home.cpp 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
posicao.cpp Show annotated file Show diff for this revision Revisions of this file
posicao.h Show annotated file Show diff for this revision Revisions of this file
posicionamento.cpp Show annotated file Show diff for this revision Revisions of this file
posicionamento.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analog.cpp	Wed May 11 11:20:10 2022 +0000
@@ -0,0 +1,25 @@
+/*************************************************************
+* Programa EXE-02
+* 22-09-2021
+* Leitura do botão-do-usuário e envio de informação via serial
+*************************************************************/
+#include "analog.h"
+
+AnalogIn xAxis(A0); // é o LED (LED1) na placa NUCLEO-F103RB
+AnalogIn yAxis(A1);
+
+int direcao_botao_analogico ()
+{
+    int x,y;
+    x = xAxis.read() * 1000;
+    y = 1000 - yAxis.read() * 1000;
+    if (x > 600) {
+        return 0;
+    } else if (x < 400) {
+        return 1;
+    } else if (y > 600) {
+        return 2;
+    } else if (y > 400) {
+        return 3;
+    }
+}
\ No newline at end of file
--- a/analog.h	Tue May 10 14:43:22 2022 +0000
+++ b/analog.h	Wed May 11 11:20:10 2022 +0000
@@ -3,24 +3,9 @@
 * 22-09-2021
 * Leitura do botão-do-usuário e envio de informação via serial
 *************************************************************/
+#ifndef ANALOG_H
+#define ANALOG_H
+#endif
 #include "mbed.h"
 
-AnalogIn xAxis(A0); // é o LED (LED1) na placa NUCLEO-F103RB
-AnalogIn yAxis(A1);
-
-string direcao_botao_analogico ()
-{
-    int x,y;
-    x = xAxis.read() * 1000;
-    y = 1000 - yAxis.read() * 1000;
-    wait(0.1);
-    if (x > 600) {
-        return "direita";
-    } else if (x < 400) {
-        return "esquerda";
-    } else if (y > 600) {
-        return "frente";
-    } else if (y > 400) {
-        return "tras";
-    }
-}
\ No newline at end of file
+int direcao_botao_analogico ();
\ No newline at end of file
--- a/home.cpp	Tue May 10 14:43:22 2022 +0000
+++ b/home.cpp	Wed May 11 11:20:10 2022 +0000
@@ -1,9 +1,9 @@
 #include "home.h"
 
-DigitalIn FDC_x_menos(PC_10);
-DigitalIn FDC_x_mais(PC_12);
-DigitalIn FDC_y_menos(PA_13);
-DigitalIn FDC_y_mais(PA_14);
+//DigitalIn FDC_x_menos(PC_10);
+//DigitalIn FDC_x_mais(PC_12);
+//DigitalIn FDC_y_menos(PA_13);
+//DigitalIn FDC_y_mais(PA_14);
 DigitalIn FDC_z_menos(PA_15);
 DigitalIn FDC_z_mais(PB_7);
 
@@ -18,21 +18,21 @@
         jog_FDC("z_mais");
     }
     
-    while (FDC_y_menos == 1)
-    {
-        jog_ref("y_menos");
-    }
-    while (FDC_y_menos == 0)
-    {
-        jog_FDC("y_mais");
-    }
-    
-    while (FDC_x_menos == 1)
-    {
-        jog_ref("x_menos");
-    }
-    while (FDC_x_menos == 0)
-    {
-        jog_FDC("x_mais");
-    }
+//    while (FDC_y_menos == 1)
+//    {
+//        jog_ref("y_menos");
+//    }
+//    while (FDC_y_menos == 0)
+//    {
+//        jog_FDC("y_mais");
+//    }
+//    
+//    while (FDC_x_menos == 1)
+//    {
+//        jog_ref("x_menos");
+//    }
+//    while (FDC_x_menos == 0)
+//    {
+//        jog_FDC("x_mais");
+//    }
 } 
\ No newline at end of file
--- a/main.cpp	Tue May 10 14:43:22 2022 +0000
+++ b/main.cpp	Wed May 11 11:20:10 2022 +0000
@@ -2,10 +2,10 @@
 #include "home.h"
 
 int main(){
-    int posicoes_x[] = {1024, 512, 1536};
-    int posicoes_y[] = {1024, 512, 1536};
-    int posicoes_z[] = {1024, 512, 1536};
-    int pegas[] = {0, 1, 1};
+    //int posicoes_x[] = {1024, 512, 1536};
+//    int posicoes_y[] = {1024, 512, 1536};
+//    int posicoes_z[] = {1024, 512, 1536};
+//    int pegas[] = {0, 1, 1};
     int referenciar = 0;
     while(1){
     /*display_to_lcd("Bem vindo /n");
@@ -22,26 +22,22 @@
             last_update()
             }
     }*/
-    //if (referenciar == 0)
-//    {
-//        home();
-//        referenciar = 1; 
-//    }
-        int numero_pegas = 0;
-        int x_pega = posicoes_x[0];
-        int y_pega = posicoes_y[0];
-        int z_pega = posicoes_z[0];
-        if (referenciar == 0)
-        {
-            for (int i=0; i < 3; i++)
-            {
-                int x_posicao = posicoes_x[i];
-                int y_posicao = posicoes_y[i];
-                int z_posicao = posicoes_z[i];
-                numero_pegas = pegas[i];
-                jog (x_posicao, y_posicao, z_posicao, x_pega, y_pega, z_pega, numero_pegas);
-            }
-            referenciar = 1;
-        }
+    home();
+ //       int numero_pegas = 0;
+//        int x_pega = posicoes_x[0];
+//        int y_pega = posicoes_y[0];
+//        int z_pega = posicoes_z[0];
+//        if (referenciar == 0)
+//        {
+//            for (int i=0; i < 3; i++)
+//            {
+//                int x_posicao = posicoes_x[i];
+//                int y_posicao = posicoes_y[i];
+//                int z_posicao = posicoes_z[i];
+//                numero_pegas = pegas[i];
+//                jog (x_posicao, y_posicao, z_posicao, x_pega, y_pega, z_pega, numero_pegas);
+//            }
+//            referenciar = 1;
+//        }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/posicao.cpp	Wed May 11 11:20:10 2022 +0000
@@ -0,0 +1,50 @@
+#include "posicao.h"
+DigitalIn enter_button(PC_8);
+int posicoes[11][4] = {0};
+int posicoes_enviar[4][11] = {0};
+int arrow_left_button =0;
+int i = 2;
+int qtd_ml = 0;
+int* x_ptr;
+int* y_ptr;
+int* z_ptr;
+int sair = 0;
+void setar_posicoes()
+{
+
+    while( i<10 && i>1 && sair == 0) {
+        printf("Setar posição SOLTA %i ? \n", i-1);
+        if(arrow_left_button == 1) {
+            i=i-2;
+        } else if(arrow_right_button == 1) {
+            x_ptr = &posicoes[i][0];
+            y_ptr = &posicoes[i][1];
+            z_ptr = &posicoes[i][2];
+            wait(2);
+            posicionamento(x_ptr, y_ptr, z_ptr,posicoes[i-1][0],posicoes[i-1][1], posicoes[i-1][2]);
+            wait(2);
+            while(i!=0 && arrow_right_button ==0) {
+                printf("Qual quantidade de ml vai colocar? \n");
+
+                if (arrow_up_button == 1) {
+                    qtd_ml++;
+                }
+            }
+            posicoes[i][3]=qtd_ml;
+            qtd_ml = 0;
+            i++;
+            wait(2);
+        } else if(enter_button == 1) {
+            sair = 1;
+        }
+    }
+
+    for (int k = 0; k < 4; ++k) {
+        for (int g = 0; g < 11; ++g) {
+            posicoes_enviar[g][k] = posicoes[k][g];
+        }
+        
+        
+    }
+    printf("%i",posicoes_enviar[1][4]);
+}
--- a/posicao.h	Tue May 10 14:43:22 2022 +0000
+++ b/posicao.h	Wed May 11 11:20:10 2022 +0000
@@ -1,15 +1,7 @@
-/*#include "LCD.h"
-bool concluido = 0;
-void posicionamento ()
-{
-    int posicoes_volumes =[10][4]
-    while(1) {
-        lcd.printf("Setar posição PEGA?");
-        if (button_enter==1) {
-            posicoes_volumes[0][0],posicoes_volumes[0][1],posicoes_volumes[0][2] = posicionamento ();
-        }
-        lcd.printf("Setar posição SOLTA 1?");
-        if (button_enter==1) {
-            posicoes_volumes[1][0],posicoes_volumes[1][1],posicoes_volumes[1][2] = posicionamento (); */
+
+#include "mbed.h"
+#include "posicionamento.h"
+extern DigitalIn enter_button;
+void setar_posicoes();
             
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/posicionamento.cpp	Wed May 11 11:20:10 2022 +0000
@@ -0,0 +1,49 @@
+#include "posicionamento.h"
+DigitalIn arrow_right_button(PC_6);
+int arrow_up_button =1;
+int arrow_down_button =1;
+
+void posicionamento (int* x_ptr, int* z_ptr, int* y_ptr, int x_passos, int y_passos, int z_passos)
+{
+
+    while(arrow_right_button == 0) {
+        printf("Cofirmar o posicionamento XY?  \n");
+        switch (direcao_botao_analogico()) {
+            case 0:
+                x_mais();
+                x_passos++;
+                break;
+
+            case 1:
+                x_menos();
+                x_passos--;
+                break;
+
+            case 2:
+                y_mais();
+                y_passos++;
+                break;
+
+            case 3:
+                y_menos();
+                y_passos--;
+                break;
+        }
+
+    }
+    wait(2);
+    while(arrow_right_button == 0) {
+        printf("Confirmar o posicionamento Z? \n");
+        if(arrow_up_button ==1 && arrow_down_button==0) {
+            z_mais();
+            z_passos++;
+        } else if(arrow_down_button == 1 && arrow_up_button==0) {
+            z_menos();
+            z_passos--;
+        }
+
+    }
+    *x_ptr = x_passos;
+    *y_ptr = y_passos;
+    *z_ptr = z_passos;
+}
\ No newline at end of file
--- a/posicionamento.h	Tue May 10 14:43:22 2022 +0000
+++ b/posicionamento.h	Wed May 11 11:20:10 2022 +0000
@@ -1,47 +1,7 @@
-/* #include "mbed.h"
-#include "movimento.h"
-#include "mover.h"
-#include "LCD.h"
-int posicionamento ()
-{
-    int x_passos = 0;
-    int y_passos = 0;
-    int z_passos = 0;
-    lcd.printf("Confirmar o posicionamento XY?");
-    while(button_enter == 0) {
-        switch (direcao_botao_analogico()) {
-            case "direita":
-                x_mais();
-                x_passos++;
-                break;
-
-            case "esquerda":
-                x_menos();
-                x_passos--;
-                break;
+#include "mbed.h"
+#include "JOG.h"
+#include "analog.h"
+extern DigitalIn arrow_right_button;
+extern int arrow_up_button;
 
-            case "frente":
-                y_mais();
-                y_passos++;;
-                break;
-
-            case "tras":
-                y_menos();
-                y_passos++;
-                break;
-        }
-
-    }
-
-    lcd.printf("Confirmar o posicionamento Z?");
-    while(button_enter == 0) {
-        if(arrow_up_button ==1 && arrow_down_button==0) {
-            z_mais();
-            z_passos++
-        } else(arrow_down_button == 1 && arrow_up_button==0) {
-            z_menos();
-            z_passos--;
-        }
-        return x_passos/50, y_passos/50, z_passos/50;
-
-    } */
\ No newline at end of file
+void posicionamento (int* x_ptr, int* z_ptr, int* y_ptr, int x_passos, int y_passos, int z_passos);
\ No newline at end of file