diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-12-20 17:42:10 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-20 17:42:10 -0800 |
commit | eb3e879030b0a29cc3f40d8df3e3eb6f7120c9ea (patch) | |
tree | 07d44a3b6fb01cf343a281f20646ec46b1a7412c | |
parent | 75f6159a048443e86b67870c1de246cabb813d29 (diff) | |
download | subsurface-eb3e879030b0a29cc3f40d8df3e3eb6f7120c9ea.tar.gz |
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 <dirk@hohndel.org>
-rw-r--r-- | divelist.c | 12 |
1 files 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; } |