mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
Define O2 permille for air in one spot
Having the O2 permille defined once is more readable. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
This commit is contained in:
parent
2175226580
commit
16b6df559f
5 changed files with 8 additions and 6 deletions
2
dive.h
2
dive.h
|
@ -326,4 +326,6 @@ const char *monthname(int mon);
|
|||
#define FIVE_STARS UTF8_BLACKSTAR UTF8_BLACKSTAR UTF8_BLACKSTAR UTF8_BLACKSTAR UTF8_BLACKSTAR
|
||||
extern const char *star_strings[];
|
||||
|
||||
#define AIR_PERMILLE 209
|
||||
|
||||
#endif /* DIVE_H */
|
||||
|
|
|
@ -244,7 +244,7 @@ static void get_dive_gas(struct dive *dive, int *o2, int *he, int *o2low)
|
|||
if (cylinder_none(cyl))
|
||||
continue;
|
||||
if (!o2)
|
||||
o2 = 209;
|
||||
o2 = AIR_PERMILLE;
|
||||
if (o2 < mino2)
|
||||
mino2 = o2;
|
||||
if (he > maxhe)
|
||||
|
@ -258,7 +258,7 @@ newmax:
|
|||
maxo2 = o2;
|
||||
}
|
||||
/* All air? Show/sort as "air"/zero */
|
||||
if (!maxhe && maxo2 == 209 && mino2 == maxo2)
|
||||
if (!maxhe && maxo2 == AIR_PERMILLE && mino2 == maxo2)
|
||||
maxo2 = mino2 = 0;
|
||||
*o2 = maxo2;
|
||||
*he = maxhe;
|
||||
|
@ -394,7 +394,7 @@ static int calculate_otu(struct dive *dive)
|
|||
t = sample->time.seconds - psample->time.seconds;
|
||||
int o2 = dive->cylinder[sample->cylinderindex].gasmix.o2.permille;
|
||||
if (!o2)
|
||||
o2 = 209;
|
||||
o2 = AIR_PERMILLE;
|
||||
po2 = o2 / 1000.0 * (sample->depth.mm + 10000) / 10000.0;
|
||||
if (po2 >= 0.5)
|
||||
otu += pow(po2 - 0.5, 0.83) * t / 30.0;
|
||||
|
|
|
@ -285,7 +285,7 @@ static void show_cylinder(cylinder_t *cyl, struct cylinder_widget *cylinder)
|
|||
o2 = cyl->gasmix.o2.permille / 10.0;
|
||||
he = cyl->gasmix.he.permille / 10.0;
|
||||
if (!o2)
|
||||
o2 = 21.0;
|
||||
o2 = AIR_PERMILLE / 10.0;
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->o2), o2);
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->he), he);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ static int parse_gasmixes(struct dive *dive, parser_t *parser, int ngases)
|
|||
he = gasmix.helium * 1000 + 0.5;
|
||||
|
||||
/* Ignore bogus data - libdivecomputer does some crazy stuff */
|
||||
if (o2 < 210 || o2 >= 1000)
|
||||
if (o2 <= AIR_PERMILLE || o2 >= 1000)
|
||||
o2 = 0;
|
||||
if (he < 0 || he >= 800 || o2+he >= 1000)
|
||||
he = 0;
|
||||
|
|
|
@ -171,7 +171,7 @@ void show_dive_stats(struct dive *dive)
|
|||
end = cyl->end.mbar ? : cyl->sample_end.mbar;
|
||||
if (!cylinder_none(cyl)) {
|
||||
/* 0% O2 strangely means air, so 21% - I don't like that at all */
|
||||
int o2 = cyl->gasmix.o2.permille ? : 209;
|
||||
int o2 = cyl->gasmix.o2.permille ? : AIR_PERMILLE;
|
||||
if (offset > 0) {
|
||||
snprintf(buf+offset, 80-offset, ", ");
|
||||
offset += 2;
|
||||
|
|
Loading…
Add table
Reference in a new issue