From f806cdbe2eee8abbc0c9de75664ceef0bbb0d93f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 1 Nov 2012 12:05:31 -0700 Subject: [PATCH] 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 --- profile.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/profile.c b/profile.c index d32224190..82b7dd0f1 100644 --- a/profile.c +++ b/profile.c @@ -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;