diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-07 09:42:47 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-07 10:18:48 -0800 |
commit | 3a7f3ba880eeacb6e19aeea3ed55073647cffc20 (patch) | |
tree | c1d16b1d9edd84db4a51e67ea2d10ccb39a4cec2 | |
parent | 59fc674e015dd8a333a495b769adc052cf6b865c (diff) | |
download | subsurface-3a7f3ba880eeacb6e19aeea3ed55073647cffc20.tar.gz |
Tune the dive joining surface event insert code
From 178a3f0d6d5112f76943fec5f8c1c1f3b173a7f4 Mon Sep 17 00:00:00 2001
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Fri, 7 Dec 2012 09:34:18 -0800
Subject: [PATCH 2/2] Tune the dive joining surface event insert code
So this makes us do surface events only if the samples are more than one
minute apart, and are shallow enough (randomly selected at 5m).
We can add more heuristics. Maybe we should compare the 1-minute sample
time limit of the previous sample to the time to the sample before that:
if some computer (or manually entered dive) has a long time between
*all* samples, we'd make the cut-off time longer.
Baby steps.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | dive.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -614,8 +614,15 @@ static void merge_one_sample(struct sample *sample, int time, struct divecompute int last = dc->samples-1; if (last >= 0) { static struct sample surface; - int last_time = dc->sample[last].time.seconds; - if (time > last_time + 60) { + struct sample *prev = dc->sample + last; + int last_time = prev->time.seconds; + int last_depth = prev->depth.mm; + + /* + * Only do surface events if the samples are more than + * a minute apart, and shallower than 5m + */ + if (time > last_time + 60 && last_depth < 5000) { add_sample(&surface, last_time+20, dc); add_sample(&surface, time - 20, dc); } |