From f5ad780b2d16abcb0d8da15cdbf6075815109023 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 1 Apr 2013 18:42:23 +0200 Subject: digital/io-hub/src/apbirthday: add cake distance sensors support --- digital/io-hub/src/apbirthday/robot.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'digital/io-hub/src/apbirthday/robot.cc') 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 ()); -- cgit v1.2.3