mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
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>
This commit is contained in:
parent
0cf9e0570d
commit
74ecb924f4
1 changed files with 7 additions and 1 deletions
|
@ -199,6 +199,7 @@ void
|
||||||
sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
||||||
{
|
{
|
||||||
unsigned int mm;
|
unsigned int mm;
|
||||||
|
static unsigned int nsensor = 0;
|
||||||
struct divecomputer *dc = userdata;
|
struct divecomputer *dc = userdata;
|
||||||
struct sample *sample;
|
struct sample *sample;
|
||||||
|
|
||||||
|
@ -217,6 +218,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case DC_SAMPLE_TIME:
|
case DC_SAMPLE_TIME:
|
||||||
|
nsensor = 0;
|
||||||
mm = 0;
|
mm = 0;
|
||||||
if (sample) {
|
if (sample) {
|
||||||
sample->in_deco = in_deco;
|
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);
|
sample->setpoint.mbar = po2 = rint(value.setpoint * 1000);
|
||||||
break;
|
break;
|
||||||
case DC_SAMPLE_PPO2:
|
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;
|
break;
|
||||||
case DC_SAMPLE_CNS:
|
case DC_SAMPLE_CNS:
|
||||||
sample->cns = cns = rint(value.cns * 100);
|
sample->cns = cns = rint(value.cns * 100);
|
||||||
|
|
Loading…
Reference in a new issue