summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2014-05-25 12:30:51 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-25 06:20:52 -0700
commitff966f2c1ab7a28bec2aa9f5ca8cca94bb7654e2 (patch)
treef28226bdbae1048d55b1555d02de2ea98f028cd5 /dive.h
parenta85023a661928142da2b9d78775099b4a080569d (diff)
downloadsubsurface-ff966f2c1ab7a28bec2aa9f5ca8cca94bb7654e2.tar.gz
Move mod calculations to a separate helper
We use mod calculations on multiple places, so make a separate helper from it with proper types. The "clumsiness" of defining a local variable to pass into the function and out from it comes from the discrepancies in how c and c++ handles initializations of variables in a struct. Thanks goes to Tiago and Linus for pointing me in the right direction. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/dive.h b/dive.h
index 05da2874b..fe2b5c784 100644
--- a/dive.h
+++ b/dive.h
@@ -104,6 +104,12 @@ static inline int interpolate(int a, int b, int part, int whole)
return rint(x / whole);
}
+static inline depth_t gas_mod(struct gasmix *mix, pressure_t po2_limit) {
+ depth_t depth;
+ depth.mm = po2_limit.mbar * 1000 / get_o2(mix) * 10 - 10000;
+ return depth;
+}
+
struct sample {
duration_t time;
depth_t depth;