From 28e37e37d7644314ec858b4bc9bc46622bb4567f Mon Sep 17 00:00:00 2001 From: dalmais Date: Sun, 1 May 2005 10:37:45 +0000 Subject: version corrigé avec le twi mis en général, 100 balles et 1 mars pour clément, fusion avec les corrections de tb --- n/es/src/main.c | 64 ++++++++++++++++++++++++++++++++--------------------- n/es/src/tourelle.c | 2 -- 2 files changed, 39 insertions(+), 27 deletions(-) (limited to 'n') diff --git a/n/es/src/main.c b/n/es/src/main.c index fc49dc7..ebee300 100644 --- a/n/es/src/main.c +++ b/n/es/src/main.c @@ -49,6 +49,15 @@ uint8_t ascenseur; uint8_t ventouse; uint8_t pont; uint8_t nb_valeur_socle = 0; +uint8_t socle = 1; +uint8_t pin_socle1 = 0; +uint8_t pin_socle2 = 0; +uint8_t valeur_socle1 = 0; +uint8_t valeur_socle2 = 0; +uint8_t SEUIL_SOCLE = 100; +uint8_t tableau_socle[16]; +uint8_t temp = 0; +uint8_t etat_socle = 0; int main (void) { @@ -77,7 +86,6 @@ int main (void) sei (); // on met les interruptions - rs232_putc('I'); // fin de l'initialisation /// programme principal @@ -119,7 +127,6 @@ int main (void) while(!adc_checkf()){} tableau_sharp[compteur]=adc_read(); - twi_update ((uint8_t *) tableau_sharp,6); // renoie des valeurs sur le I2C } } @@ -136,6 +143,30 @@ int main (void) PORTB &= ~_BV (1); } } + + + if (socle == 1) // active les fonctions liées au socle. + { + adc_start (pin_socle1); // pin socle1 sélectionnée + while(!adc_checkf()){} + valeur_socle1 = adc_read(); + + adc_start (pin_socle2); // pin socle2 sélectionnée + while(!adc_checkf()){} + valeur_socle2 = adc_read(); + + nb_valeur_socle++; + if(valeur_socle1 > SEUIL_SOCLE || valeur_socle2 > SEUIL_SOCLE) tableau_socle[nb_valeur_socle & 15] = 1; + else tableau_socle[nb_valeur_socle & 15] = 0; + + + for(temp = 0; temp < 16 ;temp++) + etat_socle = tableau_socle[temp]; + + tableau_sharp[6] = etat_socle >> 3; + // twi_update ((uint8_t *) (etat_socle >> 3)); // RASSEMBLER TOUS LES CAPTEURS DANS 1 TWI + } + switch(asc_message) /* Affiche les messages de retour de l'ascenceur : 1 ascenseur en haut en attente. @@ -149,30 +180,13 @@ int main (void) case 2 : proto_send0('E'); break; } -// Stuff a Snayle qui compile pas :-( -// -// if (socle) // active les fonctions liées au socle. -// { -// adc_start (pin_socle1); // pin socle1 sélectionnée -// while(!adc_checkf()){} -// valeur_socle1 = adc_read(); -// -// adc_start (pin_socle2); // pin socle2 sélectionnée -// while(!adc_checkf()){} -// valeur_socle2 = adc_read(); -// -// nb_valeur_socle++; -// if(valeur_socle1 > SEUIL_SOCLE || valeur_socle2 > SEUIL_SOCLE) tableau_socle[nb_valeur_socle & 15] = 1; -// else tableau_socle[nb_valeur_socle & 15] = 0; -// -// -// for(temp = 0; temp < 16 ;temp++) -// valeur_socle = tableau_socle[temp]; -// -// twi_update ((uint8_t *) valeur >> 3) -// } } - + + if (socle == 1 && pont == 1) twi_update ((uint8_t *) tableau_sharp,7); + if (socle == 1 && pont == 0) twi_update ((uint8_t *) &(tableau_sharp[6]),1); + if (socle == 0 && pont == 1) twi_update ((uint8_t *) tableau_sharp,6); + + } return 0; } diff --git a/n/es/src/tourelle.c b/n/es/src/tourelle.c index d677c6f..80b9610 100644 --- a/n/es/src/tourelle.c +++ b/n/es/src/tourelle.c @@ -70,7 +70,6 @@ void tourelle_init (uint16_t prescaler) SFIOR |= 0x01; // prescaler autorisé - rs232_putc('T'); crenaux(delay,port_tourelle,pin_tourelle); // on met le capteur à 0° delay_ms(20L); @@ -93,7 +92,6 @@ void tourelle_init (uint16_t prescaler) pont = 1; ascenseur = 1; - rs232_putc('F'); switch(prescaler) { -- cgit v1.2.3