From 9cae50acab13c027cd7c80811b0f3a637d54f32f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 2 Jun 2014 12:29:40 -0700 Subject: 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 --- planner.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'planner.c') 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); } -- cgit v1.2.3-70-g09d2