From defa71256fe16de32f69e78657c807828b7488bd Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 28 Jul 2017 10:35:25 -0700 Subject: Use the right gasmix for deco calculations In commit e1b880f4 "Profile support for multiple concurrent pressure sensors" I had mindlessly hacked away at some of the sensor lookups from the plot entries to make it all build, and forgotten about my butchery. Thankfully Jan and Davide noticed in their multi-cylinder deco dives that the deco calculations were no longer correct. This uses the newly introduced "get_gasmix()" helper to look up the currently breathing gasmix, and fixes the deco calculations. Reported-and-tested-by: Jan Mulder Reported-by: Davide DB Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- core/divelist.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'core/divelist.c') diff --git a/core/divelist.c b/core/divelist.c index d51aedf78..60b398539 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -316,10 +316,13 @@ static int calculate_sac(struct dive *dive) static void add_dive_to_deco(struct dive *dive) { struct divecomputer *dc = &dive->dc; + struct gasmix *gasmix = NULL; + struct event *ev = NULL; int i; if (!dc) return; + for (i = 1; i < dc->samples; i++) { struct sample *psample = dc->sample + i - 1; struct sample *sample = dc->sample + i; @@ -329,8 +332,8 @@ static void add_dive_to_deco(struct dive *dive) for (j = t0; j < t1; j++) { int depth = interpolate(psample->depth.mm, sample->depth.mm, j - t0, t1 - t0); - add_segment(depth_to_bar(depth, dive), - &dive->cylinder[sample->sensor[0]].gasmix, 1, sample->setpoint.mbar, dive, dive->sac); + gasmix = get_gasmix(dive, dc, j, &ev, gasmix); + add_segment(depth_to_bar(depth, dive), gasmix, 1, sample->setpoint.mbar, dive, dive->sac); } } } -- cgit v1.2.3-70-g09d2