From cfc9ddc380bdc5616893fc2af4e05204b5500ea2 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 18 Jun 2021 21:54:29 +0200 Subject: [PATCH] Use the correct standard gravity factor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For manual depth calculations by divers, the standard gravity is often approximated as 10.0 (e.g. 1 bar corresponds to 10 meter), but libdivecomputer prefers to use the exact value of 9.80665 m/s². For the McLean Extreme, it has been confirmed that the device also uses the correct standard gravity internally for the conversion of the sample depth. --- src/mclean_extreme_parser.c | 4 ++-- src/uwatec_smart_parser.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mclean_extreme_parser.c b/src/mclean_extreme_parser.c index 585c10c..5fef8aa 100644 --- a/src/mclean_extreme_parser.c +++ b/src/mclean_extreme_parser.c @@ -179,10 +179,10 @@ mclean_extreme_parser_get_field(dc_parser_t *abstract, dc_field_type_t type, uns *((unsigned int *)value) = array_uint32_le(abstract->data + SZ_CFG + 0x000C) - array_uint32_le(abstract->data + SZ_CFG + 0x0000); break; case DC_FIELD_MAXDEPTH: - *((double *)value) = (signed int)(array_uint16_le(abstract->data + SZ_CFG + 0x0016) - atmospheric) * (BAR / 1000.0) / (density * 10.0); + *((double *)value) = (signed int)(array_uint16_le(abstract->data + SZ_CFG + 0x0016) - atmospheric) * (BAR / 1000.0) / (density * GRAVITY); break; case DC_FIELD_AVGDEPTH: - *((double *)value) = (signed int)(array_uint16_le(abstract->data + SZ_CFG + 0x0018) - atmospheric) * (BAR / 1000.0) / (density * 10.0); + *((double *)value) = (signed int)(array_uint16_le(abstract->data + SZ_CFG + 0x0018) - atmospheric) * (BAR / 1000.0) / (density * GRAVITY); break; case DC_FIELD_SALINITY: salinity->density = density; diff --git a/src/uwatec_smart_parser.c b/src/uwatec_smart_parser.c index 3e4ed09..7a12a4e 100644 --- a/src/uwatec_smart_parser.c +++ b/src/uwatec_smart_parser.c @@ -801,7 +801,7 @@ uwatec_smart_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi *((unsigned int *) value) = array_uint16_le (data + table->divetime) * 60; break; case DC_FIELD_MAXDEPTH: - *((double *) value) = array_uint16_le (data + table->maxdepth) * (BAR / 1000.0) / (density * 10.0); + *((double *) value) = array_uint16_le (data + table->maxdepth) * (BAR / 1000.0) / (density * GRAVITY); break; case DC_FIELD_GASMIX_COUNT: *((unsigned int *) value) = parser->ngasmixes; @@ -1233,7 +1233,7 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback } if (have_depth) { - sample.depth = (signed int)(depth - depth_calibration) * (2.0 * BAR / 1000.0) / (density * 10.0); + sample.depth = (signed int)(depth - depth_calibration) * (2.0 * BAR / 1000.0) / (density * GRAVITY); if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); }