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>
This commit is contained in:
Robert C. Helling 2019-10-29 17:57:34 +01:00 committed by Dirk Hohndel
parent 43b16f0810
commit 9c8fbe494d
12 changed files with 121 additions and 86 deletions

View file

@ -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;