Add support for gas switches.

This commit is contained in:
Jef Driesen 2014-02-15 09:41:28 +01:00
parent d30b5c65fe
commit ba77b0ed24

View File

@ -185,6 +185,9 @@ cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
else
interval = 30;
unsigned int ngasmixes = cressi_edy_parser_count_gasmixes(data);
unsigned int gasmix = 0xFFFFFFFF;
unsigned int offset = 32;
while (offset + 2 <= size) {
dc_sample_value_t sample = {0};
@ -206,6 +209,21 @@ cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Current gasmix
if (ngasmixes) {
unsigned int idx = (data[offset + 0] & 0x60) >> 5;
if (idx >= ngasmixes)
return DC_STATUS_DATAFORMAT;
if (idx != gasmix) {
sample.event.type = SAMPLE_EVENT_GASCHANGE;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = bcd2dec(data[0x17 - idx]);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
gasmix = idx;
}
}
offset += 2 + extra;
}