Ca marche 2025
This commit is contained in:
parent
6843d46b93
commit
fa7bacdc9b
78
main.c
78
main.c
@ -30,11 +30,23 @@
|
||||
#define ASCENSEUR_LACHE_POT_JARDINIERE 2
|
||||
#define ASCENSEUR_LACHE_PLANTE 2
|
||||
|
||||
#define STATU_PINCE_TIENT 0
|
||||
#define STATU_PINCE_LACHE 1
|
||||
|
||||
#define STATU_CAME_POUSSE 0
|
||||
#define STATU_CAME_NEUTRE 1
|
||||
|
||||
#define STATU_BANDEROLLE_DEPLIE 0
|
||||
#define STATU_BANDEROLLE_NEUTRE 1
|
||||
|
||||
|
||||
unsigned result0, result1;
|
||||
int joystic_clicker;
|
||||
int pince;
|
||||
int ascenseur;
|
||||
|
||||
static uint8_t etat_bouton[32]={1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1};
|
||||
|
||||
void init_bouton(uint8_t bouton)
|
||||
{
|
||||
gpio_init(bouton);
|
||||
@ -58,12 +70,14 @@ int Adc_Read(short input)
|
||||
|
||||
bool bouton_appui(uint8_t button)
|
||||
{
|
||||
static uint8_t etat_bouton[32]={1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1};
|
||||
bool retour;
|
||||
|
||||
|
||||
bool is_button_pressed = gpio_get(button);
|
||||
|
||||
retour = is_button_pressed && (is_button_pressed != etat_bouton[button]);
|
||||
etat_bouton[button] = is_button_pressed;
|
||||
|
||||
return is_button_pressed && is_button_pressed != etat_bouton[button];
|
||||
return retour;
|
||||
}
|
||||
|
||||
void main()
|
||||
@ -72,6 +86,9 @@ void main()
|
||||
|
||||
// Communication
|
||||
char message [256];
|
||||
char statu_pince;
|
||||
char statu_came;
|
||||
char statu_banderolle;
|
||||
communication_init();
|
||||
|
||||
// ADC
|
||||
@ -104,6 +121,9 @@ void main()
|
||||
|
||||
// Set rotation speed according to DA rotations buttons
|
||||
message[2] = 128 - 95 * (gpio_get(PIN_BUTTON_LEFT_ROTATION) - gpio_get(PIN_BUTTON_RIGHT_ROTATION));
|
||||
message[3] = statu_pince;
|
||||
message[4] = statu_banderolle;
|
||||
message[5] = statu_came;
|
||||
/*
|
||||
// Voie X
|
||||
result1 = AdcRead(1) / 16;
|
||||
@ -141,40 +161,34 @@ void main()
|
||||
// Pince
|
||||
// Bouton plante
|
||||
if(bouton_appui(6)){
|
||||
if(pince == PINCE_OUVERTE)
|
||||
{
|
||||
pince = PINCE_POT;
|
||||
}
|
||||
else
|
||||
{
|
||||
pince = PINCE_OUVERTE;
|
||||
if(statu_pince == STATU_PINCE_TIENT){
|
||||
statu_pince = STATU_PINCE_LACHE;
|
||||
}else{
|
||||
statu_pince = STATU_PINCE_TIENT;
|
||||
}
|
||||
}else{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Bouton Pot
|
||||
if(bouton_appui(10))
|
||||
{
|
||||
if(pince == PINCE_OUVERTE)
|
||||
{
|
||||
pince = PINCE_PLANTE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pince = PINCE_OUVERTE;
|
||||
if(bouton_appui(10)){
|
||||
if(statu_came == STATU_CAME_POUSSE){
|
||||
statu_came = STATU_CAME_NEUTRE;
|
||||
}else{
|
||||
statu_came = STATU_CAME_POUSSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Ascenseur
|
||||
// Commande simple
|
||||
if(bouton_appui(2))
|
||||
{
|
||||
if(ascenseur == ASCENSEUR_HAUT)
|
||||
{
|
||||
ascenseur = ASCENSEUR_BAS;
|
||||
}
|
||||
else
|
||||
{
|
||||
ascenseur = ASCENSEUR_HAUT;
|
||||
if(statu_banderolle == STATU_BANDEROLLE_DEPLIE){
|
||||
statu_banderolle = STATU_BANDEROLLE_NEUTRE;
|
||||
}else{
|
||||
statu_banderolle = STATU_BANDEROLLE_DEPLIE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,15 +232,17 @@ void main()
|
||||
}
|
||||
}
|
||||
|
||||
message[3] = pince;
|
||||
message[4] = ascenseur;
|
||||
|
||||
//printf(">x:%d\n", message[0]);
|
||||
//printf(">Y:%d\n", message[1]);
|
||||
printf(">Rz:%d\n", message[2]);
|
||||
printf(">pince:%d\n", message[3]);
|
||||
printf(">pince:%d\n", message[2]);
|
||||
printf(">banderole:%d\n", message[3]);
|
||||
printf(">ascenseur:%d\n", message[4]);
|
||||
//printf(">result0:%d\n", result0);
|
||||
printf(">came:%d\n", message[5]);
|
||||
//printf(">c10_1:%d\n", gpio_get(10));
|
||||
//printf(">b10:%d\n", bouton_appui(10));
|
||||
//printf(">etat_10:%d\n", etat_bouton[10]);
|
||||
|
||||
|
||||
communication_envoyer_message(message, 254);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user