Fix the pO2 calculation when diving with air

So few of my dives are on air that at first I didn't notice - but for
those dives we set the o2 permille to 0 - which of course causes incorrect
(and extremely deadly) pO2 of 0...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-11-01 12:05:31 -07:00
parent 01fd6a57bc
commit f806cdbe2e

View file

@ -1298,8 +1298,8 @@ static struct plot_info *create_plot_info(struct dive *dive, int nr_samples, str
lastindex = 0;
lastdepth = -1;
for (i = 0; i < nr_samples; i++) {
int depth;
double fo2, pressure;
int depth, fo2;
double pressure;
int delay = 0;
struct sample *sample = dive_sample+i;
@ -1341,8 +1341,10 @@ static struct plot_info *create_plot_info(struct dive *dive, int nr_samples, str
entry->cylinderindex = sample->cylinderindex;
SENSOR_PRESSURE(entry) = sample->cylinderpressure.mbar;
pressure = (depth + 10000) / 10000.0 * 1.01325;
fo2 = dive->cylinder[sample->cylinderindex].gasmix.o2.permille / 1000.0;
entry->po2 = fo2 * pressure;
fo2 = dive->cylinder[sample->cylinderindex].gasmix.o2.permille;
if (!fo2)
fo2 = AIR_PERMILLE;
entry->po2 = fo2 / 1000.0 * pressure;
entry->temperature = sample->temperature.mkelvin;