summaryrefslogtreecommitdiffhomepage
path: root/digital/io-hub/src/apbirthday/rgb.stm32.cc
diff options
context:
space:
mode:
Diffstat (limited to 'digital/io-hub/src/apbirthday/rgb.stm32.cc')
-rw-r--r--digital/io-hub/src/apbirthday/rgb.stm32.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/digital/io-hub/src/apbirthday/rgb.stm32.cc b/digital/io-hub/src/apbirthday/rgb.stm32.cc
index 50655745..3000c6d3 100644
--- a/digital/io-hub/src/apbirthday/rgb.stm32.cc
+++ b/digital/io-hub/src/apbirthday/rgb.stm32.cc
@@ -125,7 +125,7 @@ Rgb::calibrate_cannon_sensor ()
{
// Do a measure to get current light situation
do_measure (CANNON, false);
- cannon_offset_ = BASIC_GREY - color_value_[BLUE];
+ cannon_ref_grey_ = color_value_[BLUE];
}
void
@@ -244,25 +244,26 @@ Rgb::ic_isr ()
if (router_)
{
- uint16_t v = color_value_[BLUE] + cannon_offset_;
- if (v > 120 && v < 165)
+ uint16_t v = (color_value_[BLUE] * 100) / cannon_ref_grey_;
+
+ if (v > 0 && v < 30)
+ {
+ seen_white_ = true;
+ }
+ else if (v > 30 && v < 90)
{
// we don't know if it's blue or red, and we don't care
// It's colored and must be thrown out !
seen_color_ = true;
}
- else if (v > 40 && v < 100)
- {
- seen_white_ = true;
- }
// Check if we are seeing GREY again
- else if (v > 180 && v < 210)
+ else if (v > 90)
{
// If we have seen color
if (seen_color_ && !seen_white_)
{
robot->hardware.cherry_bad_out.set (true);
- router_timer_ = 4;
+ router_timer_ = 18;
}
seen_color_ = seen_white_ = false;
}