summaryrefslogtreecommitdiffstats
path: root/core/gas.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/gas.c')
-rw-r--r--core/gas.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/core/gas.c b/core/gas.c
index 128305e12..d37b614fb 100644
--- a/core/gas.c
+++ b/core/gas.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "gas.h"
#include "pref.h"
+#include "gettext.h"
#include <stdio.h>
#include <string.h>
@@ -139,3 +140,32 @@ void fill_pressures(struct gas_pressures *pressures, const double amb_pressure,
}
}
}
+
+enum gastype gasmix_to_type(struct gasmix mix)
+{
+ if (gasmix_is_air(mix))
+ return GASTYPE_AIR;
+ if (mix.o2.permille >= 980)
+ return GASTYPE_OXYGEN;
+ if (mix.he.permille == 0)
+ return mix.o2.permille >= 230 ? GASTYPE_NITROX : GASTYPE_AIR;
+ if (mix.o2.permille <= 180)
+ return GASTYPE_HYPOXIC_TRIMIX;
+ return mix.o2.permille <= 230 ? GASTYPE_NORMOXIC_TRIMIX : GASTYPE_HYPEROXIC_TRIMIX;
+}
+
+static const char *gastype_names[] = {
+ QT_TRANSLATE_NOOP("gettextFromC", "Air"),
+ QT_TRANSLATE_NOOP("gettextFromC", "Nitrox"),
+ QT_TRANSLATE_NOOP("gettextFromC", "Hypoxic Trimix"),
+ QT_TRANSLATE_NOOP("gettextFromC", "Normoxic Trimix"),
+ QT_TRANSLATE_NOOP("gettextFromC", "Hyperoxic Trimix"),
+ QT_TRANSLATE_NOOP("gettextFromC", "Oxygen")
+};
+
+const char *gastype_name(enum gastype type)
+{
+ if (type < 0 || type >= GASTYPE_COUNT)
+ return "";
+ return translate("gettextFromC", gastype_names[type]);
+}