From: Henrik Brautaset Aronsen Date: Sat, 31 Dec 2011 16:15:59 +0000 (+0100) Subject: Define O2 permille for air in one spot X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=16b6df559f7b5aabbcbec7d7d08f3687b30384dc;p=ext%2Fsubsurface.git Define O2 permille for air in one spot Having the O2 permille defined once is more readable. Signed-off-by: Henrik Brautaset Aronsen --- diff --git a/dive.h b/dive.h index 0549843..bdf3aa6 100644 --- a/dive.h +++ b/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 */ diff --git a/divelist.c b/divelist.c index 32dc92b..4ab6199 100644 --- a/divelist.c +++ b/divelist.c @@ -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; diff --git a/equipment.c b/equipment.c index 482fb4e..d2c7891 100644 --- a/equipment.c +++ b/equipment.c @@ -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); } diff --git a/libdivecomputer.c b/libdivecomputer.c index 9d4c106..daf7241 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -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; diff --git a/statistics.c b/statistics.c index f8f9d0e..9510030 100644 --- a/statistics.c +++ b/statistics.c @@ -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;