fix my screwed up sensor data parsing

This commit is contained in:
samhenrigold
2025-09-06 18:34:06 -04:00
parent d590174cdd
commit f608105ce7
2 changed files with 4 additions and 3 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -126,9 +126,9 @@
if (result == kIOReturnSuccess && reportLength >= 3) { if (result == kIOReturnSuccess && reportLength >= 3) {
// Data format: [report_id, angle_low, angle_high] // Data format: [report_id, angle_low, angle_high]
// Example: [01 72 00] = 0x7201 centidegrees = 291.85 degrees // Parse the 16-bit value from bytes 1-2 (skipping report ID)
uint16_t rawValue = *(uint16_t*)(report); uint16_t rawValue = (report[2] << 8) | report[1]; // High byte, low byte
double angle = rawValue * 0.01; // Convert centidegrees to degrees double angle = (double)rawValue; // Raw value is already in degrees
return angle; return angle;
} }