diff options
author | Andrew Tridgell <tridge@samba.org> | 2013-09-09 16:35:20 +1000 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-09-10 11:56:46 +0200 |
commit | 5ee40da720207acde6976d33e721e6bb109617ee (patch) | |
tree | dd486a36b40437a9b13172f456d6618ee7d9a9f9 /src/drivers/ets_airspeed/ets_airspeed.cpp | |
parent | 4650c21141433b5c0f679265314f95ce69d0f2b6 (diff) | |
download | px4-firmware-5ee40da720207acde6976d33e721e6bb109617ee.tar.gz px4-firmware-5ee40da720207acde6976d33e721e6bb109617ee.tar.bz2 px4-firmware-5ee40da720207acde6976d33e721e6bb109617ee.zip |
airspeed: convert to using RingBuffer class
Diffstat (limited to 'src/drivers/ets_airspeed/ets_airspeed.cpp')
-rw-r--r-- | src/drivers/ets_airspeed/ets_airspeed.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/drivers/ets_airspeed/ets_airspeed.cpp b/src/drivers/ets_airspeed/ets_airspeed.cpp index 257b41935..dd8436b10 100644 --- a/src/drivers/ets_airspeed/ets_airspeed.cpp +++ b/src/drivers/ets_airspeed/ets_airspeed.cpp @@ -68,6 +68,7 @@ #include <drivers/drv_airspeed.h> #include <drivers/drv_hrt.h> +#include <drivers/device/ringbuffer.h> #include <uORB/uORB.h> #include <uORB/topics/differential_pressure.h> @@ -173,27 +174,22 @@ ETSAirspeed::collect() diff_pres_pa -= _diff_pres_offset; } - // XXX we may want to smooth out the readings to remove noise. - - _reports[_next_report].timestamp = hrt_absolute_time(); - _reports[_next_report].differential_pressure_pa = diff_pres_pa; - // Track maximum differential pressure measured (so we can work out top speed). - if (diff_pres_pa > _reports[_next_report].max_differential_pressure_pa) { - _reports[_next_report].max_differential_pressure_pa = diff_pres_pa; + if (diff_pres_pa > _max_differential_pressure_pa) { + _max_differential_pressure_pa = diff_pres_pa; } - /* announce the airspeed if needed, just publish else */ - orb_publish(ORB_ID(differential_pressure), _airspeed_pub, &_reports[_next_report]); + // XXX we may want to smooth out the readings to remove noise. + differential_pressure_s report; + report.timestamp = hrt_absolute_time(); + report.differential_pressure_pa = diff_pres_pa; + report.voltage = 0; + report.max_differential_pressure_pa = _max_differential_pressure_pa; - /* post a report to the ring - note, not locked */ - INCREMENT(_next_report, _num_reports); + /* announce the airspeed if needed, just publish else */ + orb_publish(ORB_ID(differential_pressure), _airspeed_pub, &report); - /* if we are running up against the oldest report, toss it */ - if (_next_report == _oldest_report) { - perf_count(_buffer_overflows); - INCREMENT(_oldest_report, _num_reports); - } + new_report(report); /* notify anyone waiting for data */ poll_notify(POLLIN); |