summaryrefslogtreecommitdiffstats
path: root/libdivecomputer.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2014-10-20 17:18:40 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-10-20 18:10:23 -0700
commit46809bac4f7bec97ce8e06e522a7b0596570b638 (patch)
tree8fba89a3ffc4d28b25237de3aae8a84632cb79b5 /libdivecomputer.c
parent540dbe927e6c784fd53752f89d0a83917ec28ce8 (diff)
downloadsubsurface-46809bac4f7bec97ce8e06e522a7b0596570b638.tar.gz
Make it possible to have samples without depth from libdivecomputer
Normally, all samples have depths associated with them, and most dive computers likely don't even have the concept of a sample without a depth. However, the new Suunto EON Steel definitely has samples with just time updates (and perhaps other data, like events) and no depth at all. We get unhappy about that, and interpret it as having a zero depth. Which doesn't look very nice. This just makes all samples default to the same depth as the previous sample. For normal samples with a depth value, that will just override that default. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r--libdivecomputer.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c
index 22c758ffb..ff8d0eb93 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -185,6 +185,7 @@ void
sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
{
int i;
+ unsigned int mm;
struct divecomputer *dc = userdata;
struct sample *sample;
@@ -203,6 +204,7 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
switch (type) {
case DC_SAMPLE_TIME:
+ mm = 0;
if (sample) {
sample->in_deco = in_deco;
sample->ndl.seconds = ndl;
@@ -210,9 +212,11 @@ sample_cb(dc_sample_type_t type, dc_sample_value_t value, void *userdata)
sample->stopdepth.mm = stopdepth;
sample->setpoint.mbar = po2;
sample->cns = cns;
+ mm = sample->depth.mm;
}
sample = prepare_sample(dc);
sample->time.seconds = value.time;
+ sample->depth.mm = mm;
finish_sample(dc);
break;
case DC_SAMPLE_DEPTH: