summaryrefslogtreecommitdiff
path: root/n/es-2006/src/main.c
diff options
context:
space:
mode:
authordufourj2006-05-13 21:59:17 +0000
committerdufourj2006-05-13 21:59:17 +0000
commit28243d592481d45eaa8c077684c164bc4fb76c9b (patch)
tree7fcf11c6d377b489a4b128bf5b1a4061e2de9d7c /n/es-2006/src/main.c
parentea6b47fd42b1e7e3d8976674d9aab4638d550dc9 (diff)
ES :
- calibration du vert - detection de couleur green/other marche - debut de detection du bleu/rouge () () (o o) (_)(_)
Diffstat (limited to 'n/es-2006/src/main.c')
-rw-r--r--n/es-2006/src/main.c80
1 files changed, 57 insertions, 23 deletions
diff --git a/n/es-2006/src/main.c b/n/es-2006/src/main.c
index 07a4a28..078fc19 100644
--- a/n/es-2006/src/main.c
+++ b/n/es-2006/src/main.c
@@ -32,28 +32,42 @@
#include "timer_main.h" /* main timer */
#include "sensor_rvb.h" /* RVB sensors management */
-#include "timer_1.h" /* timer/counter 1 */
+#include "sniff_rvb.h" /* RVB sensors analysis */
+#include "timer_1.h" /* timer/counter 1 */
+#include "others.h" /* define game color mode + jack + frontal sensor */
-#include "others.h" /* define game color mode + jack + frontal sensor */
/* Statistics for RVB sensors */
-uint8_t sensor_rvb_stat_enable[RVB_MAX_SENSOR] = { 0 };
-uint8_t sensor_rvb_stats[RVB_MAX_SENSOR] = { 0 };
+uint8_t sensor_rvb_stat_enable[RVB_MAX_SENSOR], sensor_rvb_stats[RVB_MAX_SENSOR];
+/* Statistics for RVB analysis. */
+uint8_t sniff_rvb_stat_enable[RVB_MAX_SENSOR], sniff_rvb_stats[RVB_MAX_SENSOR];
/** Call when we receive some data from proto (uart) */
void
proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
{
- uint8_t compt;
- uint16_t temp_16b;
/* This macro combine command and size in one integer. */
#define c(cmd, size) (cmd << 8 | size)
+
+ uint8_t compt;
+ uint16_t temp_16b;
+
switch (c (cmd, size))
{
/* Reset */
case c ('z', 0):
utils_reset ();
break;
+
+ /*** RVB ***/
+ /* RVB sensors configuration */
+ case c ('p', 4):
+ sensor_rvb_config (args[0], args[1], args[2]);
+ break;
+ /* RVB sniff configuration */
+ case c ('x', 1):
+ sniff_rvb_config (args[0]);
+ break;
/* RVB sensors stats */
case c ('S', 3):
temp_16b = v8_to_v16 (args[0], args[1]);
@@ -64,24 +78,27 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
break;
/* Set threshold for the differents colors */
case c ('s', 9):
- sensor_rvb_set_threshold
+ sniff_rvb_set_threshold
(args[0], v8_to_v16 (args[1], args[2]),
v8_to_v16 (args[3], args[4]), v8_to_v16 (args[5], args[6]),
v8_to_v16 (args[7], args[8]));
break;
- /* RVB sensors configuration */
- case c ('R', 3):
- sensor_rvb_config (args[0], args[1], args[2]);
- break;
/* Set current color as reference */
- case c ('r', 0):
- sensor_rvb_set_ref_color ();
+ case c ('r', 1):
+ sniff_rvb_set_ref_color (args[0]);
+ break;
+ /* Print stats if the sensor is seen */
+ case c ('A', 3):
+ temp_16b = v8_to_v16 (args[0], args[1]);
+ for (compt = 0; compt < RVB_MAX_SENSOR; compt++)
+ if (temp_16b & _BV(compt))
+ sniff_rvb_stat_enable[compt] = sniff_rvb_stats[compt] =
+ args[2];
break;
/* color mode game */
case c ('c', 0 ):
proto_send1b('c', others_selectcoul());
break;
-
// /* contact */
// case c ('t', 0 ):
// proto_send1b('t', others_contact());
@@ -121,27 +138,44 @@ main (void)
/* Enable interrupts */
sei ();
+ // XXX
+ sniff_rvb_set_threshold (RVB_SNIFF_RED, -100, -85, 725, 0);
+ sniff_rvb_set_threshold (RVB_SNIFF_BLUE, 650, -140, -1050, -950);
+
/* We are ready ! */
proto_send0 ('z');
while (1)
{
/* Wait 4.44 ms */
+ // FIXME Try to put this down and make some test before if it
+ // possible.
timer_main_wait ();
-
+
/* RVB Sensors stats */
for (compt = 0; compt < RVB_MAX_SENSOR; compt++)
if (sensor_rvb_stat_enable[compt] && !--sensor_rvb_stats[compt])
- {
- /* Re init stats system for this sensor */
- sensor_rvb_stats[compt] = sensor_rvb_stat_enable[compt];
- // FIXME useless 16 bit value.
- proto_send5w ('S', compt, sensor_rvb_values[compt][0],
- sensor_rvb_values[compt][1], sensor_rvb_values[compt][2],
- sensor_rvb_values[compt][3]);
- }
+ {
+ /* Re init stats system for this sensor */
+ sensor_rvb_stats[compt] = sensor_rvb_stat_enable[compt];
+ // FIXME useless 16 bit value.
+ proto_send5w ('S', compt, sensor_rvb_values[compt][0],
+ sensor_rvb_values[compt][1], sensor_rvb_values[compt][2],
+ sensor_rvb_values[compt][3]);
+ }
+
+ /* RVB Sensors analysis stats */
+ for (compt = 0; compt < RVB_MAX_SENSOR; compt++)
+ if (sniff_rvb_stat_enable[compt] && !--sniff_rvb_stats[compt])
+ {
+ /* Re init stats system for this sensor */
+ sniff_rvb_stats[compt] = sniff_rvb_stat_enable[compt];
+ proto_send2b ('A', compt, sniff_rvb_analysis_color (compt, RVB_SNIFF_ALL_COLORS));
+ }
/* Update RVB sensors data. */
sensor_rvb_start_capture ();
+ /* Update all the asserv pin comunication */
+// sensor_rvb_update_asserv_pins ();
/* Get data for serial port */
while (uart0_poll ())