New fixup function fixup_dc_ndl

Fixup the NDL value to '-1' at the very beginning of a dive.
Some dive computer report a NDL of 0 at the very beginning of a dive
and then only some 10 seconds later they report the correct value
like 240 min for the first time.
Translate this 0 at the beginning of a dive into our internal '-1'
for no info available.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
Stefan Fuchs 2017-11-05 17:32:38 +01:00 committed by Dirk Hohndel
parent adbc71f9da
commit a8d4ff308d

View file

@ -1423,6 +1423,19 @@ static void fixup_dc_depths(struct dive *dive, struct divecomputer *dc)
dive->maxdepth.mm = maxdepth;
}
static void fixup_dc_ndl(struct dive *dive, struct divecomputer *dc)
{
int i;
for (i = 0; i < dc->samples; i++) {
struct sample *sample = dc->sample + i;
if (sample->ndl.seconds != 0)
break;
if (sample->ndl.seconds == 0)
sample->ndl.seconds = -1;
}
}
static void fixup_dc_temp(struct dive *dive, struct divecomputer *dc)
{
int i;
@ -1640,6 +1653,9 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc)
/* Fix up sample depth data */
fixup_dc_depths(dive, dc);
/* Fix up first sample ndl data */
fixup_dc_ndl(dive, dc);
/* Fix up dive temperatures based on dive computer samples */
fixup_dc_temp(dive, dc);