summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-08 14:16:13 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-08 21:23:27 -0800
commit02844c3a10f3e7785aa81080e1c91b64c4d5dfd8 (patch)
treeb9f28f6523d70cb57cd88ae575e588d2aa216ae4
parent9bcd21bf679081b64aaf10f0fc5a035c34ac1c7b (diff)
downloadsubsurface-02844c3a10f3e7785aa81080e1c91b64c4d5dfd8.tar.gz
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 <dirk@hohndel.org>
-rw-r--r--profile.c10
1 files changed, 8 insertions, 2 deletions
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;
}