summaryrefslogtreecommitdiff
path: root/n
diff options
context:
space:
mode:
Diffstat (limited to 'n')
-rw-r--r--n/es/src/Makefile2
-rw-r--r--n/es/src/main.c18
-rw-r--r--n/es/src/tourelle.c11
-rw-r--r--n/es/src/tourelle.h2
4 files changed, 20 insertions, 13 deletions
diff --git a/n/es/src/Makefile b/n/es/src/Makefile
index dadafda..bde642d 100644
--- a/n/es/src/Makefile
+++ b/n/es/src/Makefile
@@ -1,5 +1,5 @@
PROGS = es
-es_OBJECTS = main.o rs232.o tourelle.o adc.o twi_slave.o
+es_OBJECTS = main.o rs232.o tourelle.o adc.o twi_slave.o proto.o
DOC =
EXTRACTDOC =
MODULES = n/avr/rs232 n/avr/carte_capteur n/avr/utils n/avr/adc n/avr/proto n/avr/twi-slave
diff --git a/n/es/src/main.c b/n/es/src/main.c
index bcb123c..35feb5f 100644
--- a/n/es/src/main.c
+++ b/n/es/src/main.c
@@ -39,6 +39,8 @@ uint8_t envoie = 0; // demande fait par I2C d'un envoi
char buffer_serie ; // buffer RS232
const uint16_t prescaler = 8;// prescaler
uint16_t tableau_longueur[25];
+uint16_t SEUIL = 0x01AF;
+uint8_t mesure = 0;
int main (void)
{
@@ -58,7 +60,7 @@ int main (void)
sei (); // on met les interruptions
- rs232_putc('1'); // fin de l'initialisation
+ rs232_putc('I'); // fin de l'initialisation
/// programme principal
@@ -66,20 +68,26 @@ int main (void)
{
if(etat == 1)
{
- rs232_putc('2');
etat = 0;
- // METTRE L'ACTIVATION DE L'INTERRUPTION
- TCNT1 = 5; //(65535L - ((20L*14745600L)/(1024L*1000L))); // LE PASSER EN COMPARATEUR.
+ TCNT1 = 115; //(65535L - ((20L*14745600L)/(1024L*1000L))); // LE PASSER EN COMPARATEUR.
if(temp_sens != sens)
{
- rs232_putc('S');
temp_sens = sens;
// if(continu == 1) renvoi_RS232(); // nom de la fonction qui renvoie la valeur
}
// if(buffer_serie != 0) callback_RS232();
TIMSK |= 0x04;
}
+
+ if(mesure == 1)
+ {
+ tableau_longueur[0]=mesurer();
+ if(tableau_longueur[0] > SEUIL)
+ proto_send1w ('S',tableau_longueur[0]);
+// else
+// proto_send1w ('P',tableau_longueur[0]);
+ }
for(compteur=0;compteur<3;compteur++)
{
diff --git a/n/es/src/tourelle.c b/n/es/src/tourelle.c
index 62f037f..d906853 100644
--- a/n/es/src/tourelle.c
+++ b/n/es/src/tourelle.c
@@ -28,7 +28,7 @@ const uint8_t delayMax = 125;
const uint8_t delayMin = 175;
const uint8_t pin_sharp = 3 ;
uint8_t delay = 0;
-const uint8_t SEUIL = 280; // 10 cm = 2.25V et 80 cm = 1.75 V
+//extern uint16_t SEUIL = 280; // 10 cm = 2.25Vnet 80 cm = 1.75 V
const uint8_t MILIEU = 2;
// const int8_t PROUT = 12; A VERIFIER !!
@@ -49,6 +49,8 @@ extern uint8_t envoie;
extern uint8_t sens;
+extern uint8_t mesure;
+
uint8_t valeur_actuelle1 = 0;
uint8_t valeur_actuelle2 = 0;
uint8_t angle_actuel1 = 0;
@@ -130,10 +132,9 @@ void crenaux(uint8_t temps, uint8_t port, uint8_t pin)
delay_us(10L);
}
PORTD &= ~_BV (7); // on remet l'impulsion à 0
- rs232_putc('C');
}
-void rs232_callback (uint8_t cmd, uint8_t size,uint8_t* args)
+void proto_callback (uint8_t cmd, uint8_t size,uint8_t* args)
{
#define c(cmd, size) (cmd << 8 | size)
switch (c (cmd, size))
@@ -200,14 +201,12 @@ SIGNAL (SIG_OVERFLOW1)
TIMSK &= ~(0x04);
- rs232_putc('3');
for(i=0;i<(MILIEU*2+1);i++)
{
if(temp < tableau_longueur [i]) temp = tableau_longueur[i];
}
tableau_longueur[0] = mesurer();
- proto_send1w ('S',tableau_longueur[0]);
/*
if(temp == tableau_longueur[MILIEU+1] && temp > SEUIL )
{
@@ -233,6 +232,6 @@ SIGNAL (SIG_OVERFLOW1)
TournerTourelle ();
etat = 1;
- rs232_putc('4');
+ mesure = 1;
}
diff --git a/n/es/src/tourelle.h b/n/es/src/tourelle.h
index 79091b8..1e6ffca 100644
--- a/n/es/src/tourelle.h
+++ b/n/es/src/tourelle.h
@@ -32,7 +32,7 @@
void tourelle_init (uint16_t prescaler);
void crenaux(uint8_t temps, uint8_t port, uint8_t pin);
-void rs232_callback (uint8_t cmd, uint8_t size, uint8_t *args);
+void proto_callback (uint8_t cmd, uint8_t size, uint8_t *args);
void TournerTourelle(void);
int16_t mesurer(void);
void Timer_tourelle(void);