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>
This commit is contained in:
Linus Torvalds 2014-10-20 17:18:40 -07:00 committed by Dirk Hohndel
parent 540dbe927e
commit 46809bac4f

View file

@ -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: