diff --git a/dive.h b/dive.h index f06791cc5..de0d826e3 100644 --- a/dive.h +++ b/dive.h @@ -63,6 +63,7 @@ typedef struct depth_t depth; bool manually_added; volume_t gas_used; + volume_t deco_gas_used; } cylinder_t; typedef struct diff --git a/equipment.c b/equipment.c index 51020e5a3..0cc7ea918 100644 --- a/equipment.c +++ b/equipment.c @@ -57,7 +57,8 @@ bool cylinder_nodata(cylinder_t *cyl) !cyl->gasmix.he.permille && !cyl->start.mbar && !cyl->end.mbar && - !cyl->gas_used.mliter; + !cyl->gas_used.mliter && + !cyl->deco_gas_used.mliter; } static bool cylinder_nosamples(cylinder_t *cyl) diff --git a/planner.c b/planner.c index fcdfe01dc..2f3f3def5 100644 --- a/planner.c +++ b/planner.c @@ -217,7 +217,7 @@ static int verify_gas_exists(struct dive *dive, struct gasmix mix_in) /* calculate the new end pressure of the cylinder, based on its current end pressure and the * latest segment. */ -static void update_cylinder_pressure(struct dive *d, int old_depth, int new_depth, int duration, int sac, cylinder_t *cyl) +static void update_cylinder_pressure(struct dive *d, int old_depth, int new_depth, int duration, int sac, cylinder_t *cyl, bool in_deco) { volume_t gas_used; pressure_t delta_p; @@ -228,6 +228,8 @@ static void update_cylinder_pressure(struct dive *d, int old_depth, int new_dept mean_depth.mm = (old_depth + new_depth) / 2; gas_used.mliter = depth_to_atm(mean_depth.mm, d) * sac / 60 * duration; cyl->gas_used.mliter += gas_used.mliter; + if (in_deco) + cyl->deco_gas_used.mliter += gas_used.mliter; if (cyl->type.size.mliter) { delta_p.mbar = gas_used.mliter * 1000.0 / cyl->type.size.mliter; cyl->end.mbar -= delta_p.mbar; @@ -320,7 +322,7 @@ static struct dive *create_dive_from_plan(struct diveplan *diveplan, struct dive sample->time.seconds = lasttime = time; sample->depth.mm = lastdepth = depth; update_cylinder_pressure(dive, sample[-1].depth.mm, depth, time - sample[-1].time.seconds, - dp->entered ? diveplan->bottomsac : diveplan->decosac, cyl); + dp->entered ? diveplan->bottomsac : diveplan->decosac, cyl, !dp->entered); sample->cylinderpressure.mbar = cyl->end.mbar; finish_sample(dc); dp = dp->next; @@ -637,15 +639,17 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool snprintf(temp, sizeof(temp), "%s", translate("gettextFromC", "Gas consumption:")); len += snprintf(buffer + len, sizeof(buffer) - len, "