aboutsummaryrefslogtreecommitdiffstats
path: root/statistics.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-06 20:36:37 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-06 20:38:38 -0700
commitb75a89aa868d39be29d2bb220a6e0c50d5a2b0ac (patch)
treed19b9490a152cc83ea7efecd8e4692c597720f9a /statistics.c
parent1a8239a240fe14e983da6d9a6048e2fb154ee053 (diff)
downloadsubsurface-b75a89aa868d39be29d2bb220a6e0c50d5a2b0ac.tar.gz
Start populating the maintab Dive Info widget
Establish some useful helpers and use them when updating the values. One of the helpers (from statistics.c) puzzlingly doesn't link - so that's ifdefed out. Also had to re-arrange the settings reading code (it came too late) and to extract the expanding code of the top dive from the settings reading code (as it had no business being there to begin with). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'statistics.c')
-rw-r--r--statistics.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/statistics.c b/statistics.c
index 7532e346e..bee5837d6 100644
--- a/statistics.c
+++ b/statistics.c
@@ -267,3 +267,18 @@ void get_selected_dives_text(char *buffer, int size)
}
}
+volume_t get_gas_used(struct dive *dive)
+{
+ int idx;
+ volume_t gas_used = { 0 };
+ for (idx = 0; idx < MAX_CYLINDERS; idx++) {
+ cylinder_t *cyl = &dive->cylinder[idx];
+ pressure_t start, end;
+
+ start = cyl->start.mbar ? cyl->start : cyl->sample_start;
+ end = cyl->end.mbar ?cyl->sample_end : cyl->sample_end;
+ if (start.mbar && end.mbar)
+ gas_used.mliter += gas_volume(cyl, start) - gas_volume(cyl, end);
+ }
+ return gas_used;
+}