Skip to content

Commit 6f19abf

Browse files
authored
Merge pull request #73 from mikeller/add_hw_compass_heading_logging
2 parents 34556d4 + db8e668 commit 6f19abf

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/hw_ostc_parser.c

+34
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,40 @@ hw_ostc_parser_internal_foreach (hw_ostc_parser_t *parser, dc_sample_callback_t
11311131
offset += 2;
11321132
length -= 2;
11331133
}
1134+
1135+
// Compass heading update
1136+
if (events & 0x0200) {
1137+
if (length < 2) {
1138+
ERROR (abstract->context, "Buffer overflow detected!");
1139+
return DC_STATUS_DATAFORMAT;
1140+
}
1141+
1142+
if (callback) {
1143+
unsigned int heading = array_uint16_le(data + offset);
1144+
dc_sample_value_t sample = {
1145+
.event.type = SAMPLE_EVENT_STRING,
1146+
.event.flags = SAMPLE_FLAGS_SEVERITY_INFO,
1147+
};
1148+
1149+
if (heading & 0x8000) {
1150+
sample.event.name = "Cleared compass heading";
1151+
} else {
1152+
if (heading & 0x4000) {
1153+
sample.event.type = SAMPLE_EVENT_HEADING;
1154+
sample.event.name = "Set compass heading";
1155+
} else {
1156+
sample.event.name = "Logged compass heading";
1157+
}
1158+
1159+
sample.event.value = heading & 0x1FF;
1160+
}
1161+
1162+
callback(DC_SAMPLE_EVENT, &sample, userdata);
1163+
}
1164+
1165+
offset += 2;
1166+
length -= 2;
1167+
}
11341168
}
11351169

11361170
// Extended sample info.

0 commit comments

Comments
 (0)