summaryrefslogtreecommitdiff
path: root/digital/io-hub/src/apbirthday/robot.cc
diff options
context:
space:
mode:
authorNicolas Schodet2013-04-01 18:42:23 +0200
committerNicolas Schodet2013-04-01 18:42:23 +0200
commitf5ad780b2d16abcb0d8da15cdbf6075815109023 (patch)
tree32f3718a6a83c8de7f73602029f710d5231861b0 /digital/io-hub/src/apbirthday/robot.cc
parent811a23702fc65ff2be53f7e5fa0ef3e9924a1e19 (diff)
digital/io-hub/src/apbirthday: add cake distance sensors support
Diffstat (limited to 'digital/io-hub/src/apbirthday/robot.cc')
-rw-r--r--digital/io-hub/src/apbirthday/robot.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/digital/io-hub/src/apbirthday/robot.cc b/digital/io-hub/src/apbirthday/robot.cc
index 35dc891a..900a4fda 100644
--- a/digital/io-hub/src/apbirthday/robot.cc
+++ b/digital/io-hub/src/apbirthday/robot.cc
@@ -50,7 +50,7 @@ Robot::Robot ()
outputs_set_ (outputs_, lengthof (outputs_)),
stats_proto_ (0),
stats_asserv_ (0), stats_chrono_ (false), stats_chrono_last_s_ (-1),
- stats_inputs_ (0), stats_usdist_ (0), stats_pressure_ (0)
+ stats_inputs_ (0), stats_usdist_ (0), stats_cake_ (0), stats_pressure_ (0)
{
robot = this;
// Fill I/O arrays.
@@ -257,6 +257,12 @@ Robot::proto_handle (ucoo::Proto &proto, char cmd, const uint8_t *args, int size
stats_usdist_cpt_ = stats_usdist_ = args[0];
stats_proto_ = &proto;
break;
+ case c ('G', 1):
+ // Cake distance sensors stats.
+ // 1B: stat interval.
+ stats_cake_cpt_ = stats_cake_ = args[0];
+ stats_proto_ = &proto;
+ break;
case c ('F', 1):
// Pressure stats.
// 1B: stat interval.
@@ -309,6 +315,12 @@ Robot::proto_stats ()
usdist2_.get (), usdist3_.get ());
stats_usdist_cpt_ = stats_usdist_;
}
+ if (stats_cake_ && !--stats_cake_cpt_)
+ {
+ stats_proto_->send ('G', "HH", hardware.adc_cake_front.read (),
+ hardware.adc_cake_back.read ());
+ stats_cake_cpt_ = stats_cake_;
+ }
if (stats_pressure_ && !--stats_pressure_cpt_)
{
stats_proto_->send ('F', "H", pressure.get ());