Skip to content

Commit f93a3fa

Browse files
committed
Separate the Reporting of 'bearing' vs. 'heading.
There seems to be two different ways that dive computers report directional information: 1. report headings that are set by the user by pointing the device in the desired direction, then pressing a button; 2. report the direction that the device is pointing in at set intervals (like every 10 seconds) during the dive. For a user-friendly visualisation, these two approaches need to be shown in different ways in Subsurface: 1. show an event in the profile every time the user executes the 'set heading' operation (and potentially at the start of the dive for the initial heading); 2. show the current bearing in the information box in the profile when the mouse pointer traverses the profile. Subsurface will be using different ways for libdivecomputer backends to import this data: 1. using `DC_SAMPLE_EVENT` samples with `SAMPLE_EVENT_HEADING` type; 2. using `DC_SAMPLE_BEARING` samples. This changeset updates the following dive computers to use 1. to match their type of reporting: - Heinrichs Weikamp OSTC3 / 4 / 5 - ScubaPro / Uwatec Smart The following dive computers are already using 1. correctly: - Suunto EON Steel - Suunto D9 And the following dive computer seems to be using 2. correctly: - Divesoft Freedom / Liberty The following dive computers are currently using 2., but we don't have any information if this is correct: - DiveSystem iDive - Shearwater Predator - Halcyon Symbios Signed-off-by: Michael Keller <[email protected]>
1 parent 71a80b6 commit f93a3fa

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/hw_ostc_parser.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,6 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
11841184

11851185
if (callback) {
11861186
unsigned int value = array_uint16_le(data + offset);
1187-
dc_sample_type_t eventType = DC_SAMPLE_EVENT;
11881187
dc_sample_value_t sample = {
11891188
.event.type = SAMPLE_EVENT_STRING,
11901189
.event.flags = SAMPLE_FLAGS_SEVERITY_INFO,
@@ -1194,21 +1193,20 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
11941193
if (value & OSTC4_COMPASS_HEADING_CLEARED_FLAG) {
11951194
snprintf(buf, BUFLEN, "Cleared compass heading");
11961195
} else {
1196+
sample.event.value = heading;
11971197

11981198
if (value & OSTC4_COMPASS_HEADING_SET_FLAG) {
1199-
eventType = DC_SAMPLE_BEARING;
1200-
sample.bearing = heading;
1199+
sample.event.type = SAMPLE_EVENT_HEADING;
12011200
snprintf(buf, BUFLEN, "Set compass heading [degrees]%s", sample.event.value ? "" : ": 0");
12021201
} else {
1203-
sample.event.value = heading;
12041202
snprintf(buf, BUFLEN, "Logged compass heading [degrees]%s", sample.event.value ? "" : ": 0");
12051203
}
12061204

12071205
}
12081206

12091207
sample.event.name = buf;
12101208

1211-
callback(eventType, &sample, userdata);
1209+
callback(DC_SAMPLE_EVENT, &sample, userdata);
12121210
}
12131211

12141212
offset += 2;

src/uwatec_smart_parser.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,8 +1192,13 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
11921192
}
11931193

11941194
if (have_bearing) {
1195-
sample.bearing = bearing;
1196-
if (callback) callback (DC_SAMPLE_BEARING, &sample, userdata);
1195+
sample.event.type = SAMPLE_EVENT_HEADING;
1196+
sample.event.time = 0;
1197+
sample.event.flags = SAMPLE_FLAGS_SEVERITY_INFO;
1198+
sample.event.value = bearing;
1199+
sample.event.name = NULL;
1200+
1201+
if (callback) callback(DC_SAMPLE_EVENT, &sample, userdata);
11971202
have_bearing = 0;
11981203
}
11991204

0 commit comments

Comments
 (0)