summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2014-12-12 14:30:13 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-12-17 08:05:02 -0800
commitd67cce2af849209bd3222f7ee030b30c4686d666 (patch)
treedd4f51257262203137c6f8b7d915ca12ccdeeca5 /profile.c
parent8400776595f6865d6c84142fba5bf95f39fc0b7e (diff)
downloadsubsurface-d67cce2af849209bd3222f7ee030b30c4686d666.tar.gz
Recording average depth data
This is the calculation that is needed to display a running average in the profile. It adds a new member plot_data.running_sum which can be turned into the running average by dividing by plot_data.time. Right now this isn't used by the UI. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/profile.c b/profile.c
index 6efd05eb7..521e6f68f 100644
--- a/profile.c
+++ b/profile.c
@@ -597,6 +597,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->stopdepth = sample->stopdepth.mm;
entry->stoptime = sample->stoptime.seconds;
entry->ndl = sample->ndl.seconds;