From 02844c3a10f3e7785aa81080e1c91b64c4d5dfd8 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 8 Dec 2012 14:16:13 -0800 Subject: Correctly parse the two different gas change events This now takes the He percentage into account when matching tanks. Given the encoding of fO2 and fHe in the GASCHANGE2 event, we can simply mask and shift as if we have a GASCHANGE2 event and things will automatically work correctly for the regular GASCHANGE event. Signed-off-by: Dirk Hohndel --- profile.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'profile.c') diff --git a/profile.c b/profile.c index 9b0ddd700..e56a1459d 100644 --- a/profile.c +++ b/profile.c @@ -1627,14 +1627,20 @@ static int get_cylinder_index(struct dive *dive, struct event *ev) * * Crazy suunto gas change events. We really should do * this in libdivecomputer or something. + * + * There are two different gas change events that can get + * us here - GASCHANGE2 has the He value in the high 16 + * bits; looking at the possible values we can actually + * handle them with the same code since the high 16 bits + * will be 0 with the GASCHANGE event - and that means no He */ for (i = 0; i < MAX_CYLINDERS; i++) { cylinder_t *cyl = dive->cylinder+i; int o2 = (cyl->gasmix.o2.permille + 5) / 10; - if (o2 == ev->value) + int he = (cyl->gasmix.he.permille + 5) / 10; + if (o2 == (ev->value & 0xFFFF) && he == (ev->value >> 16)) return i; } - return 0; } -- cgit v1.2.3-70-g09d2