diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-28 10:35:25 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-07-28 21:50:20 -0700 |
commit | defa71256fe16de32f69e78657c807828b7488bd (patch) | |
tree | 91c5e784225375bff7256d9ca885f548b1059480 /core/divelist.c | |
parent | 1e337518b81fdcd21b9c2e6efac3cc3ad0667439 (diff) | |
download | subsurface-defa71256fe16de32f69e78657c807828b7488bd.tar.gz |
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 <jlmulder@xs4all.nl>
Reported-by: Davide DB <dbdavide@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/divelist.c')
-rw-r--r-- | core/divelist.c | 7 |
1 files changed, 5 insertions, 2 deletions
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); } } } |