summaryrefslogtreecommitdiff
path: root/n/es-2006/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'n/es-2006/src/main.c')
-rw-r--r--n/es-2006/src/main.c47
1 files changed, 40 insertions, 7 deletions
diff --git a/n/es-2006/src/main.c b/n/es-2006/src/main.c
index 8320bfd..856343f 100644
--- a/n/es-2006/src/main.c
+++ b/n/es-2006/src/main.c
@@ -38,6 +38,7 @@
#include "servo_motor.h"/* Servo motor module */
#include "sharp.h" /* SHarps module */
#include "lcd.h" /* Communication with the LCD card */
+#include "ack.h" /* Ack module */
#include "barillet.h"
/* Statistics for RVB sensors */
@@ -65,6 +66,11 @@ uint8_t twi_buffer_read;
/* Keyboard LCD update frequency */
uint8_t lcd_key_enable, lcd_key_freq;
+/* Enable stat for ack */
+uint8_t main_ack_freq = 0xFF;
+uint8_t main_ack_enable = 0xFF;
+uint8_t ack_value;
+
/** Call when we receive some data from proto (uart) */
void
proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
@@ -86,11 +92,21 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
main_stats_freq = main_stats_enable = args[0];
break;
+ case c ('f', 0):
+ /* Shut up ! */
+ ack_reset ();
+ main_ack_freq = 1;
+ break;
+
+ case c ('F', 1):
+ /* Change the frequency of ack */
+ main_ack_enable = main_ack_freq = args[0];
+ break;
+
/*** RVB ***/
/* RVB sensors configuration */
- case c ('p', 3):
- temp_16b = v8_to_v16 (args[1], args[2]);
- sensor_rvb_config (args[0], temp_16b);
+ case c ('p', 2):
+ sensor_rvb_config (args[0], args[1]);
break;
/* RVB sniff configuration */
case c ('x', 5):
@@ -112,7 +128,7 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
if (temp_16b & _BV(compt))
sniff_rvb_set_ref_color (compt, args[2]);
break;
- /* Print stats if the sensor is seen */
+ /* Print stats of the colour seen by the sensor */
case c ('A', 3):
temp_16b = v8_to_v16 (args[0], args[1]);
for (compt = 0; compt < RVB_MAX_SENSOR; compt++)
@@ -129,6 +145,7 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
case c ('u', 1):
sensor_rvb_upper_sensors (args[0]);
break;
+
/* contact */
case c ('c', 0 ):
proto_send1b ('c', others_contact());
@@ -162,7 +179,11 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
case c ('H', 2):
for (compt = 0; compt < SHARP_NUMBER; compt++)
if (args[0] & _BV(compt))
- sharp_stat_enable[compt] = sharp_stat_freq[compt] = args[1];
+ sharp_stat_enable[compt] = sharp_stat_freq[compt] = args[1];
+ break;
+ case c ('o', 5):
+ sharp_config_threshold (args[0], v8_to_v16 (args[1], args[2]),
+ v8_to_v16 (args[3], args[4]));
break;
/* LCD */
@@ -179,7 +200,7 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
break;
/* tests primaires pour le barillet */
- case c('v',3):
+ case c ('v',3):
temp_16b = v8_to_v16 (args[1], args[2]);
vitesse_turbine( args[0], temp_16b);
break;
@@ -272,6 +293,18 @@ main (void)
main_stats[0] = TCNT0;
+ /* Ack management */
+ compt = ack_get ();
+ if (compt)
+ if (main_ack_enable && !--main_ack_freq)
+ {
+ main_ack_freq = main_ack_enable;
+ proto_send1b ('F', compt);
+ }
+
+ /* Front contact */
+ others_contact_update ();
+
/* RVB Sensors stats */
for (compt = 0; compt < RVB_MAX_SENSOR; compt++)
{
@@ -300,7 +333,7 @@ main (void)
{
/* Re init stats system for this sensor */
sniff_ball_stats[compt] = sniff_ball_stat_enable[compt];
- proto_send2b ('B', compt, sniff_rvb_analysis_ball (compt + 7));
+ proto_send2b ('B', compt + 7, sniff_rvb_analysis_ball (compt + 7));
}
main_stats[1] = TCNT0;