Reception message + asser moteur
This commit is contained in:
parent
4ff4b2c8bf
commit
7ce5acb7bf
@ -14,9 +14,11 @@ add_executable(Mon_Projet
|
||||
Asser_Position.c
|
||||
Asser_Moteurs.c
|
||||
Commande_vitesse.c
|
||||
communication.c
|
||||
Evitement.c
|
||||
Geometrie.c
|
||||
i2c_maitre.c
|
||||
messagerie.c
|
||||
Moteurs.c
|
||||
Localisation.c
|
||||
main.c
|
||||
@ -61,3 +63,7 @@ add_custom_target(Flash
|
||||
DEPENDS Mon_Projet
|
||||
COMMAND sudo picotool load -f ${PROJECT_BINARY_DIR}/Mon_Projet.uf2
|
||||
)
|
||||
|
||||
# Suppression de la conversion automatique LF -> CRLF
|
||||
add_definitions(-DPICO_STDIO_ENABLE_CRLF_SUPPORT=0)
|
||||
|
||||
|
||||
57
main.c
57
main.c
@ -9,9 +9,11 @@
|
||||
#include "hardware/pwm.h"
|
||||
#include "Asser_Position.h"
|
||||
#include "Asser_Moteurs.h"
|
||||
#include "communication.h"
|
||||
#include "Commande_vitesse.h"
|
||||
#include "i2c_maitre.h"
|
||||
#include "Localisation.h"
|
||||
#include "messagerie.h"
|
||||
#include "Moteurs.h"
|
||||
#include "Strategie.h"
|
||||
#include "Servomoteur.h"
|
||||
@ -55,6 +57,7 @@ VL53L8CX_Configuration Dev;
|
||||
void main(void)
|
||||
{
|
||||
VL53L8CX_ResultsData Results;
|
||||
struct message_t message;
|
||||
bool fin_match = false;
|
||||
|
||||
|
||||
@ -64,10 +67,13 @@ void main(void)
|
||||
identifiant_init();
|
||||
Localisation_init(get_identifiant());
|
||||
Trajet_init(get_identifiant());
|
||||
i2c_maitre_init();
|
||||
//i2c_maitre_init();
|
||||
|
||||
Servomoteur_Init();
|
||||
|
||||
communication_init();
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t temps_ms = Temps_get_temps_ms();
|
||||
@ -81,29 +87,72 @@ void main(void)
|
||||
gpio_set_dir(LED1PIN, GPIO_OUT );
|
||||
gpio_put(LED1PIN, 1);
|
||||
|
||||
gpio_init(PICO_DEFAULT_LED_PIN);
|
||||
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT );
|
||||
gpio_put(PICO_DEFAULT_LED_PIN, 1);
|
||||
|
||||
gpio_init(TIRETTE_PIN);
|
||||
gpio_set_dir(LED1PIN, GPIO_IN);
|
||||
gpio_pull_up(TIRETTE_PIN);
|
||||
|
||||
|
||||
sleep_ms(5000);
|
||||
|
||||
printf("Demarrage...\n");
|
||||
|
||||
|
||||
// TODO: A remettre - quand on aura récupéré un capteur
|
||||
if(get_identifiant() != 0){
|
||||
multicore_launch_core1(gestion_VL53L8CX);
|
||||
//multicore_launch_core1(gestion_VL53L8CX);
|
||||
multicore_launch_core1(gestion_affichage);
|
||||
}else{
|
||||
multicore_launch_core1(gestion_affichage);
|
||||
}
|
||||
|
||||
|
||||
printf("Demarrage...\n");
|
||||
|
||||
|
||||
enum etat_trajet_t etat_trajet=TRAJET_EN_COURS;
|
||||
|
||||
while(1){
|
||||
|
||||
|
||||
communication_reception_message();
|
||||
|
||||
if(messagerie_message_disponible()){
|
||||
uint8_t id_carte, registre;
|
||||
while(messagerie_message_disponible()){
|
||||
message = messagerie_get_message();
|
||||
|
||||
if(message.type == 'b'){
|
||||
switch(message.donnees[0]){
|
||||
case 'r': // réception de données
|
||||
// Reception de données
|
||||
// données[0]: commande ('r' ici)
|
||||
// données[1]: id de la carte
|
||||
// données[2]: 1er registre
|
||||
// données[3 à tailles_données -1]: valeurs
|
||||
id_carte = message.donnees[1];
|
||||
registre = message.donnees[2];
|
||||
if(id_carte == 'D'){
|
||||
if(message.donnees[4] > 0 && message.donnees[4] < 30){
|
||||
printf("LED ON\n");
|
||||
gpio_put(PICO_DEFAULT_LED_PIN, 1);
|
||||
}else{
|
||||
printf("LED OFF\n");
|
||||
gpio_put(PICO_DEFAULT_LED_PIN, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//printf(">temps_reception:%lld\n", current_time_us - start_time_us);
|
||||
//printf(">nb_message:%u\n",nb_message);
|
||||
}
|
||||
|
||||
// Fin du match
|
||||
|
||||
if(temps_ms != Temps_get_temps_ms()){
|
||||
temps_ms = Temps_get_temps_ms();
|
||||
if(temps_ms % step_ms == 0){
|
||||
@ -144,7 +193,7 @@ void gestion_PAMI(uint32_t step_ms, int * asser_pos){
|
||||
if(get_tirette() == 1 && (Temps_get_temps_ms() - temps_tirette > 1000)){
|
||||
etat_PAMI = PAMI_FIN_TEMPO_MANUELLE;
|
||||
}
|
||||
if (Temps_get_temps_ms() - temps_tirette > 85000){
|
||||
if (Temps_get_temps_ms() - temps_tirette > 5000){
|
||||
etat_PAMI = PAMI_TRAJECTOIRE;
|
||||
temps_mouvement = Temps_get_temps_ms();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user