From 62c57be1da37ca9a95e424896025b875e30e4697 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Tue, 30 Oct 2018 12:19:00 +0100 Subject: [PATCH] Fix gasmix for OTU calculation With the fixed sematics of get_gasmix to return the new gasmix for the time of a gas switch (added comments to make this clear), in the OTU calculation we need the previous gasmix for the interval up to the current time. Signed-off-by: Robert C. Helling --- core/dive.c | 2 ++ core/divelist.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/dive.c b/core/dive.c index 255f113fe..d6fba1714 100644 --- a/core/dive.c +++ b/core/dive.c @@ -4433,6 +4433,7 @@ int dive_has_gps_location(const struct dive *dive) return dive_site_has_gps_location(dive->dive_site); } +/* When evaluated at the time of a gasswitch, this returns the new gas */ struct gasmix get_gasmix(const struct dive *dive, const struct divecomputer *dc, int time, const struct event **evp, struct gasmix gasmix) { const struct event *ev = *evp; @@ -4456,6 +4457,7 @@ struct gasmix get_gasmix(const struct dive *dive, const struct divecomputer *dc, } /* get the gas at a certain time during the dive */ +/* If there is a gasswitch at that time, it returns the new gasmix */ struct gasmix get_gasmix_at_time(const struct dive *d, const struct divecomputer *dc, duration_t time) { const struct event *ev = NULL; diff --git a/core/divelist.c b/core/divelist.c index 6197f23b9..1054ccc94 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -173,7 +173,7 @@ static int calculate_otu(const struct dive *dive) if (sample->setpoint.mbar) { po2 = sample->setpoint.mbar; } else { - int o2 = active_o2(dive, dc, sample->time); + int o2 = active_o2(dive, dc, psample->time); po2 = lrint(o2 * depth_to_atm(sample->depth.mm, dive)); } if (po2 >= 500)