aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);
}