diff options
author | Rick Walsh <rickmwalsh@gmail.com> | 2016-07-06 22:40:31 +1000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-07-09 12:08:06 -0700 |
commit | 9fbd11744f1bfffbc6973e0f9483ae1630dd8722 (patch) | |
tree | 3b4873ba46e85fb5f61cb87ce103aba1285231ae /core/dive.h | |
parent | 1ba61d7ad5025cf3bafc86705cf4c174aef8c264 (diff) | |
download | subsurface-9fbd11744f1bfffbc6973e0f9483ae1630dd8722.tar.gz |
Add function to calculate gas maximum narcotic depth
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/dive.h')
-rw-r--r-- | core/dive.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/dive.h b/core/dive.h index 9c612048d..c968746f8 100644 --- a/core/dive.h +++ b/core/dive.h @@ -481,6 +481,17 @@ static inline depth_t gas_mod(struct gasmix *mix, pressure_t po2_limit, struct d return rounded_depth; } +/* Maximum narcotic depth rounded to multiples of roundto mm */ +static inline depth_t gas_mnd(struct gasmix *mix, depth_t end, struct dive *dive, int roundto) { + depth_t rounded_depth; + pressure_t ppo2n2; + ppo2n2.mbar = depth_to_mbar(end.mm, dive); + + double maxambient = ppo2n2.mbar / (1 - get_he(mix) / 1000.0); + rounded_depth.mm = rint(mbar_to_depth(maxambient, dive) / roundto) * roundto; + return rounded_depth; +} + #define SURFACE_THRESHOLD 750 /* somewhat arbitrary: only below 75cm is it really diving */ /* this is a global spot for a temporary dive structure that we use to |