summaryrefslogtreecommitdiffstats
path: root/dive.h
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-12 21:17:52 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-12 21:17:52 +0100
commit05b55542c82fc6842afd68c972b18e86a6c1d004 (patch)
treee2191043e663de9d9817fcb0e52d1b4ff4318a07 /dive.h
parent56f62cc4ab46f811b4340aa36ad1df42bb08832c (diff)
downloadsubsurface-05b55542c82fc6842afd68c972b18e86a6c1d004.tar.gz
Extract salinity for Uemis SDA and improve depth calculation
THe Uemis SDA allows the user to set it up for salt water and fresh water use. We should take this into consideration for the water pressure to depth conversion. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.h')
-rw-r--r--dive.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/dive.h b/dive.h
index d4da7af07..7131b3eaf 100644
--- a/dive.h
+++ b/dive.h
@@ -298,6 +298,21 @@ static inline int depth_to_mbar(int depth, struct dive *dive)
return depth / 10.0 * specific_weight + surface_pressure + 0.5;
}
+/* for the inverse calculation we use just the relative pressure
+ * (that's the one that some dive computers like the Uemis Zurich
+ * provide - for the other models that do this libdivecomputer has to
+ * take care of this, but the Uemis we support natively */
+static inline int rel_mbar_to_depth(int mbar, struct dive *dive)
+{
+ int cm;
+ double specific_weight = 1.03 * 0.981;
+ if (dive->salinity)
+ specific_weight = dive->salinity / 10000.0 * 0.981;
+ /* whole mbar gives us cm precision */
+ cm = mbar / specific_weight + 0.5;
+ return cm * 10;
+}
+
#define SURFACE_THRESHOLD 750 /* somewhat arbitrary: only below 75cm is it really diving */
/* this is a global spot for a temporary dive structure that we use to