diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-03-28 09:56:32 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-03-28 13:47:28 -0700 |
commit | 99070c49e2ed1834c7371ce7500d78895e85e67c (patch) | |
tree | ee2243971ca914a21e97fa0f1eb131d4d0f2c06f /dive.h | |
parent | f2f29665d499b57a9f554f29898a300781670f14 (diff) | |
download | subsurface-99070c49e2ed1834c7371ce7500d78895e85e67c.tar.gz |
Fix get_cylinder_index() gasmix comparisons
get_cylinder_index() looks up which cylinder to use based on the
gaschange event that describes the mix. However, it was both buggy and
not very good.
It was buggy because it didn't understand about our air rules, and it
was not very good because it required an exact match (after rounding our
permille-based numbers to percent).
So fix it to use the right permille values, and look for a closest match
(using the normal sum-of-squares distance function - although I wonder
if we should consider helium percentages to be "more important" and give
them a stronger weight).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.h')
-rw-r--r-- | dive.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -215,6 +215,16 @@ static inline int mbar_to_PSI(int mbar) return to_PSI(p); } +static inline int get_o2(const struct gasmix *mix) +{ + return mix->o2.permille ? : O2_IN_AIR; +} + +static inline int get_he(const struct gasmix *mix) +{ + return mix->he.permille; +} + static inline gboolean is_air(int o2, int he) { return (he == 0) && (o2 == 0 || ((o2 >= O2_IN_AIR - 1) && (o2 <= O2_IN_AIR + 1))); |