aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/opendeco.c
diff options
context:
space:
mode:
authorGravatar Tim Segers <tsegers@pm.me>2023-01-04 12:58:59 +0100
committerGravatar Tim Segers <tsegers@pm.me>2023-01-07 15:24:51 +0100
commit70d7bb650ad46a4237afd27cfd595812eb040701 (patch)
tree88fa2889132c756ced9b86a87b8ea4e5d5204d47 /src/opendeco.c
parent5737a0996df3b9f11d541cc45c7e32ae3b9a7aac (diff)
downloadopendeco-70d7bb650ad46a4237afd27cfd595812eb040701.tar.gz
Add support for imperial units
Implements: https://todo.sr.ht/~tsegers/opendeco/1
Diffstat (limited to 'src/opendeco.c')
-rw-r--r--src/opendeco.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/opendeco.c b/src/opendeco.c
index 029a81f..fe9a1d1 100644
--- a/src/opendeco.c
+++ b/src/opendeco.c
@@ -12,7 +12,7 @@
#include "output.h"
#include "schedule.h"
-#define MOD_OXY (abs_depth(msw_to_bar(6)))
+#define MOD_OXY (abs_depth(xsw_to_bar(msw_or_fsw(6, 20))))
#define RMV_DIVE_DEFAULT 20
#define RMV_DECO_DEFAULT 15
@@ -154,6 +154,7 @@ int main(int argc, char *argv[])
.RMV_DIVE = RMV_DIVE_DEFAULT,
.RMV_DECO = RMV_DECO_DEFAULT,
.SHOW_TRAVEL = SHOW_TRAVEL_DEFAULT,
+ .UNITS = UNITS_DEFAULT,
};
opendeco_conf_parse("opendeco.toml", &arguments);
@@ -166,11 +167,12 @@ int main(int argc, char *argv[])
RMV_DIVE = arguments.RMV_DIVE;
RMV_DECO = arguments.RMV_DECO;
SHOW_TRAVEL = arguments.SHOW_TRAVEL;
+ UNITS = arguments.UNITS;
/* setup */
decostate_t ds;
- init_decostate(&ds, arguments.gflow, arguments.gfhigh, msw_to_bar(3));
- double dec_per_min = msw_to_bar(9);
+ init_decostate(&ds, arguments.gflow, arguments.gfhigh, xsw_to_bar(msw_or_fsw(3, 10)));
+ double dec_per_min = xsw_to_bar(msw_or_fsw(9, 30));
gas_t bottom_gas;
scan_gas(&bottom_gas, arguments.gas);
@@ -184,12 +186,12 @@ int main(int argc, char *argv[])
deco_gasses[i].mod = MOD_OXY;
/* simulate dive */
- double descent_time = msw_to_bar(arguments.depth) / dec_per_min;
+ double descent_time = xsw_to_bar(arguments.depth) / dec_per_min;
double bottom_time = max(1, arguments.time - descent_time);
waypoint_t waypoints[] = {
- {.depth = abs_depth(msw_to_bar(arguments.depth)), .time = descent_time, &bottom_gas},
- {.depth = abs_depth(msw_to_bar(arguments.depth)), .time = bottom_time, &bottom_gas},
+ {.depth = abs_depth(xsw_to_bar(arguments.depth)), .time = descent_time, &bottom_gas},
+ {.depth = abs_depth(xsw_to_bar(arguments.depth)), .time = bottom_time, &bottom_gas},
};
waypoint_callback_t print_segment_callback = {