Take the gas model into account to parse the gas mixes.
When the gas model setting is set to air, the individual gas mix definitions retain their previous (non-air) values. This is convenient to avoid having to adjust the gas mixes again on your next nitrox or mixed gas dive. But the consequence is that for air dives, the gas model should take precedence over the individual gas mix definitions, and a single mix with air is returned instead.
This commit is contained in:
parent
136f1d1fe1
commit
4df5e49008
@ -42,6 +42,12 @@
|
||||
#define D6i 0x1A
|
||||
#define D9tx 0x1B
|
||||
|
||||
#define AIR 0
|
||||
#define NITROX 1
|
||||
#define GAUGE 2
|
||||
#define FREEDIVE 3
|
||||
#define MIXED 4
|
||||
|
||||
typedef struct suunto_d9_parser_t suunto_d9_parser_t;
|
||||
|
||||
struct suunto_d9_parser_t {
|
||||
@ -185,6 +191,14 @@ suunto_d9_parser_get_field (parser_t *abstract, parser_field_type_t type, unsign
|
||||
if (size < config)
|
||||
return PARSER_STATUS_ERROR;
|
||||
|
||||
// Gas model
|
||||
unsigned int gasmodel_offset = 0x1D - SKIP;
|
||||
if (parser->model == HELO2)
|
||||
gasmodel_offset += 6;
|
||||
if (parser->model == D4i || parser->model == D6i || parser->model == D9tx)
|
||||
gasmodel_offset = 0x1D;
|
||||
unsigned int gasmodel = data[gasmodel_offset];
|
||||
|
||||
gasmix_t *gasmix = (gasmix_t *) value;
|
||||
|
||||
if (value) {
|
||||
@ -203,7 +217,9 @@ suunto_d9_parser_get_field (parser_t *abstract, parser_field_type_t type, unsign
|
||||
*((double *) value) = array_uint16_le (data + 0x0D - SKIP) / 100.0;
|
||||
break;
|
||||
case FIELD_TYPE_GASMIX_COUNT:
|
||||
if (parser->model == HELO2) {
|
||||
if (gasmodel == AIR) {
|
||||
*((unsigned int *) value) = 1;
|
||||
} else if (parser->model == HELO2) {
|
||||
*((unsigned int *) value) = 8;
|
||||
} else if (parser->model == D9tx) {
|
||||
*((unsigned int *) value) = 8;
|
||||
@ -216,7 +232,10 @@ suunto_d9_parser_get_field (parser_t *abstract, parser_field_type_t type, unsign
|
||||
}
|
||||
break;
|
||||
case FIELD_TYPE_GASMIX:
|
||||
if (parser->model == HELO2) {
|
||||
if (gasmodel == AIR) {
|
||||
gasmix->helium = 0.0;
|
||||
gasmix->oxygen = 0.21;
|
||||
} else if (parser->model == HELO2) {
|
||||
gasmix->helium = data[0x58 - SKIP + 6 * flags + 2] / 100.0;
|
||||
gasmix->oxygen = data[0x58 - SKIP + 6 * flags + 1] / 100.0;
|
||||
} else if (parser->model == D9tx) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user