Use a variable for gauge mode.

This makes the code a little bit more readable, without needing any
comments.
This commit is contained in:
Jef Driesen 2015-05-03 20:09:43 +02:00
parent e1f939c131
commit 5a61ffcc2f

View File

@ -243,6 +243,8 @@ suunto_vyper_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
if (rc != DC_STATUS_SUCCESS) if (rc != DC_STATUS_SUCCESS)
return rc; return rc;
unsigned int gauge = data[4] & 0x40;
if (value) { if (value) {
switch (type) { switch (type) {
case DC_FIELD_DIVETIME: case DC_FIELD_DIVETIME:
@ -252,8 +254,8 @@ suunto_vyper_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
*((double *) value) = parser->maxdepth * FEET; *((double *) value) = parser->maxdepth * FEET;
break; break;
case DC_FIELD_GASMIX_COUNT: case DC_FIELD_GASMIX_COUNT:
if (data[4] & 0x40) if (gauge)
*((unsigned int *) value) = 0; // Gauge mode *((unsigned int *) value) = 0;
else else
*((unsigned int *) value) = parser->ngasmixes; *((unsigned int *) value) = parser->ngasmixes;
break; break;
@ -269,7 +271,7 @@ suunto_vyper_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
*((double *) value) = (signed char) data[parser->marker + 1]; *((double *) value) = (signed char) data[parser->marker + 1];
break; break;
case DC_FIELD_DIVEMODE: case DC_FIELD_DIVEMODE:
if (data[4] & 0x40) { if (gauge) {
*((dc_divemode_t *) value) = DC_DIVEMODE_GAUGE; *((dc_divemode_t *) value) = DC_DIVEMODE_GAUGE;
} else { } else {
*((dc_divemode_t *) value) = DC_DIVEMODE_OC; *((dc_divemode_t *) value) = DC_DIVEMODE_OC;