diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-11-11 14:28:49 +0100 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2019-11-12 07:00:37 +0100 |
commit | b850384100ce429d3720ce03fc39e817f123c77d (patch) | |
tree | 77016f0e33e6dc726b118d3020d4e5a847175ae5 /core | |
parent | ebaac21ef54b7f972663cea0022460cf7c281265 (diff) | |
download | subsurface-b850384100ce429d3720ce03fc39e817f123c77d.tar.gz |
Profile: fix pressure scale
The determination of minimum pressure in calculate_max_limits_new()
in profile.c was wrong for a long time. Since the loop went over all
cylinders (even unused ones), the minimum pressure was always zero.
Since we loop only over used cylinders, the minimum pressure was
initialized to the lowest starting pressure of any cylinder.
If there were no events with pressure change, the minimum pressure
stayed unchanged, resulting in a funky scaling.
Instead, let's initialize the minimum pressure to the lowest ending
pressure.
Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r-- | core/profile.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/profile.c b/core/profile.c index bee2b7a4a..ae1bb4259 100644 --- a/core/profile.c +++ b/core/profile.c @@ -414,11 +414,12 @@ static void calculate_max_limits_new(struct dive *dive, struct divecomputer *giv /* Get the per-cylinder maximum pressure if they are manual */ for (cyl = 0; cyl < dive->cylinders.nr; cyl++) { - int mbar = get_cylinder(dive, cyl)->start.mbar; - if (mbar > maxpressure) - maxpressure = mbar; - if (mbar < minpressure) - minpressure = mbar; + int mbar_start = get_cylinder(dive, cyl)->start.mbar; + int mbar_end = get_cylinder(dive, cyl)->end.mbar; + if (mbar_start > maxpressure) + maxpressure = mbar_start; + if (mbar_end < minpressure) + minpressure = mbar_end; } /* Then do all the samples from all the dive computers */ |