Remove disabled gas mixes
Returning disabled gas mixes to the application mainly results in lots of unnecessary information. Therefore, remove all disabled gas mixes, unless they are actively used. Many other dive computers do not even include disabled gas mixes in the data. Unlike previously assumed, the on/off state of each gas mix is actually available in the PNF data format (opening record 4). For the older Predator data format, this info isn't available and all gas mixes are manually marked as enabled.
This commit is contained in:
parent
e1762fc8bd
commit
2d9008aff7
@ -107,6 +107,8 @@ typedef struct shearwater_predator_gasmix_t {
|
|||||||
unsigned int oxygen;
|
unsigned int oxygen;
|
||||||
unsigned int helium;
|
unsigned int helium;
|
||||||
unsigned int diluent;
|
unsigned int diluent;
|
||||||
|
unsigned int enabled;
|
||||||
|
unsigned int active;
|
||||||
} shearwater_predator_gasmix_t;
|
} shearwater_predator_gasmix_t;
|
||||||
|
|
||||||
typedef struct shearwater_predator_tank_t {
|
typedef struct shearwater_predator_tank_t {
|
||||||
@ -245,6 +247,8 @@ shearwater_common_parser_create (dc_parser_t **out, dc_context_t *context, const
|
|||||||
parser->gasmix[i].oxygen = 0;
|
parser->gasmix[i].oxygen = 0;
|
||||||
parser->gasmix[i].helium = 0;
|
parser->gasmix[i].helium = 0;
|
||||||
parser->gasmix[i].diluent = 0;
|
parser->gasmix[i].diluent = 0;
|
||||||
|
parser->gasmix[i].enabled = 0;
|
||||||
|
parser->gasmix[i].active = 0;
|
||||||
}
|
}
|
||||||
parser->ntanks = 0;
|
parser->ntanks = 0;
|
||||||
for (unsigned int i = 0; i < NTANKS; ++i) {
|
for (unsigned int i = 0; i < NTANKS; ++i) {
|
||||||
@ -395,6 +399,7 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
|
|||||||
gasmix[i].oxygen = data[20 + i];
|
gasmix[i].oxygen = data[20 + i];
|
||||||
gasmix[i].helium = data[30 + i];
|
gasmix[i].helium = data[30 + i];
|
||||||
gasmix[i].diluent = i >= 5;
|
gasmix[i].diluent = i >= 5;
|
||||||
|
gasmix[i].enabled = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,6 +448,8 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
|
|||||||
ngasmixes = idx + 1;
|
ngasmixes = idx + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gasmix[idx].active = 1;
|
||||||
|
|
||||||
o2_previous = o2;
|
o2_previous = o2;
|
||||||
he_previous = he;
|
he_previous = he;
|
||||||
dil_previous = ccr;
|
dil_previous = ccr;
|
||||||
@ -552,6 +559,13 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gas mix on/off state.
|
||||||
|
unsigned int state = array_uint16_be (data + offset + 17);
|
||||||
|
for (unsigned int i = 0; i < NFIXED; ++i) {
|
||||||
|
gasmix[i].enabled = (state & (1 << i)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int gtrmode = data[offset + 29];
|
unsigned int gtrmode = data[offset + 29];
|
||||||
if (popcount(gtrmode) >= 2) {
|
if (popcount(gtrmode) >= 2) {
|
||||||
for (unsigned int i = 0; i < 4; ++i) {
|
for (unsigned int i = 0; i < 4; ++i) {
|
||||||
@ -678,6 +692,8 @@ shearwater_predator_parser_cache (shearwater_predator_parser_t *parser)
|
|||||||
for (unsigned int i = 0; i < ngasmixes; ++i) {
|
for (unsigned int i = 0; i < ngasmixes; ++i) {
|
||||||
if (gasmix[i].oxygen == 0 && gasmix[i].helium == 0)
|
if (gasmix[i].oxygen == 0 && gasmix[i].helium == 0)
|
||||||
continue;
|
continue;
|
||||||
|
if (!gasmix[i].enabled && !gasmix[i].active)
|
||||||
|
continue;
|
||||||
if (gasmix[i].diluent && !shearwater_predator_is_ccr (divemode))
|
if (gasmix[i].diluent && !shearwater_predator_is_ccr (divemode))
|
||||||
continue;
|
continue;
|
||||||
parser->gasmix[parser->ngasmixes] = gasmix[i];
|
parser->gasmix[parser->ngasmixes] = gasmix[i];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user