Compute and display gas density

This appears to be critical for work of breathing so it might be
worthwhile to compute. So far only in infobox.

For background, see

https://www.youtube.com/watch?v=QBajM3xmOtc

Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
Robert C. Helling 2017-05-12 15:36:24 +02:00 committed by Dirk Hohndel
parent e6d884cf26
commit bb6ceba4ac
5 changed files with 17 additions and 2 deletions

View file

@ -1151,6 +1151,7 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p
entry->pressures.n2 / amb_pressure * N2_DENSITY +
entry->pressures.he / amb_pressure * HE_DENSITY) /
(O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 - 10000;
entry->density = gas_density(&dive->cylinder[cylinderindex].gasmix, depth_to_mbar(entry->depth, dive));
if (entry->mod < 0)
entry->mod = 0;
if (entry->ead < 0)
@ -1292,7 +1293,7 @@ static void plot_string(struct plot_info *pi, struct plot_data *entry, struct me
{
int pressurevalue, mod, ead, end, eadd;
const char *depth_unit, *pressure_unit, *temp_unit, *vertical_speed_unit;
double depthvalue, tempvalue, speedvalue, sacvalue;
double depthvalue, tempvalue, speedvalue, sacvalue, density;
int decimals;
const char *unit;
@ -1327,15 +1328,18 @@ static void plot_string(struct plot_info *pi, struct plot_data *entry, struct me
put_format(b, translate("gettextFromC", "MOD: %d%s\n"), mod, depth_unit);
}
eadd = lrint(get_depth_units(lrint(entry->eadd), NULL, &depth_unit));
if (prefs.ead) {
switch (pi->dive_type) {
case NITROX:
ead = lrint(get_depth_units(lrint(entry->ead), NULL, &depth_unit));
put_format(b, translate("gettextFromC", "EAD: %d%s\nEADD: %d%s\n"), ead, depth_unit, eadd, depth_unit);
put_format(b, translate("gettextFromC", "density: %.1fg/l\n"), entry->density);
break;
case TRIMIX:
end = lrint(get_depth_units(lrint(entry->end), NULL, &depth_unit));
put_format(b, translate("gettextFromC", "END: %d%s\nEADD: %d%s\n"), end, depth_unit, eadd, depth_unit);
put_format(b, translate("gettextFromC", "density: %.1fg/l\n"), entry->density);
break;
case AIR:
case FREEDIVING: