summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/profile.c b/profile.c
index 0601f8eaa..9f7d97d44 100644
--- a/profile.c
+++ b/profile.c
@@ -68,6 +68,7 @@ static void dump_pi (struct plot_info *pi)
}
#define ROUND_UP(x,y) ((((x)+(y)-1)/(y))*(y))
+#define DIV_UP(x,y) (((x)+(y)-1)/(y))
/*
* When showing dive profiles, we scale things to the
@@ -989,12 +990,14 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d
fo2 = get_o2(&dive->cylinder[cylinderindex].gasmix);
fhe = get_he(&dive->cylinder[cylinderindex].gasmix);
double ratio = (double)fhe / (1000.0 - fo2);
+ int ccrdive = 0;
if (entry->po2) {
/* we have an O2 partial pressure in the sample - so this
* is likely a CC dive... use that instead of the value
* from the cylinder info */
double po2 = entry->po2 > amb_pressure ? amb_pressure : entry->po2;
+ ccrdive = 1;
entry->po2 = po2;
entry->phe = (amb_pressure - po2) * ratio;
entry->pn2 = amb_pressure - po2 - entry->phe;
@@ -1040,7 +1043,7 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d
for (j = t0+1; j <= t1; j++) {
int depth = interpolate(entry[-1].depth, entry[0].depth, j - t0, t1 - t0);
double min_pressure = add_segment(depth_to_mbar(depth, dive) / 1000.0,
- &dive->cylinder[cylinderindex].gasmix, 1, entry->po2 * 1000, dive);
+ &dive->cylinder[cylinderindex].gasmix, 1, ccrdive ? entry->po2 * 1000 : 0, dive);
tissue_tolerance = min_pressure;
}
if (t0 == t1)
@@ -1165,7 +1168,7 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
if (entry->ndl) {
/* this is a safety stop as we still have ndl */
if (entry->stoptime)
- snprintf(buf, bufsize, _("%s\nSafetystop:%umin @ %.0f %s"), buf2, entry->stoptime / 60,
+ snprintf(buf, bufsize, _("%s\nSafetystop:%umin @ %.0f %s"), buf2, DIV_UP(entry->stoptime, 60),
depthvalue, depth_unit);
else
snprintf(buf, bufsize, _("%s\nSafetystop:unkn time @ %.0f %s"), buf2,
@@ -1173,7 +1176,7 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
} else {
/* actual deco stop */
if (entry->stoptime)
- snprintf(buf, bufsize, _("%s\nDeco:%umin @ %.0f %s"), buf2, entry->stoptime / 60,
+ snprintf(buf, bufsize, _("%s\nDeco:%umin @ %.0f %s"), buf2, DIV_UP(entry->stoptime, 60),
depthvalue, depth_unit);
else
snprintf(buf, bufsize, _("%s\nDeco:unkn time @ %.0f %s"), buf2,
@@ -1185,7 +1188,7 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
snprintf(buf, bufsize, _("%s\nIn deco"), buf2);
} else if (has_ndl) {
memcpy(buf2, buf, bufsize);
- snprintf(buf, bufsize, _("%s\nNDL:%umin"), buf2, entry->ndl / 60);
+ snprintf(buf, bufsize, _("%s\nNDL:%umin"), buf2, DIV_UP(entry->ndl, 60));
}
if (entry->cns) {
memcpy(buf2, buf, bufsize);