summaryrefslogtreecommitdiff
path: root/digital/io-hub/src/apbirthday/robot.cc
diff options
context:
space:
mode:
authorNicolas Schodet2013-03-26 21:00:36 +0100
committerNicolas Schodet2013-03-26 22:22:20 +0100
commit52d4a4917e49e3864cb50cb37cfd86537e42a287 (patch)
tree8bca37e49f76dc18eb546853704e05a969dbf000 /digital/io-hub/src/apbirthday/robot.cc
parentfd2970444d83ac38e0d6af53a6b4dada4226250e (diff)
digital/io-hub/src/apbirthday: add US sensors ADC
Diffstat (limited to 'digital/io-hub/src/apbirthday/robot.cc')
-rw-r--r--digital/io-hub/src/apbirthday/robot.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/digital/io-hub/src/apbirthday/robot.cc b/digital/io-hub/src/apbirthday/robot.cc
index 2dc3de95..d8b47387 100644
--- a/digital/io-hub/src/apbirthday/robot.cc
+++ b/digital/io-hub/src/apbirthday/robot.cc
@@ -41,7 +41,7 @@ Robot::Robot ()
outputs_set_ (outputs_, lengthof (outputs_)),
stats_proto_ (0),
stats_chrono_ (false), stats_chrono_last_s_ (-1),
- stats_inputs_ (0)
+ stats_inputs_ (0), stats_usdist_ (0)
{
robot = this;
unsigned i = 0;
@@ -212,6 +212,12 @@ Robot::proto_handle (ucoo::Proto &proto, char cmd, const uint8_t *args, int size
stats_inputs_cpt_ = stats_inputs_ = args[0];
stats_proto_ = &proto;
break;
+ case c ('U', 1):
+ // US distance sensors stats.
+ // 1B: stat interval.
+ stats_usdist_cpt_ = stats_usdist_ = args[0];
+ stats_proto_ = &proto;
+ break;
default:
proto.send ('?');
return;
@@ -245,5 +251,15 @@ Robot::proto_stats ()
stats_proto_->send ('I', "L", inputs);
stats_inputs_cpt_ = stats_inputs_;
}
+ if (stats_usdist_ && !--stats_usdist_cpt_)
+ {
+ // TODO: this is a hack, only work in simulation.
+ stats_proto_->send ('U', "HHHH",
+ hardware.adc_dist0.read (),
+ hardware.adc_dist1.read (),
+ hardware.adc_dist2.read (),
+ hardware.adc_dist3.read ());
+ stats_usdist_cpt_ = stats_usdist_;
+ }
}