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>
This commit is contained in:
Dirk Hohndel 2012-12-20 17:42:10 -08:00
parent 75f6159a04
commit eb3e879030

View file

@ -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;
}