From 08d8c3e13272bc4c33f62cfdc57a34702cff7191 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Wed, 1 Nov 2023 21:25:18 +0100 Subject: [PATCH] Add support for parsing the compass bearings When no compass bearing is set on the dive computer, the stored value is initialized to zero. Since this can also be a valid value, those zero values are only ignored untill another non-zero value is present. In later firmware versions, the value will get initialized to 0xFFFF instead. --- src/divesystem_idive_parser.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/divesystem_idive_parser.c b/src/divesystem_idive_parser.c index c2c934e..c13a804 100644 --- a/src/divesystem_idive_parser.c +++ b/src/divesystem_idive_parser.c @@ -413,6 +413,7 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba unsigned int algorithm_previous = INVALID; unsigned int gf_low = INVALID; unsigned int gf_high = INVALID; + unsigned int have_bearing = 0; unsigned int firmware = 0; unsigned int apos4 = 0; @@ -618,6 +619,16 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba tank[tank_idx].endpressure = pressure; } } + + // Compass bearing + unsigned int bearing = array_uint16_le (data + offset + 50); + if (bearing != 0) { + have_bearing = 1; // Stop ignoring zero values. + } + if (have_bearing && bearing != 0xFFFF) { + sample.bearing = bearing; + if (callback) callback (DC_SAMPLE_BEARING, &sample, userdata); + } } offset += samplesize;