From a8d4ff308d41987934cff31d400b4a1ebc871629 Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Sun, 5 Nov 2017 17:32:38 +0100 Subject: 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 --- core/dive.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'core') diff --git a/core/dive.c b/core/dive.c index 7cad36154..5391f3df9 100644 --- a/core/dive.c +++ b/core/dive.c @@ -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); -- cgit v1.2.3-70-g09d2