Add a macro for the default density and atmospheric pressure

Replace the hardcoded default values with a macro defined in a central
location. This makes it much easier to adjust the values if necessary.
This commit is contained in:
Jef Driesen 2022-07-04 21:09:15 +02:00
parent 7fb943ae7f
commit 18f06ea585
6 changed files with 15 additions and 11 deletions

View File

@ -75,7 +75,7 @@ atomics_cobalt_parser_create (dc_parser_t **out, dc_context_t *context)
} }
// Set the default values. // Set the default values.
parser->hydrostatic = 1025.0 * GRAVITY; parser->hydrostatic = DEF_DENSITY_SALT * GRAVITY;
*out = (dc_parser_t*) parser; *out = (dc_parser_t*) parser;

View File

@ -25,6 +25,10 @@
#include <libdivecomputer/context.h> #include <libdivecomputer/context.h>
#include <libdivecomputer/parser.h> #include <libdivecomputer/parser.h>
#define DEF_DENSITY_FRESH 1000.0
#define DEF_DENSITY_SALT 1025.0
#define DEF_ATMOSPHERIC ATM
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -80,8 +80,8 @@ reefnet_sensus_parser_create (dc_parser_t **out, dc_context_t *context, unsigned
} }
// Set the default values. // Set the default values.
parser->atmospheric = ATM; parser->atmospheric = DEF_ATMOSPHERIC;
parser->hydrostatic = 1025.0 * GRAVITY; parser->hydrostatic = DEF_DENSITY_SALT * GRAVITY;
parser->devtime = devtime; parser->devtime = devtime;
parser->systime = systime; parser->systime = systime;
parser->cached = 0; parser->cached = 0;

View File

@ -79,8 +79,8 @@ reefnet_sensuspro_parser_create (dc_parser_t **out, dc_context_t *context, unsig
} }
// Set the default values. // Set the default values.
parser->atmospheric = ATM; parser->atmospheric = DEF_ATMOSPHERIC;
parser->hydrostatic = 1025.0 * GRAVITY; parser->hydrostatic = DEF_DENSITY_SALT * GRAVITY;
parser->devtime = devtime; parser->devtime = devtime;
parser->systime = systime; parser->systime = systime;
parser->cached = 0; parser->cached = 0;

View File

@ -79,8 +79,8 @@ reefnet_sensusultra_parser_create (dc_parser_t **out, dc_context_t *context, uns
} }
// Set the default values. // Set the default values.
parser->atmospheric = ATM; parser->atmospheric = DEF_ATMOSPHERIC;
parser->hydrostatic = 1025.0 * GRAVITY; parser->hydrostatic = DEF_DENSITY_SALT * GRAVITY;
parser->devtime = devtime; parser->devtime = devtime;
parser->systime = systime; parser->systime = systime;
parser->cached = 0; parser->cached = 0;

View File

@ -245,8 +245,8 @@ shearwater_common_parser_create (dc_parser_t **out, dc_context_t *context, unsig
} }
parser->divemode = M_OC_TEC; parser->divemode = M_OC_TEC;
parser->units = METRIC; parser->units = METRIC;
parser->density = 1025; parser->density = DEF_DENSITY_SALT;
parser->atmospheric = ATM / (BAR / 1000); parser->atmospheric = DEF_ATMOSPHERIC / (BAR / 1000);
*out = (dc_parser_t *) parser; *out = (dc_parser_t *) parser;
@ -307,8 +307,8 @@ shearwater_predator_parser_set_data (dc_parser_t *abstract, const unsigned char
} }
parser->divemode = M_OC_TEC; parser->divemode = M_OC_TEC;
parser->units = METRIC; parser->units = METRIC;
parser->density = 1025; parser->density = DEF_DENSITY_SALT;
parser->atmospheric = ATM / (BAR / 1000); parser->atmospheric = DEF_ATMOSPHERIC / (BAR / 1000);
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
} }