[PATCH] Interpolate running depth when necessary

Miika Turkia miika.turkia at gmail.com
Fri Jan 2 23:36:41 PST 2015


The running depth must be interpolated when sample interval is more than
10 seconds.

Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 profile.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/profile.c b/profile.c
index 33fea50..e2913b3 100644
--- a/profile.c
+++ b/profile.c
@@ -523,6 +523,7 @@ struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer
 	*entry = entry[-1];         \
 	entry->sec = _time;         \
 	entry->depth = _depth;      \
+	entry->running_sum = (entry - 1)->running_sum + (_time - (entry - 1)->sec) * (_depth + (entry - 1)->depth) / 2; \
 	SENSOR_PRESSURE(entry) = 0; \
 	entry++;                    \
 	idx++
@@ -599,7 +600,7 @@ struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer *
 		entry->sec = time;
 		entry->depth = depth;
 
-		entry->running_sum = (entry - 1)->running_sum + (time - lasttime) * (depth + lastdepth) / 2;
+		entry->running_sum = (entry - 1)->running_sum + (time - (entry - 1)->sec) * (depth + (entry - 1)->depth) / 2;
 		entry->stopdepth = sample->stopdepth.mm;
 		entry->stoptime = sample->stoptime.seconds;
 		entry->ndl = sample->ndl.seconds;
-- 
1.9.1



More information about the subsurface mailing list