Skip to content

Commit

Permalink
Add support for parsing the compass bearings
Browse files Browse the repository at this point in the history
When no compass bearing is set on the dive computer, the stored value is
initialized to zero. Since this can also be a valid value, those zero
values are only ignored untill another non-zero value is present.

In later firmware versions, the value will get initialized to 0xFFFF
instead.
  • Loading branch information
jefdriesen committed Nov 23, 2023
1 parent 2d9008a commit 08d8c3e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/divesystem_idive_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
unsigned int algorithm_previous = INVALID;
unsigned int gf_low = INVALID;
unsigned int gf_high = INVALID;
unsigned int have_bearing = 0;

unsigned int firmware = 0;
unsigned int apos4 = 0;
Expand Down Expand Up @@ -618,6 +619,16 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
tank[tank_idx].endpressure = pressure;
}
}

// Compass bearing
unsigned int bearing = array_uint16_le (data + offset + 50);
if (bearing != 0) {
have_bearing = 1; // Stop ignoring zero values.
}
if (have_bearing && bearing != 0xFFFF) {
sample.bearing = bearing;
if (callback) callback (DC_SAMPLE_BEARING, &sample, userdata);
}
}

offset += samplesize;
Expand Down

0 comments on commit 08d8c3e

Please sign in to comment.