From 70d7bb650ad46a4237afd27cfd595812eb040701 Mon Sep 17 00:00:00 2001 From: Tim Segers Date: Wed, 4 Jan 2023 12:58:59 +0100 Subject: Add support for imperial units Implements: https://todo.sr.ht/~tsegers/opendeco/1 --- src/opendeco.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/opendeco.c') 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 = { -- cgit v1.2.3-70-g09d2