Having the O2 permille defined once is more readable.
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
#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 */
if (cylinder_none(cyl))
continue;
if (!o2)
- o2 = 209;
+ o2 = AIR_PERMILLE;
if (o2 < mino2)
mino2 = o2;
if (he > maxhe)
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;
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;
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);
}
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;
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;