aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Tim Segers <tsegers@pm.me>2022-10-12 16:04:51 +0200
committerGravatar Tim Segers <tsegers@pm.me>2022-10-12 16:05:56 +0200
commit879de8903e617d9e172a36045dc1b7b7ca4250c1 (patch)
tree82340b12e10ea7abb65d4c1eccf89b259f17a47a /src
parent378ee4dbffb8c99ffe8a74bcce70e96851a3624a (diff)
downloadopendeco-879de8903e617d9e172a36045dc1b7b7ca4250c1.tar.gz
Add option to perform last deco stop at 6m instead of 3m
Diffstat (limited to 'src')
-rw-r--r--src/deco.c9
-rw-r--r--src/deco.h4
-rw-r--r--src/opendeco.c15
3 files changed, 22 insertions, 6 deletions
diff --git a/src/deco.c b/src/deco.c
index a03ed34..204a2a7 100644
--- a/src/deco.c
+++ b/src/deco.c
@@ -15,6 +15,8 @@ double P_WV = P_WV_DEFAULT;
double PO2_MAX = PO2_MAX_DEFAULT;
double END_MAX = END_MAX_DEFAULT;
+int LAST_STOP_AT_SIX = LAST_STOP_AT_SIX_DEFAULT;
+
typedef struct zhl_n2_t {
double t;
double a[3];
@@ -213,7 +215,12 @@ double round_ceiling(const decostate_t *ds, const double c)
{
assert(ds->ceil_multiple != 0);
- return abs_depth(ds->ceil_multiple * ceil(RND(gauge_depth(c) / ds->ceil_multiple)));
+ int numbered_stop = ceil(RND(gauge_depth(c) / ds->ceil_multiple));
+
+ if (numbered_stop == 1 && LAST_STOP_AT_SIX)
+ numbered_stop = 2;
+
+ return abs_depth(ds->ceil_multiple * numbered_stop);
}
double ceiling(const decostate_t *ds, double gf)
diff --git a/src/deco.h b/src/deco.h
index 16072a1..11f6bc9 100644
--- a/src/deco.h
+++ b/src/deco.h
@@ -20,6 +20,8 @@
#define PO2_MAX_DEFAULT 1.6
#define END_MAX_DEFAULT 4.01325
+#define LAST_STOP_AT_SIX_DEFAULT 0
+
#define MOD_AUTO 0
/* types */
@@ -54,6 +56,8 @@ extern double P_WV;
extern double PO2_MAX;
extern double END_MAX;
+extern int LAST_STOP_AT_SIX;
+
/* functions */
double bar_to_msw(const double bar);
double msw_to_bar(const double msw);
diff --git a/src/opendeco.c b/src/opendeco.c
index 9329383..ae95f58 100644
--- a/src/opendeco.c
+++ b/src/opendeco.c
@@ -38,6 +38,7 @@ static struct argp_option options[] = {
{"gfhigh", 'h', "NUMBER", 0, "Set the gradient factor at the surface, defaults to 75", 5},
{"decogasses", 'G', "LIST", 0, "Set the gasses available for deco", 6},
{0, 's', 0, OPTION_ARG_OPTIONAL, "Only switch gas at deco stops", 7},
+ {0, '6', 0, OPTION_ARG_OPTIONAL, "Perform last deco stop at 6m", 8},
{0, 0, 0, 0, "Informational options:", 0},
{0, 0, 0, 0, 0, 0}
};
@@ -51,6 +52,7 @@ struct arguments {
char *decogasses;
double SURFACE_PRESSURE;
int SWITCH_INTERMEDIATE;
+ int LAST_STOP_AT_SIX;
};
static error_t parse_opt(int key, char *arg, struct argp_state *state)
@@ -73,6 +75,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
case 's':
arguments->SWITCH_INTERMEDIATE = 0;
break;
+ case '6':
+ arguments->LAST_STOP_AT_SIX = 1;
+ break;
case 'G':
arguments->decogasses = arg;
break;
@@ -174,17 +179,17 @@ int main(int argc, char *argv[])
.gflow = 30,
.gfhigh = 75,
.decogasses = "",
- .SURFACE_PRESSURE = 0,
- .SWITCH_INTERMEDIATE = 1,
+ .SURFACE_PRESSURE = SURFACE_PRESSURE_DEFAULT,
+ .SWITCH_INTERMEDIATE = SWITCH_INTERMEDIATE_DEFAULT,
+ .LAST_STOP_AT_SIX = LAST_STOP_AT_SIX_DEFAULT,
};
argp_parse(&argp, argc, argv, 0, 0, &arguments);
/* apply global options */
- if (arguments.SURFACE_PRESSURE > 0)
- SURFACE_PRESSURE = arguments.SURFACE_PRESSURE;
-
+ SURFACE_PRESSURE = arguments.SURFACE_PRESSURE;
SWITCH_INTERMEDIATE = arguments.SWITCH_INTERMEDIATE;
+ LAST_STOP_AT_SIX = arguments.LAST_STOP_AT_SIX;
/* setup */
decostate_t ds;