summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-12-07 09:42:47 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-07 10:18:48 -0800
commit3a7f3ba880eeacb6e19aeea3ed55073647cffc20 (patch)
treec1d16b1d9edd84db4a51e67ea2d10ccb39a4cec2
parent59fc674e015dd8a333a495b769adc052cf6b865c (diff)
downloadsubsurface-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.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/dive.c b/dive.c
index 5edb6087f..d4e0217d7 100644
--- a/dive.c
+++ b/dive.c
@@ -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);
}