diff options
author | Robert C. Helling <helling@atdotde.de> | 2019-10-29 17:57:34 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-31 00:30:38 -0700 |
commit | 9c8fbe494db231b59c2e072b54af85bc217c00d8 (patch) | |
tree | 2b387fea841a6a154135c8b268f3e40298ddbea5 /core/dive.c | |
parent | 43b16f0810f7aa8328fd946e0e014d0625e3b53b (diff) | |
download | subsurface-9c8fbe494db231b59c2e072b54af85bc217c00d8.tar.gz |
Planner: Add option to treat O2 as narcotic
When computing the best mix for a target depth, for helium, one
can either require that the partial pressure of N2 is the same
as at the target depth or the partial pressure of N2 plus O2.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/dive.c')
-rw-r--r-- | core/dive.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/core/dive.c b/core/dive.c index d845d8077..9788e64c7 100644 --- a/core/dive.c +++ b/core/dive.c @@ -3761,13 +3761,17 @@ fraction_t best_o2(depth_t depth, const struct dive *dive) } //Calculate He in best mix. O2 is considered narcopic -fraction_t best_he(depth_t depth, const struct dive *dive) +fraction_t best_he(depth_t depth, const struct dive *dive, bool o2narcotic, fraction_t fo2) { fraction_t fhe; int pnarcotic, ambient; pnarcotic = depth_to_mbar(prefs.bestmixend.mm, dive); ambient = depth_to_mbar(depth.mm, dive); - fhe.permille = (100 - 100 * pnarcotic / ambient) * 10; //use integer arithmetic to round up to nearest percent + if (o2narcotic) { + fhe.permille = (100 - 100 * pnarcotic / ambient) * 10; //use integer arithmetic to round up to nearest percent + } else { + fhe.permille = 1000 - fo2.permille - N2_IN_AIR * pnarcotic / ambient; + } if (fhe.permille < 0) fhe.permille = 0; return fhe; |