summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-01 12:05:31 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-01 12:05:31 -0700
commitf806cdbe2eee8abbc0c9de75664ceef0bbb0d93f (patch)
tree4e7a5add41ceed8081c2d895b545ee68698dbed8 /profile.c
parent01fd6a57bce4cd501b23481591462161f2ae34d5 (diff)
downloadsubsurface-f806cdbe2eee8abbc0c9de75664ceef0bbb0d93f.tar.gz
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>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c10
1 files 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;