Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed filesystem TextLCD
Fork of Projeto_Mecatronico by
main.cpp
- Committer:
- ricardoparanhos
- Date:
- 2022-05-30
- Revision:
- 27:cb310c1d2353
- Parent:
- 26:6be302ad0278
- Child:
- 28:84a60377564e
File content as of revision 27:cb310c1d2353:
#include "JOG.h"
#include "home.h"
#include "LCD.h"
#include "tempo_de_ciclo.h"
#include <iostream>
#include "posicao.h"
#include "SD.h"
bool velo = 1;
InterruptIn velocidade(PB_11); //PA_12
InterruptIn emergencia (PC_13);
void mudar_velocidade()
{
velo = !velo;
if(velo==0) {
tempo=0.006;
} else {
tempo=0.002;
}
}
int main()
{
int posicoes_x[] = {0, 1024, 512, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int posicoes_y[] = {0, 1024, 512, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int posicoes_z[] = {0, 1024, 512, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int pegas[] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int referenciar = 0;
char tempo_no_lcd[80];
// printf("%f",tempo);
//
// velocidade.rise(&mudar_velocidade);
//
// setar_posicoes();
// printf("%f",tempo);
// ler_SD();
/*display_to_lcd("Bem vindo /n");
display_to_lcd("Prosseguir");
if(arrow_right == 1){
display_to_lcd("Setar nova posição /n");
display_to_lcd("Utilizar a última posição");
if(arrow_up == 1) {
home();
referenciamento();
adquirir_posições();
}
if(arrow_down == 1 {
last_update()
}
}*/
while (1) {
// home();
// JOG
// int numero_pegas = 0;
// int x_pega = posicoes_x[1];
// int y_pega = posicoes_y[1];
// int z_pega = posicoes_z[1];
// int counter = 0;
// if (referenciar == 0) {
// for (int i=1; i < 12; i++) {
// int voltar_home = 0;
// int x_posicao = posicoes_x[i];
// int y_posicao = posicoes_y[i];
// int z_posicao = posicoes_z[i];
// numero_pegas = pegas[i];
// if (posicoes_x[i+1] == 0 && posicoes_y[i+1] == 0 && counter == 0) {
// voltar_home = 1;
// counter = 1;
// jog (x_posicao, y_posicao, z_posicao, x_pega, y_pega, z_pega, numero_pegas, voltar_home);
// mover_HOME (x_posicao, y_posicao);
// } else if (i == 1) {
// voltar_home = 1;
// jog (x_posicao, y_posicao, z_posicao, x_pega, y_pega, z_pega, numero_pegas, voltar_home);
// } else {
// jog (x_posicao, y_posicao, z_posicao, x_pega, y_pega, z_pega, numero_pegas, voltar_home);
// }
// }
// referenciar = 1;
// }
// JOG PREVIEW
if (referenciar == 0) {
for (int i=0; i < 11; i++) {
int posicao_anterior_x = posicoes_x[i];
int posicao_anterior_y = posicoes_y[i];
int posicao_anterior_z = posicoes_z[i];
int posicao_atual_x = posicoes_x[i+1];
int posicao_atual_y = posicoes_y[i+1];
int posicao_atual_z = posicoes_z[i+1];
jog_preview (posicao_atual_x, posicao_atual_y, posicao_atual_z, posicao_anterior_x, posicao_anterior_y, posicao_anterior_z);
}
referenciar = 1;
}
// TEMPO JOG PREVIEW
// float tempo_total = 0;
// float mover = 0;
// if (referenciar == 0) {
// for (int i=1; i < 12; i++) {
// int posicao_atual_x = posicoes_x[i];
// int posicao_atual_y = posicoes_y[i];
// int posicao_atual_z = posicoes_z[i];
// int posicao_anterior_x = posicoes_x[i-1];
// int posicao_anterior_y = posicoes_y[i-1];
// mover = tempo_jog_preview (posicao_anterior_x, posicao_anterior_y, posicao_atual_x, posicao_atual_y, posicao_atual_z);
// tempo_total += mover;
// }
// referenciar = 1;
// if (tempo_total >= 60 && tempo_total < 3600) {
// int min = abs(tempo_total/60);
// int seg = abs((tempo_total/60 - min)*60);
// printf(" %d minutos e %d segundos \n", min, seg);
// sprintf(tempo_no_lcd, "Deseja iniciar o ciclo?\n\n %imin%is \n", min, seg);
// mostrar_no_lcd(tempo_no_lcd);
//
// } else if (tempo_total < 60) {
// int seg = abs(tempo_total);
// printf("%d segundos \n", seg);
// sprintf(tempo_no_lcd, "Deseja iniciar o ciclo?\n\n %is \n", seg);
// mostrar_no_lcd(tempo_no_lcd);
// } else if (tempo_total >= 3600) {
// int hora = abs(tempo_total/3600);
// int min = abs(tempo_total/3600 - hora)*60;
// printf("%d horas e %d minutos \n", hora, min);
// sprintf(tempo_no_lcd, "Deseja iniciar o ciclo?\n\n %ih%imin\n", hora, min);
// mostrar_no_lcd(tempo_no_lcd);
// }
// }
// TEMPO DE CICLO
// int numero_pegas = 0;
// float tempo_total = 0;
// float mover = 0;
// int x_pega = posicoes_x[1];
// int y_pega = posicoes_y[1];
// int z_pega = posicoes_z[1];
// int ultimo = 0;
// if (referenciar == 0) {
// for (int i=1; i < 12; i++) {
// int posicao_atual_x = posicoes_x[i];
// int posicao_atual_y = posicoes_y[i];
// int posicao_atual_z = posicoes_z[i];
// numero_pegas = pegas[i];
// if (posicoes_x[i+1] == 0 && posicoes_y[i+1] == 0) {
// ultimo == 1;
// }
// mover = tempo_de_ciclo (posicao_atual_x, posicao_atual_y, posicao_atual_z, x_pega, y_pega, z_pega, numero_pegas, i, ultimo);
// tempo_total += mover;
// }
// referenciar = 1;
// if (tempo_total >= 60 && tempo_total < 3600) {
// int min = abs(tempo_total/60);
// int seg = abs((tempo_total/60 - min)*60);
// printf(" %d minutos e %d segundos \n", min, seg);
// sprintf(tempo_no_lcd, "Deseja iniciar o ciclo?\n\n %imin%is \n", min, seg);
// mostrar_no_lcd(tempo_no_lcd);
//
// } else if (tempo_total < 60) {
// int seg = abs(tempo_total);
// printf("%d segundos \n", seg);
// sprintf(tempo_no_lcd, "Deseja iniciar o ciclo?\n\n %is \n", seg);
// mostrar_no_lcd(tempo_no_lcd);
// } else if (tempo_total >= 3600) {
// int hora = abs(tempo_total/3600);
// int min = abs(tempo_total/3600 - hora)*60;
// printf("%d horas e %d minutos \n", hora, min);
// sprintf(tempo_no_lcd, "Deseja iniciar o ciclo?\n\n %ih%imin\n", hora, min);
// mostrar_no_lcd(tempo_no_lcd);
// }
// }
}
}
