mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add function to calculate gas maximum narcotic depth
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1ba61d7ad5
commit
9fbd11744f
6 changed files with 20 additions and 9 deletions
|
|
@ -3661,7 +3661,7 @@ fraction_t best_He(depth_t depth, struct dive *dive)
|
|||
{
|
||||
fraction_t fhe;
|
||||
int pnarcotic, ambient;
|
||||
pnarcotic = depth_to_mbar(prefs.bestmixend, dive);
|
||||
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 (fhe.permille < 0)
|
||||
|
|
|
|||
11
core/dive.h
11
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
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ struct preferences {
|
|||
int descrate;
|
||||
int bottompo2;
|
||||
int decopo2;
|
||||
int bestmixend;
|
||||
depth_t bestmixend;
|
||||
int proxy_type;
|
||||
char *proxy_host;
|
||||
int proxy_port;
|
||||
|
|
|
|||
|
|
@ -917,7 +917,7 @@ int DivePlannerSettings::decopo2() const
|
|||
|
||||
int DivePlannerSettings::bestmixend() const
|
||||
{
|
||||
return prefs.bestmixend;
|
||||
return prefs.bestmixend.mm;
|
||||
}
|
||||
|
||||
int DivePlannerSettings::reserveGas() const
|
||||
|
|
@ -1099,7 +1099,7 @@ void DivePlannerSettings::setBestmixend(int value)
|
|||
QSettings s;
|
||||
s.beginGroup(group);
|
||||
s.setValue("bestmixend", value);
|
||||
prefs.bestmixend = value;
|
||||
prefs.bestmixend.mm = value;
|
||||
emit bestmixendChanged(value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ struct preferences default_prefs = {
|
|||
.descrate = 18000 / 60,
|
||||
.bottompo2 = 1400,
|
||||
.decopo2 = 1600,
|
||||
.bestmixend = 30000,
|
||||
.bestmixend.mm = 30000,
|
||||
.doo2breaks = false,
|
||||
.drop_stone_mode = false,
|
||||
.switch_at_req_stop = false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue