summaryrefslogtreecommitdiff
path: root/n/es-2007
diff options
context:
space:
mode:
authordufourj2007-05-17 17:42:49 +0000
committerdufourj2007-05-17 17:42:49 +0000
commit46a85a34f459c13e462a4d4098735fbff26964b7 (patch)
tree052a4a8cfe1a475a75e954f48898eb13cc288d91 /n/es-2007
parent76d2b0aee926d10cc6efc6c2caf555a543918b5b (diff)
* Sharp:
- add minimun value bigger thant threshold to find an obstacle.
Diffstat (limited to 'n/es-2007')
-rw-r--r--n/es-2007/src/sharp.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/n/es-2007/src/sharp.c b/n/es-2007/src/sharp.c
index 167b86b..f98a6ea 100644
--- a/n/es-2007/src/sharp.c
+++ b/n/es-2007/src/sharp.c
@@ -33,7 +33,6 @@ uint16_t sharp_values[SHARP_NUMBER];
/** Thresholds */
uint16_t sharp_threshold_high_[SHARP_NUMBER],
sharp_threshold_low_[SHARP_NUMBER];
-uint8_t sharp_old_state[SHARP_NUMBER];
/** Init this module. */
void
@@ -73,22 +72,27 @@ sharp_update_values (uint8_t sharp_num)
int8_t
sharp_analyse_values (uint8_t sharp_num)
{
+ static int8_t compt = 0;
/* Check sharp exists (prevent kernel panic) */
if (sharp_num < SHARP_NUMBER)
{
- // XXX Check more often first
if (sharp_values[sharp_num] < sharp_threshold_low_[sharp_num])
{
- sharp_old_state[sharp_num] = SHARP_CLEAR;
+ compt = 0;
return SHARP_CLEAR;
}
- if (sharp_values[sharp_num] > sharp_threshold_high_[sharp_num])
+ else
{
- sharp_old_state[sharp_num] = SHARP_OBSTACLE;
- return SHARP_OBSTACLE;
+ if (compt == 10)
+ {
+ return SHARP_OBSTACLE;
+ }
+ else
+ {
+ compt++;
+ return SHARP_CLEAR;
+ }
}
- /* If we are here, we are inside the threshold, look at previous value */
- return sharp_old_state[sharp_num];
}
return -1;
}