From d67cce2af849209bd3222f7ee030b30c4686d666 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Fri, 12 Dec 2014 14:30:13 +0100 Subject: 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 Signed-off-by: Dirk Hohndel --- profile.c | 1 + profile.h | 1 + 2 files changed, 2 insertions(+) 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; diff --git a/profile.h b/profile.h index 5d2009530..5c30ca4de 100644 --- a/profile.h +++ b/profile.h @@ -39,6 +39,7 @@ struct plot_data { int cns; int smoothed; int sac; + int running_sum; struct gas_pressures pressures; pressure_t o2pressure; // for rebreathers, this is consensus measured po2, or setpoint otherwise. 0 for OC. pressure_t o2sensor[3]; //for rebreathers with up to 3 PO2 sensors -- cgit v1.2.3-70-g09d2