From 1872b71dad98523e6e8b705c98f6202cf6752c93 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 12 May 2014 13:15:46 +0200 Subject: [PATCH] Add support for ascent rate warnings. The Cressi Leonardo does store an indicator for the ascent rate (e.g. the number of arrows) in the upper two bits. This results in 4 possible values, ranging from 0 to 3, with the following interpretation: 0.0 - 3.9 m/min No signal 4.0 - 7.9 m/min 1 Arrow 8.0 - 11.9 m/min 2 Arrows 12.0+ m/min 3 Arrows (with STOP icon) Reported-By: Nick Shore --- src/cressi_leonardo_parser.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cressi_leonardo_parser.c b/src/cressi_leonardo_parser.c index 470a4fa..db2d3f0 100644 --- a/src/cressi_leonardo_parser.c +++ b/src/cressi_leonardo_parser.c @@ -163,6 +163,7 @@ cressi_leonardo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac unsigned int value = array_uint16_le (data + offset); unsigned int depth = value & 0x07FF; + unsigned int ascent = (value & 0xC000) >> 14; // Time (seconds). time += interval; @@ -173,6 +174,15 @@ cressi_leonardo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac sample.depth = depth / 10.0; if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); + // Ascent rate + if (ascent) { + sample.event.type = SAMPLE_EVENT_ASCENT; + sample.event.time = 0; + sample.event.flags = 0; + sample.event.value = ascent; + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); + } + offset += 2; }