summaryrefslogtreecommitdiffhomepage
path: root/digital/io-hub/src/apbirthday/robot.cc
diff options
context:
space:
mode:
authorMaxime Hadjinlian2013-05-09 06:02:43 +0200
committerNicolas Schodet2013-05-09 07:44:40 +0200
commite095c76e453fa3b840424cabc02b5812bd9cb1a9 (patch)
tree2d8d6e99b28e66244aada20e999596a0b9500f10 /digital/io-hub/src/apbirthday/robot.cc
parent4a5c5923e3ab7116f67da11b01ea0ac80ef743d5 (diff)
digital/io-hub/src/apbirthday: add RGB class
Diffstat (limited to 'digital/io-hub/src/apbirthday/robot.cc')
-rw-r--r--digital/io-hub/src/apbirthday/robot.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/digital/io-hub/src/apbirthday/robot.cc b/digital/io-hub/src/apbirthday/robot.cc
index 82a54e27..ad1538ea 100644
--- a/digital/io-hub/src/apbirthday/robot.cc
+++ b/digital/io-hub/src/apbirthday/robot.cc
@@ -66,12 +66,13 @@ Robot::Robot ()
hardware.adc_dist3.get_resolution () * 2040 / 3300),
radar_ (usdist0_, usdist1_, usdist2_, usdist3_),
candles (1),
+ rgb (&hardware.rgb_cannon, &hardware.rgb_candle_far, &hardware.rgb_candle_near),
fsm_debug_state_ (FSM_DEBUG_RUN),
outputs_set_ (outputs_, lengthof (outputs_)),
stats_proto_ (0),
stats_asserv_ (0), stats_beacon_ (0),
stats_chrono_ (false), stats_chrono_last_s_ (-1),
- stats_inputs_ (0), stats_usdist_ (0), stats_cake_ (0), stats_pressure_ (0)
+ stats_inputs_ (0), stats_usdist_ (0), stats_cake_ (0), stats_pressure_ (0), stats_rgb_ (0)
{
robot = this;
// Fill I/O arrays.
@@ -122,6 +123,7 @@ Robot::Robot ()
usdist1_.disable ();
usdist2_.disable ();
usdist3_.disable ();
+ rgb.enable ();
}
void
@@ -197,6 +199,8 @@ Robot::main_loop ()
hardware.zb_handle ();
// Send stats.
proto_stats ();
+ // RGB Update Router
+ rgb.update ();
}
}
@@ -398,6 +402,14 @@ Robot::proto_handle (ucoo::Proto &proto, char cmd, const uint8_t *args, int size
stats_pressure_cpt_ = stats_pressure_ = args[0];
stats_proto_ = &proto;
break;
+ case c ('R', 2):
+ // RGB stats.
+ // 1B: sensor type.
+ // 1B: stat interval.
+ stats_rgb_type_ = args[0];
+ stats_rgb_cpt_ = stats_rgb_ = args[1];
+ stats_proto_ = &proto;
+ break;
case c ('P', 1):
// Plate test
// 1B:
@@ -585,6 +597,13 @@ Robot::proto_stats ()
stats_proto_->send ('F', "H", pressure.get ());
stats_pressure_cpt_ = stats_pressure_;
}
+ if (stats_rgb_ && !--stats_rgb_cpt_)
+ {
+ uint16_t w, r, g, b;
+ rgb.get_colors ((Rgb::rgb_type) stats_rgb_type_, w, r, g, b);
+ stats_proto_->send ('R', "HHHH", w, r, g, b);
+ stats_rgb_cpt_ = stats_rgb_;
+ }
}
void