summaryrefslogtreecommitdiff
path: root/n/es-2006/src
diff options
context:
space:
mode:
authordufourj2006-05-16 23:58:09 +0000
committerdufourj2006-05-16 23:58:09 +0000
commite8634493098188f1a33dfa491a8bfa4b6e5dbd35 (patch)
tree672469a313b11275c38265ec370ae91302d2b8ad /n/es-2006/src
parentbc5944190b7ae0af55caa84f86d63bf95e40712f (diff)
ES :
- ajout du support des servo moteurs ; - import d'une partie des modifications d'Olivier à la pré-coupe sur l'analyse des capteurs rvb ; - import de la gestion de l'eeprom. TODO : - terminer les imports de la pré-coupe ; - mettre eeprom avec un .h ; - corriger l'interruption qui dure 1.4ms.
Diffstat (limited to 'n/es-2006/src')
-rw-r--r--n/es-2006/src/Makefile2
-rw-r--r--n/es-2006/src/main.c16
-rw-r--r--n/es-2006/src/sensor_eeprom.c89
-rw-r--r--n/es-2006/src/sensor_rvb.c6
-rw-r--r--n/es-2006/src/servo_motor.c162
-rw-r--r--n/es-2006/src/servo_motor.h52
-rw-r--r--n/es-2006/src/sniff_rvb.c92
-rw-r--r--n/es-2006/src/sniff_rvb.h15
8 files changed, 401 insertions, 33 deletions
diff --git a/n/es-2006/src/Makefile b/n/es-2006/src/Makefile
index ef1aba9..8abab90 100644
--- a/n/es-2006/src/Makefile
+++ b/n/es-2006/src/Makefile
@@ -1,6 +1,6 @@
BASE = ../../avr
PROGS = es
-es_SOURCES = main.c sensor_rvb.c sniff_rvb.c timer_1.c barillet.c
+es_SOURCES = main.c sensor_rvb.c sniff_rvb.c timer_1.c barillet.c servo_motor.c
MODULES = proto uart utils
CONFIGFILE = avrconfig.h
# atmega8, atmega8535, atmega128...
diff --git a/n/es-2006/src/main.c b/n/es-2006/src/main.c
index 8edfb78..c65fd55 100644
--- a/n/es-2006/src/main.c
+++ b/n/es-2006/src/main.c
@@ -35,7 +35,9 @@
#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 "sensor_eeprom.c"
#include "barillet.h"
+#include "servo_motor.h"
/* Statistics for RVB sensors */
@@ -103,6 +105,18 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
case c ('c', 0 ):
proto_send1b('c', others_selectcoul());
break;
+ /* Load sniff values from eeprom */
+ case c ('l', 0):
+ sensor_eeprom_read_params ();
+ break;
+ /* saVe sniff values from eeprom */
+ case c ('v', 0):
+ sensor_eeprom_write_params ();
+ break;
+ /* Communication with the servo motor */
+ case c ('m', 2):
+ servo_motor_set_pos (args[0], args[1]);
+ break;
// /* contact */
// case c ('TTTTTTTTTTt', 0 ):
// proto_send1b('t', others_contact());
@@ -175,6 +189,8 @@ main (void)
others_init();
/* barillet init */
barillet_init();
+ /* Servo motor init */
+ servo_motor_init ();
/* Enable interrupts */
sei ();
diff --git a/n/es-2006/src/sensor_eeprom.c b/n/es-2006/src/sensor_eeprom.c
new file mode 100644
index 0000000..c9bcdc1
--- /dev/null
+++ b/n/es-2006/src/sensor_eeprom.c
@@ -0,0 +1,89 @@
+/* sniff_eeprom.c */
+/* es - Input/Output general purpose board. {{{
+ *
+ * Copyright (C) 2006 Dufour Jérémy
+ *
+ * Robot APB Team/Efrei 2004.
+ * Web: http://assos.efrei.fr/robot/
+ * Email: robot AT efrei DOT fr
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * }}} */
+
+#include <avr/eeprom.h>
+
+/* Change the eeprom key each time you change eeprom format. */
+#define EEPROM_KEY 0x45
+#define EEPROM_START 256
+
+/* +AutoDec */
+/* -AutoDec */
+
+/* Read parameters from eeprom. */
+static void
+sensor_eeprom_read_params (void)
+{
+ uint8_t *p8 = (uint8_t *) EEPROM_START;
+ uint16_t *p16;
+ uint8_t sensor, compt, color;
+ if (eeprom_read_byte (p8++) != EEPROM_KEY)
+ return;
+ p16 = (uint16_t *) p8;
+ for (sensor = 0; sensor < RVB_MAX_SENSOR; sensor++)
+ for (compt = 0; compt < RVB_SNIFF_MAX_INDEX; compt++)
+ sniff_rvb_reference_color[sensor][compt] = eeprom_read_word (p16++);
+ for (color = 0; color < 2; color++)
+ for (sensor = 0; sensor < RVB_MAX_SENSOR; sensor++)
+ for (compt = 0; compt < RVB_SNIFF_MAX_INDEX; compt++)
+ sniff_rvb_threshold[color][sensor][compt] = eeprom_read_word (p16++);
+ p8 = (uint8_t *) p16;
+ for (color = 0; color < 2; color++)
+ for (sensor = 0; sensor < RVB_MAX_SENSOR; sensor++)
+ for (compt = 0; compt < RVB_SNIFF_MAX_INDEX; compt++)
+ sniff_rvb_sign[color][sensor][compt] = eeprom_read_byte (p8++);
+}
+
+/* Write parameters to eeprom. */
+static void
+sensor_eeprom_write_params (void)
+{
+ uint8_t *p8 = (uint8_t *) EEPROM_START;
+ uint16_t *p16;
+ uint8_t sensor, compt, color;
+ eeprom_write_byte (p8++, EEPROM_KEY);
+ p16 = (uint16_t *) p8;
+ for (sensor = 0; sensor < RVB_MAX_SENSOR; sensor++)
+ for (compt = 0; compt < RVB_SNIFF_MAX_INDEX; compt++)
+ eeprom_write_word (p16++, sniff_rvb_reference_color[sensor][compt]);
+ for (color = 0; color < 2; color++)
+ for (sensor = 0; sensor < RVB_MAX_SENSOR; sensor++)
+ for (compt = 0; compt < RVB_SNIFF_MAX_INDEX; compt++)
+ eeprom_write_word (p16++, sniff_rvb_threshold[color][sensor][compt]);
+ p8 = (uint8_t *) p16;
+ for (color = 0; color < 2; color++)
+ for (sensor = 0; sensor < RVB_MAX_SENSOR; sensor++)
+ for (compt = 0; compt < RVB_SNIFF_MAX_INDEX; compt++)
+ eeprom_write_byte (p8++, sniff_rvb_sign[color][sensor][compt]);
+}
+
+/* Clear eeprom parameters. */
+// static void
+// sensor_eeprom_clear_params (void)
+// {
+// uint8_t *p = (uint8_t *) EEPROM_START;
+// eeprom_write_byte (p, 0xff);
+// }
+
diff --git a/n/es-2006/src/sensor_rvb.c b/n/es-2006/src/sensor_rvb.c
index f81b33b..f53c324 100644
--- a/n/es-2006/src/sensor_rvb.c
+++ b/n/es-2006/src/sensor_rvb.c
@@ -30,6 +30,7 @@
#include "modules/proto/proto.h"
#include "sniff_rvb.h"
+
/**
* Somes defines.
**/
@@ -76,10 +77,11 @@ volatile uint8_t sensor_rvb_overflow_count_;
/** Results table for 9 RVB sensors (RVCB) */
volatile uint16_t sensor_rvb_values[RVB_MAX_SENSOR][4];
/** Count the number of IC before starting a good capture. */
+
uint8_t sensor_rvb_ic_count_;
/** Update everything for you. */
-void sensor_rvb_update (void);
+inline void sensor_rvb_update (void);
/** Select a color :
* 0 : red ;
@@ -190,7 +192,7 @@ sensor_rvb_start_capture (void)
}
/** Update everything for you. */
-void
+inline void
sensor_rvb_update (void)
{
if (sensor_rvb_state_ == RVB_STATE_NEXT_COLOR)
diff --git a/n/es-2006/src/servo_motor.c b/n/es-2006/src/servo_motor.c
new file mode 100644
index 0000000..d01ceac
--- /dev/null
+++ b/n/es-2006/src/servo_motor.c
@@ -0,0 +1,162 @@
+/* servo_motor.c */
+/* es - Input/Output general purpose board. {{{
+ *
+ * Copyright (C) 2006 Dufour Jérémy
+ *
+ * Robot APB Team/Efrei 2004.
+ * Web: http://assos.efrei.fr/robot/
+ * Email: robot AT efrei DOT fr
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * }}} */
+#include "servo_motor.h"
+
+#include "io.h"
+#include "common.h"
+#include "modules/utils/utils.h"
+#include "modules/utils/byte.h"
+
+/** TOP of the timer/counter 2. */
+#define TC2_TOP 0xFF
+/** Prescaler of the timer/counter2. */
+#define TC2_PRESCALER 256
+/** Delay a full cycle in TIC before restarting should last (in 100µs). */
+/* time * AC_FREQ / TC2_PRESCALER */
+#define SRVM_CYCLE_DELAY 1152
+/** The servo motor identifier. */
+#define SRVM_TRASH_PIN 0 /* the trash system */
+#define SRVM_TOTEML_PIN 3 /* first totem */
+#define SRVM_TOTEMR_PIN 2 /* second totem */
+/** Table for the time spend by each servo in high position. */
+volatile uint8_t servo_time[3] = { SRVM_POS_IN, SRVM_POS_IN, SRVM_POS_IN };
+/** Different states of this module. */
+enum ServoMotorState
+{
+ sleeping = 0,
+ trash,
+ totem_1,
+ totem_2
+};
+/** State variable. */
+volatile enum ServoMotorState servo_motor_state;
+/** Time the TC2 have to sleep after manage all the servo motor. */
+volatile uint16_t srvm_need_to_sleep;
+
+/** Init the servo motor system. */
+void
+servo_motor_init (void)
+{
+ /* All the pins are in out mode */
+ DDRB |= _BV (SRVM_TRASH_PIN) | _BV (SRVM_TOTEML_PIN) |
+ _BV (SRVM_TOTEMR_PIN);
+ /* We are sleeping */
+ servo_motor_state = sleeping;
+ /* Prescaler 256 => 4.44 ms TOP */
+ TCCR2 = regv (FOC2, WGM20, COM21, COM20, WGM21, CS22, CS21, CS20,
+ 0, 0, 0, 0, 0, 1, 0, 0);
+ /* Enable overflow interrupt */
+ TIMSK |= _BV (TOIE2);
+ /* Iniate to delay */
+ srvm_need_to_sleep = SRVM_CYCLE_DELAY;
+}
+
+/** Ask the servo motor to go to a position. */
+void
+servo_motor_set_pos (uint8_t servo_num, uint8_t servo_pos)
+{
+ uint8_t num;
+ /* for each servo motor */
+ for (num = 0; num < 3; num++)
+ if (servo_num & _BV (num))
+ {
+ /* Set the value and bound it */
+ servo_time[num] = servo_pos;
+ UTILS_BOUND (servo_time[num], SRVM_POS_IN,
+ SRVM_POS_OUT);
+ }
+}
+
+/** What is your current position my dear servo motor ? */
+inline uint8_t
+servo_motor_get_pos (uint8_t servo_num)
+{
+ return servo_time[servo_num];
+}
+
+SIGNAL (SIG_OVERFLOW2)
+{
+ /* Overflow count for time sleeping */
+ static int8_t srvm_ov_for_sleeping = -1;
+
+ switch (servo_motor_state)
+ {
+ case sleeping:
+ /* We remove from the TOP the number of TIC of this servo */
+ TCNT2 = TC2_TOP - servo_time[servo_motor_state];
+ /* We activate the pin */
+ PORTB |= _BV (SRVM_TRASH_PIN);
+ /* We remove the TIC of this servo from the main one */
+ srvm_need_to_sleep -= servo_time[servo_motor_state];
+ /* Next state */
+ servo_motor_state = trash;
+ break;
+ case trash:
+ /* We remove from the TOP the number of TIC of this servo */
+ TCNT2 = TC2_TOP - servo_time[servo_motor_state];
+ /* Unactivate previous pin */
+ PORTB &= ~_BV (SRVM_TRASH_PIN);
+ /* We activate the pin */
+ PORTB |= _BV (SRVM_TOTEML_PIN);
+ /* We remove the TIC of this servo from the main one */
+ srvm_need_to_sleep -= servo_time[servo_motor_state];
+ /* Next state */
+ servo_motor_state = totem_1;
+ break;
+ case totem_1:
+ /* We remove from the TOP the number of TIC of this servo */
+ TCNT2 = TC2_TOP - servo_time[servo_motor_state];
+ /* Unactivate previous pin */
+ PORTB &= ~_BV (SRVM_TOTEML_PIN);
+ /* We activate the pin */
+ PORTB |= _BV (SRVM_TOTEMR_PIN);
+ /* We remove the TIC of this servo from the main one */
+ srvm_need_to_sleep -= servo_time[servo_motor_state];
+ /* Next state */
+ servo_motor_state = totem_2;
+ break;
+ case totem_2:
+ if (srvm_ov_for_sleeping == -1)
+ {
+ /* We need to wait some TIC */
+ TCNT2 = TC2_TOP - v16_to_v8 (srvm_need_to_sleep, 0);
+ /* Unactivate previous pin */
+ PORTB &= ~_BV (SRVM_TOTEMR_PIN);
+ /* Calculate the OV */
+ srvm_ov_for_sleeping = srvm_need_to_sleep >> 8;
+ }
+ else
+ {
+ if (--srvm_ov_for_sleeping == -1)
+ {
+ /* Next state */
+ servo_motor_state = sleeping;
+ /* Re init */
+ srvm_need_to_sleep = SRVM_CYCLE_DELAY;
+ }
+ }
+ break;
+ }
+}
diff --git a/n/es-2006/src/servo_motor.h b/n/es-2006/src/servo_motor.h
new file mode 100644
index 0000000..ebece15
--- /dev/null
+++ b/n/es-2006/src/servo_motor.h
@@ -0,0 +1,52 @@
+#ifndef servo_motor_h
+#define servo_motor_h
+// servo_motor.h
+// es - Input/Output general purpose board. {{{
+//
+// Copyright (C) 2006 Dufour Jérémy
+//
+// Robot APB Team/Efrei 2004.
+// Web: http://assos.efrei.fr/robot/
+// Email: robot AT efrei DOT fr
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// }}}
+
+/** Module for controlling the servo motor for the totems. */
+
+#include "common.h"
+
+/** All the states used to comunicate with this module. */
+#define SRVM_POS_IN 40
+#define SRVM_POS_OUT 143
+#define SRVM_POS_MIDDLE 91
+
+/** Init the servo motor system. */
+void servo_motor_init (void);
+
+/** Ask the servo motor to go to a position.
+ * - servo_num : mask for sensor ;
+ * - servo_pos : desired position.
+ */
+void servo_motor_set_pos (uint8_t servo_nun, uint8_t servo_pos);
+
+/** What is your current position my dear servo motor ?
+ * - servo_num : sensor number (not a mask) ;
+ * - return : desired position.
+ */
+uint8_t servo_motor_get_pos (uint8_t servo_num);
+
+#endif // servo_motor_h
diff --git a/n/es-2006/src/sniff_rvb.c b/n/es-2006/src/sniff_rvb.c
index c819efe..5941316 100644
--- a/n/es-2006/src/sniff_rvb.c
+++ b/n/es-2006/src/sniff_rvb.c
@@ -25,6 +25,7 @@
#include "sniff_rvb.h"
#include "io.h"
+#include "string.h"
#include "common.h"
#include "modules/proto/proto.h"
#include "modules/utils/byte.h"
@@ -34,7 +35,10 @@
/** Reference color. */
uint16_t sniff_rvb_reference_color[RVB_MAX_SENSOR][RVB_SNIFF_MAX_INDEX];
/** Threshold table data. */
-int16_t sniff_rvb_threshold_table[RVB_MAX_SENSOR][RVB_SNIFF_MAX_INDEX];
+uint16_t sniff_rvb_threshold[2][RVB_MAX_SENSOR][RVB_SNIFF_MAX_INDEX];
+/** Used to build threshold */
+// XXX only bool needed, use bit operation if we need to use less space
+uint8_t sniff_rvb_sign[2][RVB_MAX_SENSOR][RVB_SNIFF_MAX_INDEX];
/** Ratio min max */
uint16_t sniff_rvb_reference_color_min[RVB_MAX_SENSOR][RVB_SNIFF_MAX_INDEX];
uint16_t sniff_rvb_reference_color_max[RVB_MAX_SENSOR][RVB_SNIFF_MAX_INDEX];
@@ -53,22 +57,22 @@ sniff_rvb_try_reference (uint8_t sensor_num, uint16_t
ref[RVB_MAX_SENSOR][RVB_SNIFF_MAX_INDEX])
{
uint8_t compt;
- //
-
/* If sensor is valid */
if (sensor_rvb_values[sensor_num][0] != 0)
{
/* For each color add this value by averrage */
for (compt = 0; compt < RVB_SNIFF_MAX_INDEX; compt++)
- {
- if (ref[sensor_num][compt] == 0)
+ if (ref[sensor_num][compt] == 0)
+ {
ref[sensor_num][compt] =
sensor_rvb_values[sensor_num][compt];
+ }
else
+ {
ref[sensor_num][compt] =
- (sensor_rvb_values[sensor_num][compt] / 2
- + ref[sensor_num][compt] / 2);
- }
+ (sensor_rvb_values[sensor_num][compt] / 2
+ + ref[sensor_num][compt] / 2);
+ }
return !0;
}
return 0;
@@ -77,20 +81,19 @@ sniff_rvb_try_reference (uint8_t sensor_num, uint16_t
/* Test blue or red */
uint8_t
-sniff_rvb_analysis_color_other (uint8_t sensor, uint8_t color)
+sniff_rvb_analysis_color_other (uint8_t sensor, uint8_t color,
+ uint16_t threshold[RVB_SNIFF_MAX_INDEX],
+ uint8_t sign[RVB_SNIFF_MAX_INDEX])
{
uint8_t compt;
uint8_t what_is_it = color;
- for (compt = 0; compt < 4; compt++)
+ for (compt = 0; compt < RVB_SNIFF_MAX_INDEX; compt++)
{
- // XXX will be in cache table after
- uint16_t threshold = sniff_rvb_reference_color[sensor][compt]
- + sniff_rvb_threshold_table[color][compt];
// if relative threshold is positive, current value must be greater
// than the threshold
- if (sniff_rvb_threshold_table[color][compt] > 0)
+ if (sign[compt] > 0)
{
- if (sensor_rvb_values[sensor][compt] > threshold)
+ if (sensor_rvb_values[sensor][compt] > threshold[compt])
{
continue;
}
@@ -98,7 +101,7 @@ sniff_rvb_analysis_color_other (uint8_t sensor, uint8_t color)
// if negative, must be lower
else
{
- if (sensor_rvb_values[sensor][compt] < threshold)
+ if (sensor_rvb_values[sensor][compt] < threshold[compt])
{
continue;
}
@@ -130,18 +133,18 @@ sniff_rvb_analysis_color (uint8_t sensor, uint8_t mode)
if ((what_is_it == RVB_SNIFF_GREEN) || (mode == RVB_SNIFF_ONLY_GREEN))
goto sniff_rvb_set_ref_color_end;
-// XXX pb if reference too high and sum with threshold overflow
-// same pb with the cache table creation
-// XXX create cache table for blue and red
-
/* test for blue */
- if (sniff_rvb_analysis_color_other (sensor, RVB_SNIFF_BLUE) == RVB_SNIFF_BLUE)
+ if (sniff_rvb_analysis_color_other (sensor, RVB_SNIFF_BLUE,
+ sniff_rvb_threshold[RVB_THRESHOLD_BLUE][sensor],
+ sniff_rvb_sign[RVB_THRESHOLD_BLUE][sensor]) == RVB_SNIFF_BLUE)
{
what_is_it = RVB_SNIFF_BLUE;
goto sniff_rvb_set_ref_color_end;
}
/* test for red */
- if (sniff_rvb_analysis_color_other (sensor, RVB_SNIFF_RED) == RVB_SNIFF_RED)
+ if (sniff_rvb_analysis_color_other (sensor, RVB_SNIFF_RED,
+ sniff_rvb_threshold[RVB_THRESHOLD_RED][sensor],
+ sniff_rvb_sign[RVB_THRESHOLD_RED][sensor]) == RVB_SNIFF_RED)
{
what_is_it = RVB_SNIFF_RED;
goto sniff_rvb_set_ref_color_end;
@@ -179,10 +182,39 @@ sniff_rvb_set_ref_color_green (uint8_t sensor)
}
/* sub function of sniff_rvb_set_ref_color */
+/* XXX call only after the reference color initialization has been done */
void
-sniff_rvb_set_ref_color_other (uint8_t sensor)
+sniff_rvb_set_ref_color_other (uint8_t sensor, uint8_t color)
{
-
+ uint8_t compt;
+ uint16_t *threshold;
+ uint8_t *sign;
+ if (color == RVB_SNIFF_BLUE)
+ {
+ threshold = sniff_rvb_threshold[RVB_THRESHOLD_BLUE][sensor];
+ sign = sniff_rvb_sign[RVB_THRESHOLD_BLUE][sensor];
+ }
+ else
+ {
+ threshold = sniff_rvb_threshold[RVB_THRESHOLD_RED][sensor];
+ sign = sniff_rvb_sign[RVB_THRESHOLD_RED][sensor];
+ }
+ /* get sensor values */
+ /* test if valid */
+ if (sensor_rvb_values[sensor][0] != 0)
+ for (compt = 0; compt < RVB_SNIFF_MAX_INDEX; compt++)
+ {
+ /* compute threshold */
+ int16_t tmp = (sensor_rvb_values[sensor][compt]
+ - sniff_rvb_reference_color[sensor][compt]) / 2;
+ // XXX use ratio instead of 2
+ threshold[compt] = tmp + sniff_rvb_reference_color[sensor][compt];
+ /* store sign for faster processing later */
+ if (tmp > 0)
+ sign[compt] = RVB_THRESHOLD_POSITIVE;
+ else
+ sign[compt] = RVB_THRESHOLD_NEGATIVE;
+ }
}
/** Set the current color seen by some sensors as the reference color
@@ -197,7 +229,7 @@ sniff_rvb_set_ref_color (uint8_t sensor, uint8_t color)
break;
case RVB_SNIFF_RED:
case RVB_SNIFF_BLUE:
- sniff_rvb_set_ref_color_other (sensor);
+ sniff_rvb_set_ref_color_other (sensor, color);
break;
}
}
@@ -213,10 +245,10 @@ sniff_rvb_set_threshold (uint8_t color, int16_t red_ts, int16_t blue_ts,
case RVB_SNIFF_RED:
case RVB_SNIFF_BLUE:
case RVB_SNIFF_GREEN:
- sniff_rvb_threshold_table[color][0] = red_ts;
- sniff_rvb_threshold_table[color][1] = blue_ts;
- sniff_rvb_threshold_table[color][2] = clear_ts;
- sniff_rvb_threshold_table[color][3] = green_ts;
- break;
+// sniff_rvb_thresholdtable[color][0] = red_ts;
+// sniff_rvb_thresholdtable[color][1] = blue_ts;
+// sniff_rvb_thresholdtable[color][2] = clear_ts;
+// sniff_rvb_thresholdtable[color][3] = green_ts;
+ break;
}
}
diff --git a/n/es-2006/src/sniff_rvb.h b/n/es-2006/src/sniff_rvb.h
index 348a071..313af5a 100644
--- a/n/es-2006/src/sniff_rvb.h
+++ b/n/es-2006/src/sniff_rvb.h
@@ -27,6 +27,7 @@
#include "io.h"
#include "common.h"
+#include "sensor_rvb.h"
/** Analysis sensors and determine the colors. */
@@ -43,6 +44,20 @@
#define RVB_SNIFF_ALL_COLORS 1
+/** Used for blue/red test */
+#define RVB_THRESHOLD_POSITIVE 0
+#define RVB_THRESHOLD_NEGATIVE 1
+
+#define RVB_THRESHOLD_BLUE 0
+#define RVB_THRESHOLD_RED 1
+
+/** Reference color. */
+extern uint16_t sniff_rvb_reference_color[RVB_MAX_SENSOR][RVB_SNIFF_MAX_INDEX];
+/** Threshold table data. */
+extern uint16_t sniff_rvb_threshold[2][RVB_MAX_SENSOR][RVB_SNIFF_MAX_INDEX];
+/** Used to build threshold */
+extern uint8_t sniff_rvb_sign[2][RVB_MAX_SENSOR][RVB_SNIFF_MAX_INDEX];
+
/** Set the current color seen by some sensors as the reference color.
* It must be called at the begining of the match for setting the green value.
*/