From b4582977251dbf07c13c4d69a4f7be04e75612d6 Mon Sep 17 00:00:00 2001 From: Tim Segers Date: Tue, 8 Aug 2023 20:48:27 +0200 Subject: Split unit conversion functions out from deco.c --- src/deco.c | 54 +----------------------------------------------------- 1 file changed, 1 insertion(+), 53 deletions(-) (limited to 'src/deco.c') diff --git a/src/deco.c b/src/deco.c index 08a3957..f39c61e 100644 --- a/src/deco.c +++ b/src/deco.c @@ -5,12 +5,11 @@ #include #include "deco.h" +#include "units.h" #define RND(x) (round((x) *10000) / 10000) enum ALGO ALGO_VER = ALGO_VER_DEFAULT; -enum UNITS UNITS = UNITS_DEFAULT; -double SURFACE_PRESSURE = SURFACE_PRESSURE_DEFAULT; double P_WV = P_WV_DEFAULT; double END_MAX = END_MAX_DEFAULT; @@ -65,57 +64,6 @@ const zhl_he_t ZHL16He[] = { {.t = 240.03, .a = 0.5119, .b = 0.9267}, }; -double bar_to_msw(double bar) -{ - return bar * 10; -} - -double msw_to_bar(double msw) -{ - return msw / 10; -} - -double bar_to_fsw(double bar) -{ - return (bar / 1.01325) * 33.0; -} - -double fsw_to_bar(double fsw) -{ - return (fsw * 1.01325) / 33.0; -} - -double msw_or_fsw(double msw, double fsw) -{ - assert(UNITS == METRIC || UNITS == IMPERIAL); - - return (UNITS == METRIC) ? msw : fsw; -} - -double xsw_to_bar(double xsw) -{ - assert(UNITS == METRIC || UNITS == IMPERIAL); - - return (UNITS == METRIC) ? msw_to_bar(xsw) : fsw_to_bar(xsw); -} - -double bar_to_xsw(double bar) -{ - assert(UNITS == METRIC || UNITS == IMPERIAL); - - return (UNITS == METRIC) ? bar_to_msw(bar) : bar_to_fsw(bar); -} - -double abs_depth(double gd) -{ - return gd + SURFACE_PRESSURE; -} - -double gauge_depth(double ad) -{ - return ad - SURFACE_PRESSURE; -} - void add_segment_ascdec(decostate_t *ds, double dstart, double dend, double time, const gas_t *gas) { assert(time > 0); -- cgit v1.2.3-70-g09d2