From eb3e879030b0a29cc3f40d8df3e3eb6f7120c9ea Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 20 Dec 2012 17:42:10 -0800 Subject: [PATCH] Correctly calculate OTUs when pO2 is recorded in the samples This will normally happen for CCR dives with a set pO2. The old calculations was only valid for OC dives. Signed-off-by: Dirk Hohndel --- divelist.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/divelist.c b/divelist.c index 19ee031c6..45091e02b 100644 --- a/divelist.c +++ b/divelist.c @@ -724,10 +724,14 @@ static int calculate_otu(struct dive *dive, struct divecomputer *dc) struct sample *sample = dc->sample + i; struct sample *psample = sample - 1; t = sample->time.seconds - psample->time.seconds; - int o2 = dive->cylinder[sample->cylinderindex].gasmix.o2.permille; - if (!o2) - o2 = AIR_PERMILLE; - po2 = o2 / 1000.0 * depth_to_mbar(sample->depth.mm, dive) / 1000.0; + if (sample->po2) { + po2 = sample->po2; + } else { + int o2 = dive->cylinder[sample->cylinderindex].gasmix.o2.permille; + if (!o2) + o2 = AIR_PERMILLE; + po2 = o2 / 1000.0 * depth_to_mbar(sample->depth.mm, dive) / 1000.0; + } if (po2 >= 0.5) otu += pow(po2 - 0.5, 0.83) * t / 30.0; }