Use symbolic constants for the dive mode.
This commit is contained in:
parent
651123de53
commit
c95ab19e6a
@ -46,6 +46,11 @@
|
|||||||
#define NEMOAPNEIST 18
|
#define NEMOAPNEIST 18
|
||||||
#define PUCKAIR 19
|
#define PUCKAIR 19
|
||||||
|
|
||||||
|
#define AIR 0
|
||||||
|
#define NITROX 1
|
||||||
|
#define FREEDIVE 2
|
||||||
|
#define GAUGE 3
|
||||||
|
|
||||||
void
|
void
|
||||||
mares_common_device_init (mares_common_device_t *device, dc_context_t *context, const dc_device_vtable_t *vtable)
|
mares_common_device_init (mares_common_device_t *device, dc_context_t *context, const dc_device_vtable_t *vtable)
|
||||||
{
|
{
|
||||||
@ -212,9 +217,9 @@ mares_common_extract_dives (dc_context_t *context, const mares_common_layout_t *
|
|||||||
|
|
||||||
// Get the freedive mode for this model.
|
// Get the freedive mode for this model.
|
||||||
unsigned int model = data[1];
|
unsigned int model = data[1];
|
||||||
unsigned int freedive = 2;
|
unsigned int freedive = FREEDIVE;
|
||||||
if (model == NEMOWIDE || model == NEMOAIR || model == PUCK || model == PUCKAIR)
|
if (model == NEMOWIDE || model == NEMOAIR || model == PUCK || model == PUCKAIR)
|
||||||
freedive = 3;
|
freedive = GAUGE;
|
||||||
|
|
||||||
// Get the end of the profile ring buffer.
|
// Get the end of the profile ring buffer.
|
||||||
unsigned int eop = array_uint16_le (data + 0x6B);
|
unsigned int eop = array_uint16_le (data + 0x6B);
|
||||||
|
|||||||
@ -39,6 +39,11 @@
|
|||||||
#define NEMOAPNEIST 18
|
#define NEMOAPNEIST 18
|
||||||
#define PUCKAIR 19
|
#define PUCKAIR 19
|
||||||
|
|
||||||
|
#define AIR 0
|
||||||
|
#define NITROX 1
|
||||||
|
#define FREEDIVE 2
|
||||||
|
#define GAUGE 3
|
||||||
|
|
||||||
typedef struct mares_nemo_parser_t mares_nemo_parser_t;
|
typedef struct mares_nemo_parser_t mares_nemo_parser_t;
|
||||||
|
|
||||||
struct mares_nemo_parser_t {
|
struct mares_nemo_parser_t {
|
||||||
@ -87,14 +92,14 @@ mares_nemo_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int
|
|||||||
parser_init (&parser->base, context, &mares_nemo_parser_vtable);
|
parser_init (&parser->base, context, &mares_nemo_parser_vtable);
|
||||||
|
|
||||||
// Get the freedive mode for this model.
|
// Get the freedive mode for this model.
|
||||||
unsigned int freedive = 2;
|
unsigned int freedive = FREEDIVE;
|
||||||
if (model == NEMOWIDE || model == NEMOAIR || model == PUCK || model == PUCKAIR)
|
if (model == NEMOWIDE || model == NEMOAIR || model == PUCK || model == PUCKAIR)
|
||||||
freedive = 3;
|
freedive = GAUGE;
|
||||||
|
|
||||||
// Set the default values.
|
// Set the default values.
|
||||||
parser->model = model;
|
parser->model = model;
|
||||||
parser->freedive = freedive;
|
parser->freedive = freedive;
|
||||||
parser->mode = 0;
|
parser->mode = AIR;
|
||||||
parser->length = 0;
|
parser->length = 0;
|
||||||
parser->sample_count = 0;
|
parser->sample_count = 0;
|
||||||
parser->sample_size = 0;
|
parser->sample_size = 0;
|
||||||
@ -125,7 +130,7 @@ mares_nemo_parser_set_data (dc_parser_t *abstract, const unsigned char *data, un
|
|||||||
// Clear the previous state.
|
// Clear the previous state.
|
||||||
parser->base.data = NULL;
|
parser->base.data = NULL;
|
||||||
parser->base.size = 0;
|
parser->base.size = 0;
|
||||||
parser->mode = 0;
|
parser->mode = AIR;
|
||||||
parser->length = 0;
|
parser->length = 0;
|
||||||
parser->sample_count = 0;
|
parser->sample_count = 0;
|
||||||
parser->sample_size = 0;
|
parser->sample_size = 0;
|
||||||
@ -234,17 +239,17 @@ mares_nemo_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsign
|
|||||||
*((double *) value) = array_uint16_le (p + 53 - 10) / 10.0;
|
*((double *) value) = array_uint16_le (p + 53 - 10) / 10.0;
|
||||||
break;
|
break;
|
||||||
case DC_FIELD_GASMIX_COUNT:
|
case DC_FIELD_GASMIX_COUNT:
|
||||||
if (parser->mode == 0 || parser->mode == 1)
|
if (parser->mode == AIR || parser->mode == NITROX)
|
||||||
*((unsigned int *) value) = 1;
|
*((unsigned int *) value) = 1;
|
||||||
else
|
else
|
||||||
*((unsigned int *) value) = 0;
|
*((unsigned int *) value) = 0;
|
||||||
break;
|
break;
|
||||||
case DC_FIELD_GASMIX:
|
case DC_FIELD_GASMIX:
|
||||||
switch (parser->mode) {
|
switch (parser->mode) {
|
||||||
case 0: // Air
|
case AIR:
|
||||||
gasmix->oxygen = 0.21;
|
gasmix->oxygen = 0.21;
|
||||||
break;
|
break;
|
||||||
case 1: // Nitrox
|
case NITROX:
|
||||||
gasmix->oxygen = p[53 - 43] / 100.0;
|
gasmix->oxygen = p[53 - 43] / 100.0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user