summaryrefslogtreecommitdiffstats
path: root/statistics.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2014-04-26 10:55:17 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-04-26 17:24:12 -0700
commit0c5ec1d6dbf386e063a11717c7bfdbec5c57fcf0 (patch)
tree48952fba2899178633cb15ae3fa92f7b8ea1f73d /statistics.c
parentcd98e4f6dbe0a9d8731bfd5c7bf506ae73f07877 (diff)
downloadsubsurface-0c5ec1d6dbf386e063a11717c7bfdbec5c57fcf0.tar.gz
Don't calculate SAC-rates for negative pressure changes
They happen - maybe the cylinder actually warmed up, or maybe the user entered just a ending pressure without a starting pressure. Regardless, just ignore cylinder pressure changes that go up. Also ignore cylinders with a zero ending pressure: that's really a *missing* pressure rather than an actual zero pressure. As Dirk says, the scuba regulators don't even work without a healthy positive pressure differential, so even when you breathe down a tank to "empty", it won't be at zero pressure (this is true even with gauge pressure, where zero means "atmospheric pressure"). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'statistics.c')
-rw-r--r--statistics.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/statistics.c b/statistics.c
index 1610a1a8a..ad5a95d06 100644
--- a/statistics.c
+++ b/statistics.c
@@ -329,7 +329,7 @@ void get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS])
start = cyl->start.mbar ? cyl->start : cyl->sample_start;
end = cyl->end.mbar ? cyl->end : cyl->sample_end;
- if (start.mbar && end.mbar)
+ if (end.mbar && start.mbar > end.mbar)
gases[idx].mliter = gas_volume(cyl, start) - gas_volume(cyl, end);
}
}