diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2015-03-08 21:40:31 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-03-08 12:55:37 -0700 |
commit | a22adb833446f79710ffef016ea67cc90c47957a (patch) | |
tree | 15808adc5b5f28d3d86a60a802b407281813d6ce /liquivision.c | |
parent | 0ebfcfdf681ad0e93a49d64320fe575d24e5b0d6 (diff) | |
download | subsurface-a22adb833446f79710ffef016ea67cc90c47957a.tar.gz |
Ignore buddy pressures in Liquivision import
Since we do not currently handle buddy pressure properly, let's just
ignore that information for now. Unfortunately, this information is lost
in this case, but if we include it, the pressure graph is going to be
bogus.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'liquivision.c')
-rw-r--r-- | liquivision.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/liquivision.c b/liquivision.c index 2f1bb00ad..6eefdc123 100644 --- a/liquivision.c +++ b/liquivision.c @@ -35,6 +35,8 @@ struct lv_event { } pressure; }; +uint16_t primary_sensor; + static int handle_event_ver2(int code, const unsigned char *ps, unsigned int ps_ptr, struct lv_event *event) { // Skip 4 bytes @@ -45,6 +47,7 @@ static int handle_event_ver2(int code, const unsigned char *ps, unsigned int ps_ static int handle_event_ver3(int code, const unsigned char *ps, unsigned int ps_ptr, struct lv_event *event) { int skip = 4; + uint16_t current_sensor; switch (code) { case 0x0002: // Unknown @@ -67,8 +70,23 @@ static int handle_event_ver3(int code, const unsigned char *ps, unsigned int ps_ case 0x000f: // Tank pressure event->time = array_uint32_le(ps + ps_ptr); - event->pressure.sensor = 0; //array_uint16_le(ps + ps_ptr + 4); - event->pressure.mbar = array_uint16_le(ps + ps_ptr + 6) * 10; // cb->mb + + /* As far as I know, Liquivision supports 2 sensors, own and buddie's. This is my + * best guess how it is represented. */ + + current_sensor = array_uint16_le(ps + ps_ptr + 4); + if (primary_sensor == 0) { + primary_sensor = current_sensor; + } + if (current_sensor == primary_sensor) { + event->pressure.sensor = 0; + event->pressure.mbar = array_uint16_le(ps + ps_ptr + 6) * 10; // cb->mb + } else { + /* Ignoring the buddy sensor for no as we cannot draw it on the profile. + event->pressure.sensor = 1; + event->pressure.mbar = array_uint16_le(ps + ps_ptr + 6) * 10; // cb->mb + */ + } // 1 byte PSR // 1 byte ST skip = 10; @@ -97,9 +115,15 @@ static void parse_dives (int log_version, const unsigned char *buf, unsigned int struct sample *sample; while (ptr < buf_size) { + int i; dive = alloc_dive(); + primary_sensor = 0; dc = &dive->dc; + /* Just the main cylinder until we can handle the buddy cylinder porperly */ + for (i = 0; i < 1; i++) + fill_default_cylinder(&dive->cylinder[i]); + // Model 0=Xen, 1,2=Xeo, 4=Lynx, other=Liquivision model = *(buf + ptr); switch (model) { |