summaryrefslogtreecommitdiffstats
path: root/uemis.c
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 /uemis.c
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 'uemis.c')
-rw-r--r--uemis.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/uemis.c b/uemis.c
index 72d20e360..646c37d9a 100644
--- a/uemis.c
+++ b/uemis.c
@@ -75,25 +75,6 @@ void decode( uint8_t *inbuf, uint8_t *outbuf, int inbuf_len ) {
/* end code from Bob Trower */
/*
- * pressure_to_depth: In centibar. And when converting to
- * depth, I'm just going to always use saltwater, because I
- * think "true depth" is just stupid. From a diving standpoint,
- * "true depth" is pretty much completely pointless, unless
- * you're doing some kind of underwater surveying work.
- *
- * So I give water depths in "pressure depth", always assuming
- * salt water. So one atmosphere per 10m.
- */
-static int pressure_to_depth(uint16_t value)
-{
- double atm, cm;
-
- atm = bar_to_atm(value / 100.0);
- cm = 100 * atm + 0.5;
- return (cm > 0) ? 10 * (long)cm : 0;
-}
-
-/*
* convert the base64 data blog
*/
int uemis_convert_base64(char *base64, uint8_t **data) {
@@ -212,7 +193,12 @@ void uemis_parse_divelog_binary(char *base64, void *datap) {
datalen = uemis_convert_base64(base64, &data);
dive->airtemp.mkelvin = *(uint16_t *)(data + 45) * 100 + 273150;
- dive->surface_pressure.mbar = *(uint16_t *)(data +43);
+ dive->surface_pressure.mbar = *(uint16_t *)(data + 43);
+ if (*(uint8_t *)(data + 19))
+ dive->salinity = 10300; /* avg grams per 10l sea water */
+ else
+ dive->salinity = 10000; /* grams per 10l fresh water */
+
/* dive template in use:
0 = air
1 = nitrox (B)
@@ -253,7 +239,7 @@ void uemis_parse_divelog_binary(char *base64, void *datap) {
sample = prepare_sample(divep);
dive = *divep; /* prepare_sample might realloc the dive */
sample->time.seconds = u_sample->dive_time;
- sample->depth.mm = pressure_to_depth(u_sample->water_pressure);
+ sample->depth.mm = rel_mbar_to_depth(u_sample->water_pressure, dive);
sample->temperature.mkelvin = (u_sample->dive_temperature * 100) + 273150;
sample->cylinderindex = u_sample->active_tank;
sample->cylinderpressure.mbar =