From 34a42d7f04319973cbecfcc3b21c6bf8b29f2a22 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 30 Mar 2017 11:30:23 +0200 Subject: Shift fake tank pressures up by 30bar This is a rather arbitrary value, intended to create actually valid pressure values for Uwatec Memomouse users - since we treat 0bar as invalid pressure value, this simply creates an arbitrary '30bar + delta' to '30bar' consumption graph (since all the Memomouse devices give us is the pressure delta that was used during the dive). Signed-off-by: Dirk Hohndel --- core/libdivecomputer.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index cac6143b8..28fa90948 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -208,9 +208,16 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t // normally 0 is not a valid pressure, but for some Uwatec dive computers we // don't get the actual start and end pressure, but instead a start pressure // that matches the consumption and an end pressure of always 0 - if (!IS_FP_SAME(tank.beginpressure, 0.0) && (same_string(devdata->vendor, "Uwatec") || !IS_FP_SAME(tank.endpressure, 0.0))) { - dive->cylinder[i].start.mbar = lrint(tank.beginpressure * 1000); - dive->cylinder[i].end.mbar = lrint(tank.endpressure * 1000); + // In order to make this work, we arbitrary shift this up by 30bar so the + // rest of the code treats this as if they were valid values + if (!IS_FP_SAME(tank.beginpressure, 0.0)) { + if (!IS_FP_SAME(tank.endpressure, 0.0)) { + dive->cylinder[i].start.mbar = lrint(tank.beginpressure * 1000); + dive->cylinder[i].end.mbar = lrint(tank.endpressure * 1000); + } else if (same_string(devdata->vendor, "Uwatec")) { + dive->cylinder[i].start.mbar = lrint(tank.beginpressure * 1000 + 30000); + dive->cylinder[i].end.mbar = 30000; + } } } #endif -- cgit v1.2.3-70-g09d2