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>
This commit is contained in:
Dirk Hohndel 2012-11-12 21:17:52 +01:00
parent 56f62cc4ab
commit 05b55542c8
2 changed files with 22 additions and 21 deletions

15
dive.h
View file

@ -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