From f4841872a41ba9211f6f7aa632c32c1f4156dd4b Mon Sep 17 00:00:00 2001
From: Rick Walsh <[email protected]>
Date: Sun, 5 Jul 2015 09:34:57 +1000
Subject: [PATCH 16/16] MOD of oxygen at pO2 of 1.6 is 20ft

We generally calculate the MOD of a gas as (pO2_limit / fO2 - 1) * 10 metres.  This is good, but with pO2_limit of 1.6 bar (the default), the calculated MOD of oxygen is 19.8ft, which gets rounded down to 10ft.  We want the MOD to be 20ft.

Signed-off-by: Rick Walsh <[email protected]>
---
 dive.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/dive.h b/dive.h
index 042878c..b374c1c 100644
--- a/dive.h
+++ b/dive.h
@@ -170,7 +170,12 @@ static inline int interpolate(int a, int b, int part, int whole)
 /* MOD rounded to multiples of roundto mm */
 static inline depth_t gas_mod(struct gasmix *mix, pressure_t po2_limit, int roundto) {
 	depth_t depth;
-	depth.mm = ((po2_limit.mbar * 1000 / get_o2(mix) * 10 - 10000) / roundto) * roundto;
+	if (roundto == feet_to_mm(10) && get_o2(mix) == 1000 && po2_limit.mbar == 1600) {
+		// MOD of oxygen at pO2 = 1.6 is 20ft
+		depth.mm = feet_to_mm(20);
+	} else {
+		depth.mm = ((po2_limit.mbar * 1000 / get_o2(mix) * 10 - 10000) / roundto) * roundto;
+	}
 	return depth;
 }
 
-- 
2.4.3

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to