From 0f83d6ae23ac4c2863cf3d5dce993ea4f9f94406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Spruck?= Date: Fri, 30 Mar 2012 20:31:03 +0200 Subject: [PATCH] Add support for parsing the events. The event bits have been verified for a Mares M1 only. --- src/mares_darwin_parser.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/mares_darwin_parser.c b/src/mares_darwin_parser.c index e36b04a..ea10b69 100644 --- a/src/mares_darwin_parser.c +++ b/src/mares_darwin_parser.c @@ -191,16 +191,48 @@ mares_darwin_parser_samples_foreach (parser_t *abstract, sample_callback_t callb while (offset + parser->samplesize <= abstract->size) { parser_sample_value_t sample = {0}; + unsigned int value = array_uint16_le (abstract->data + offset); + unsigned int depth = value & 0x07FF; + unsigned int ascent = (value & 0xE000) >> 13; + unsigned int violation = (value & 0x1000) >> 12; + unsigned int deco = (value & 0x0800) >> 11; + // Surface Time (seconds). time += 20; sample.time = time; if (callback) callback (SAMPLE_TYPE_TIME, sample, userdata); // Depth (1/10 m). - unsigned int depth = array_uint16_le (abstract->data + offset) & 0x07FF; sample.depth = depth / 10.0; if (callback) callback (SAMPLE_TYPE_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 (SAMPLE_TYPE_EVENT, sample, userdata); + } + + // Deco violation + if (violation) { + sample.event.type = SAMPLE_EVENT_CEILING; + sample.event.time = 0; + sample.event.flags = 0; + sample.event.value = 0; + if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + } + + // Deco stop + if (deco) { + sample.event.type = SAMPLE_EVENT_DECOSTOP; + sample.event.time = 0; + sample.event.flags = 0; + sample.event.value = 0; + if (callback) callback (SAMPLE_TYPE_EVENT, sample, userdata); + } + if (parser->samplesize == 3) { unsigned int type = (time / 20 + 2) % 3; if (type == 0) {