@@ -149,7 +149,7 @@ bool BNO080::dataAvailable(void)
149
149
if (digitalRead (_int) == HIGH)
150
150
return (false );
151
151
}
152
-
152
+
153
153
if (receivePacket () == true )
154
154
{
155
155
// Check to see if this packet is a sensor reporting its data to us
@@ -163,11 +163,11 @@ bool BNO080::dataAvailable(void)
163
163
parseCommandReport (); // This will update responses to commands, calibrationStatus, etc.
164
164
return (true );
165
165
}
166
- else if (shtpHeader[2 ] == CHANNEL_GYRO)
167
- {
168
- parseInputReport (); // This will update the rawAccelX, etc variables depending on which feature report is found
169
- return (true );
170
- }
166
+ else if (shtpHeader[2 ] == CHANNEL_GYRO)
167
+ {
168
+ parseInputReport (); // This will update the rawAccelX, etc variables depending on which feature report is found
169
+ return (true );
170
+ }
171
171
}
172
172
return (false );
173
173
}
@@ -232,12 +232,12 @@ void BNO080::parseInputReport(void)
232
232
int16_t dataLength = ((uint16_t )shtpHeader[1 ] << 8 | shtpHeader[0 ]);
233
233
dataLength &= ~(1 << 15 ); // Clear the MSbit. This bit indicates if this package is a continuation of the last.
234
234
// Ignore it for now. TODO catch this as an error and exit
235
-
235
+
236
236
dataLength -= 4 ; // Remove the header bytes from the data count
237
237
238
238
timeStamp = ((uint32_t )shtpData[4 ] << (8 * 3 )) | ((uint32_t )shtpData[3 ] << (8 * 2 )) | ((uint32_t )shtpData[2 ] << (8 * 1 )) | ((uint32_t )shtpData[1 ] << (8 * 0 ));
239
239
240
- // The gyro-integrated input reports are sent via the special gyro channel and do no include the usual ID, sequence, and status fields
240
+ // The gyro-integrated input reports are sent via the special gyro channel and do no include the usual ID, sequence, and status fields
241
241
if (shtpHeader[2 ] == CHANNEL_GYRO) {
242
242
rawQuatI = (uint16_t )shtpData[1 ] << 8 | shtpData[0 ];
243
243
rawQuatJ = (uint16_t )shtpData[3 ] << 8 | shtpData[2 ];
@@ -246,7 +246,7 @@ void BNO080::parseInputReport(void)
246
246
rawFastGyroX = (uint16_t )shtpData[9 ] << 8 | shtpData[8 ];
247
247
rawFastGyroY = (uint16_t )shtpData[11 ] << 8 | shtpData[10 ];
248
248
rawFastGyroZ = (uint16_t )shtpData[13 ] << 8 | shtpData[12 ];
249
-
249
+
250
250
return ;
251
251
}
252
252
@@ -295,14 +295,20 @@ void BNO080::parseInputReport(void)
295
295
rawMagY = data2;
296
296
rawMagZ = data3;
297
297
}
298
- else if (shtpData[5 ] == SENSOR_REPORTID_ROTATION_VECTOR || shtpData[5 ] == SENSOR_REPORTID_GAME_ROTATION_VECTOR)
298
+ else if (shtpData[5 ] == SENSOR_REPORTID_ROTATION_VECTOR ||
299
+ shtpData[5 ] == SENSOR_REPORTID_GAME_ROTATION_VECTOR ||
300
+ shtpData[5 ] == SENSOR_REPORTID_AR_VR_STABILIZED_ROTATION_VECTOR ||
301
+ shtpData[5 ] == SENSOR_REPORTID_AR_VR_STABILIZED_GAME_ROTATION_VECTOR)
299
302
{
300
303
quatAccuracy = status;
301
304
rawQuatI = data1;
302
305
rawQuatJ = data2;
303
306
rawQuatK = data3;
304
307
rawQuatReal = data4;
305
- rawQuatRadianAccuracy = data5; // Only available on rotation vector, not game rot vector
308
+
309
+ // Only available on rotation vector and ar/vr stabilized rotation vector,
310
+ // not game rot vector and not ar/vr stabilized rotation vector
311
+ rawQuatRadianAccuracy = data5;
306
312
}
307
313
else if (shtpData[5 ] == SENSOR_REPORTID_STEP_COUNTER)
308
314
{
@@ -878,12 +884,24 @@ void BNO080::enableRotationVector(uint16_t timeBetweenReports)
878
884
setFeatureCommand (SENSOR_REPORTID_ROTATION_VECTOR, timeBetweenReports);
879
885
}
880
886
887
+ // Sends the packet to enable the ar/vr stabilized rotation vector
888
+ void BNO080::enableARVRStabilizedRotationVector (uint16_t timeBetweenReports)
889
+ {
890
+ setFeatureCommand (SENSOR_REPORTID_AR_VR_STABILIZED_ROTATION_VECTOR, timeBetweenReports);
891
+ }
892
+
881
893
// Sends the packet to enable the rotation vector
882
894
void BNO080::enableGameRotationVector (uint16_t timeBetweenReports)
883
895
{
884
896
setFeatureCommand (SENSOR_REPORTID_GAME_ROTATION_VECTOR, timeBetweenReports);
885
897
}
886
898
899
+ // Sends the packet to enable the ar/vr stabilized rotation vector
900
+ void BNO080::enableARVRStabilizedGameRotationVector (uint16_t timeBetweenReports)
901
+ {
902
+ setFeatureCommand (SENSOR_REPORTID_AR_VR_STABILIZED_GAME_ROTATION_VECTOR, timeBetweenReports);
903
+ }
904
+
887
905
// Sends the packet to enable the accelerometer
888
906
void BNO080::enableAccelerometer (uint16_t timeBetweenReports)
889
907
{
@@ -1198,13 +1216,13 @@ boolean BNO080::receivePacket(void)
1198
1216
uint8_t packetMSB = _spiPort->transfer (0 );
1199
1217
uint8_t channelNumber = _spiPort->transfer (0 );
1200
1218
uint8_t sequenceNumber = _spiPort->transfer (0 ); // Not sure if we need to store this or not
1201
-
1219
+
1202
1220
// Store the header info
1203
1221
shtpHeader[0 ] = packetLSB;
1204
1222
shtpHeader[1 ] = packetMSB;
1205
1223
shtpHeader[2 ] = channelNumber;
1206
1224
shtpHeader[3 ] = sequenceNumber;
1207
-
1225
+
1208
1226
// Calculate the number of data bytes in this packet
1209
1227
uint16_t dataLength = ((uint16_t )packetMSB << 8 | packetLSB);
1210
1228
dataLength &= ~(1 << 15 ); // Clear the MSbit.
@@ -1226,7 +1244,7 @@ boolean BNO080::receivePacket(void)
1226
1244
}
1227
1245
1228
1246
digitalWrite (_cs, HIGH); // Release BNO080
1229
-
1247
+
1230
1248
_spiPort->endTransaction ();
1231
1249
// printPacket();
1232
1250
}
0 commit comments