diff options
author | Anton Lundin <glance@acc.umu.se> | 2015-08-31 23:23:43 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-08-31 15:13:06 -0700 |
commit | 74ecb924f4831d93d5287db8ea034c5d593c35e9 (patch) | |
tree | fda4dcec4b4fb8eda015fe05e239782097508787 /libdivecomputer.c | |
parent | 0cf9e0570dc08f4d911c5d4b2b57e9b89b077f3b (diff) | |
download | subsurface-74ecb924f4831d93d5287db8ea034c5d593c35e9.tar.gz |
Support multiple o2 sensor values from libdc
libdivecomputer might call us with DC_SAMPLE_PPO2 multiple times, which
means multiple sensors.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r-- | libdivecomputer.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c index e877e5962..3e4cfada7 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -199,6 +199,7 @@ void sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) { unsigned int mm; + static unsigned int nsensor = 0; struct divecomputer *dc = userdata; struct sample *sample; @@ -217,6 +218,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) switch (type) { case DC_SAMPLE_TIME: + nsensor = 0; mm = 0; if (sample) { sample->in_deco = in_deco; @@ -269,7 +271,11 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata) sample->setpoint.mbar = po2 = rint(value.setpoint * 1000); break; case DC_SAMPLE_PPO2: - sample->o2sensor[0].mbar = po2 = rint(value.ppo2 * 1000); + if (nsensor < 3) + sample->o2sensor[nsensor].mbar = po2 = rint(value.ppo2 * 1000); + else + report_error("%d is more o2 sensors than we can handle", nsensor); + nsensor++; break; case DC_SAMPLE_CNS: sample->cns = cns = rint(value.cns * 100); |