From ecb17c6fb6fff892d851a930324ad5ab988180e6 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 13 Nov 2012 11:25:18 -0800 Subject: [PATCH] Correct the OSTC depth calculation This now uses the same formula as the OSTC uses internally which will get the values reported by libdivecomputer to be consistent with what is displayed on the OSTC. Signed-off-by: Dirk Hohndel --- src/hw_ostc_parser.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index e0801f2..f86fed3 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -22,6 +22,7 @@ #include #include +#include "libdivecomputer/units.h" #include "context-private.h" #include "parser-private.h" @@ -307,7 +308,7 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call // Depth (mbar). unsigned int depth = array_uint16_le (data + offset); - sample.depth = depth / 100.0; + sample.depth = (depth * BAR / 1000.0) / (GRAVITY * data[43] * 10.0); if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); offset += 2;