summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2017-11-05 17:32:38 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-11-13 20:50:10 -0800
commita8d4ff308d41987934cff31d400b4a1ebc871629 (patch)
treece2d12d58edcc1de86717b835fb6f80978935305 /core
parentadbc71f9daf6778cf7402a18f9d954226bfceda4 (diff)
downloadsubsurface-a8d4ff308d41987934cff31d400b4a1ebc871629.tar.gz
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>
Diffstat (limited to 'core')
-rw-r--r--core/dive.c16
1 files changed, 16 insertions, 0 deletions
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);