From ff966f2c1ab7a28bec2aa9f5ca8cca94bb7654e2 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Sun, 25 May 2014 12:30:51 +0200 Subject: Move mod calculations to a separate helper We use mod calculations on multiple places, so make a separate helper from it with proper types. The "clumsiness" of defining a local variable to pass into the function and out from it comes from the discrepancies in how c and c++ handles initializations of variables in a struct. Thanks goes to Tiago and Linus for pointing me in the right direction. Signed-off-by: Anton Lundin Signed-off-by: Dirk Hohndel --- qt-ui/diveplanner.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp index aaf530ca7..3ffacdd2b 100644 --- a/qt-ui/diveplanner.cpp +++ b/qt-ui/diveplanner.cpp @@ -499,10 +499,9 @@ bool DivePlannerPointsModel::addGas(int o2, int he) cyl->gasmix.he.permille = he; /* The depth to change to that gas is given by the depth where its pO2 is 1.6 bar. * The user should be able to change this depth manually. */ - if (!o2) - cyl->depth.mm = 1600 * 1000 / O2_IN_AIR * 10 - 10000; - else - cyl->depth.mm = 1600 * 1000 / o2 * 10 - 10000; + pressure_t modppO2; + modppO2.mbar = 1600; + cyl->depth = gas_mod(&cyl->gasmix, modppO2); CylindersModel::instance()->setDive(stagingDive); return true; } -- cgit v1.2.3-70-g09d2