summaryrefslogtreecommitdiffstats
path: root/planner.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-02 12:29:40 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-02 12:58:27 -0700
commit9cae50acab13c027cd7c80811b0f3a637d54f32f (patch)
tree8b1b85210612f0366d9523dd49cc158b52227d17 /planner.c
parent90885bfb8e9ac9eb21d969dd6de54b2ddb14c4cb (diff)
downloadsubsurface-9cae50acab13c027cd7c80811b0f3a637d54f32f.tar.gz
Planner: warn about high pO2
If the user entered part of the plan exceeds a pO2 of 1.6, include a warning about that in the notes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'planner.c')
-rw-r--r--planner.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/planner.c b/planner.c
index fa636bd5a..dbe59730c 100644
--- a/planner.c
+++ b/planner.c
@@ -632,6 +632,22 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
}
snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "%.0f%s of %s%s\n"), volume, unit, gasname(&cyl->gasmix), warning);
}
+ dp = diveplan->dp;
+ while (dp) {
+ if (dp->time != 0) {
+ int pO2 = depth_to_atm(dp->depth, dive) * dp->gasmix.o2.permille;
+ if (pO2 > 1600) {
+ const char *depth_unit;
+ int decimals;
+ double depth_value = get_depth_units(dp->depth, &decimals, &depth_unit);
+ len = strlen(buffer);
+ snprintf(buffer + len, sizeof(buffer) - len,
+ translate("gettextFromC", "Warning: high pO2 value %.2f at %d:%02u with gas %s at depth %.*f %s"),
+ pO2 / 1000.0, FRACTION(dp->time, 60), gasname(&dp->gasmix), depth_value, decimals, depth_unit);
+ }
+ }
+ dp = dp->next;
+ }
dive->notes = strdup(buffer);
}