[PATCH] Show MOD, EAD, END and EADD

Dirk Hohndel dirk at hohndel.org
Sun Jan 13 13:08:42 PST 2013


Jan Schubert <Jan.Schubert at GMX.li> writes:
> diff --git a/profile.c b/profile.c
> index ccca599..28fe22a 100644
> --- a/profile.c
> +++ b/profile.c
> @@ -1840,11 +1842,31 @@ static void calculate_deco_information(struct
> dive *dive, struct divecomputer *d
>                         entry->phe = (amb_pressure - po2) * ratio;
>                         entry->pn2 = amb_pressure - po2 - entry->phe;
>                         entry->po2 = po2;
> +
> +                        entry->ead  = (entry->depth/1000 + 10) *
> (entry->po2+(amb_pressure-entry->po2)*(1-ratio))/amb_pressure - 10; //
> no rounding! (equla to -9.5)
> +                        entry->end  = (entry->depth/1000 + 10) *
> (amb_pressure-entry->po2)*(1-ratio)/amb_pressure/N2_IN_AIR - 10;
> +                        entry->eadd = (entry->depth/1000 + 10) *
> (entry->po2/amb_pressure * O2_DENSITY + entry->pn2/amb_pressure *
> N2_DENSITY + entry->phe/amb_pressure * HE_DENSITY) / (O2_IN_AIR *
> O2_DENSITY + N2_IN_AIR * N2_DENSITY) -10;


It looks like your patch got word-wrapped... :-(

>                 } else {
>                         entry->po2 = fo2 / 1000.0 * amb_pressure;
>                         entry->phe = fhe / 1000.0 * amb_pressure;
>                         entry->pn2 = (1000 - fo2 - fhe) / 1000.0 *
> amb_pressure;
> +
> +                        entry->ead = (entry->depth/1000 + 10) * (1000 -
> fhe) / 1000.0 - 10;
> +                        entry->end = (entry->depth/1000 + 10) * (1000 -
> fo2 - fhe) / 1000.0 / N2_IN_AIR - 10;
> +                        entry->eadd = (entry->depth/1000 + 10) * (fo2 *
> O2_DENSITY + (1-fo2-fhe) * N2_DENSITY + fhe * HE_DENSITY) / (O2_IN_AIR *
> O2_DENSITY + N2_IN_AIR * N2_DENSITY) -10;
>                 }
> +               entry->mod = (prefs.mod_ppO2/fo2*1000 -1) *
> (strcmp(depth_unit, "m") ? 33 : 10);
> +
> +               // Convert to Feet if necessary
> +               get_depth_units(entry->depth, NULL, &depth_unit);
> +               if(strcmp(depth_unit, "m"))
> +               {
> +                 entry->ead = mm_to_feet(entry->ead*1000);
> +                 entry->end = mm_to_feet(entry->end*1000);
> +                 entry->eadd = mm_to_feet(entry->eadd*1000);
> +                 entry->mod = mm_to_feet(entry->mod*1000);
> +               }
> +

Look how get_depth_units is used elsewhere:

It actually gives you the correct conversion and unit for display. You
just use it once to get the correct unit and then manually
convert... look at this for example:

   depthvalue = get_depth_units(entry->ceiling, NULL, &depth_unit);
   snprintf(buf, bufsize, "%s\nCalculated ceiling %.0f %s", buf2, depthvalue, depth_unit);

/D


More information about the subsurface mailing list