@@ -149,7 +149,7 @@ bool BNO080::dataAvailable(void)
149149 if (digitalRead (_int) == HIGH)
150150 return (false );
151151 }
152-
152+
153153 if (receivePacket () == true )
154154 {
155155 // Check to see if this packet is a sensor reporting its data to us
@@ -163,11 +163,11 @@ bool BNO080::dataAvailable(void)
163163 parseCommandReport (); // This will update responses to commands, calibrationStatus, etc.
164164 return (true );
165165 }
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+ }
171171 }
172172 return (false );
173173}
@@ -232,12 +232,12 @@ void BNO080::parseInputReport(void)
232232 int16_t dataLength = ((uint16_t )shtpHeader[1 ] << 8 | shtpHeader[0 ]);
233233 dataLength &= ~(1 << 15 ); // Clear the MSbit. This bit indicates if this package is a continuation of the last.
234234 // Ignore it for now. TODO catch this as an error and exit
235-
235+
236236 dataLength -= 4 ; // Remove the header bytes from the data count
237237
238238 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 ));
239239
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
241241 if (shtpHeader[2 ] == CHANNEL_GYRO) {
242242 rawQuatI = (uint16_t )shtpData[1 ] << 8 | shtpData[0 ];
243243 rawQuatJ = (uint16_t )shtpData[3 ] << 8 | shtpData[2 ];
@@ -246,7 +246,7 @@ void BNO080::parseInputReport(void)
246246 rawFastGyroX = (uint16_t )shtpData[9 ] << 8 | shtpData[8 ];
247247 rawFastGyroY = (uint16_t )shtpData[11 ] << 8 | shtpData[10 ];
248248 rawFastGyroZ = (uint16_t )shtpData[13 ] << 8 | shtpData[12 ];
249-
249+
250250 return ;
251251 }
252252
@@ -295,14 +295,20 @@ void BNO080::parseInputReport(void)
295295 rawMagY = data2;
296296 rawMagZ = data3;
297297 }
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)
299302 {
300303 quatAccuracy = status;
301304 rawQuatI = data1;
302305 rawQuatJ = data2;
303306 rawQuatK = data3;
304307 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;
306312 }
307313 else if (shtpData[5 ] == SENSOR_REPORTID_STEP_COUNTER)
308314 {
@@ -878,12 +884,24 @@ void BNO080::enableRotationVector(uint16_t timeBetweenReports)
878884 setFeatureCommand (SENSOR_REPORTID_ROTATION_VECTOR, timeBetweenReports);
879885}
880886
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+
881893// Sends the packet to enable the rotation vector
882894void BNO080::enableGameRotationVector (uint16_t timeBetweenReports)
883895{
884896 setFeatureCommand (SENSOR_REPORTID_GAME_ROTATION_VECTOR, timeBetweenReports);
885897}
886898
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+
887905// Sends the packet to enable the accelerometer
888906void BNO080::enableAccelerometer (uint16_t timeBetweenReports)
889907{
@@ -1198,13 +1216,13 @@ boolean BNO080::receivePacket(void)
11981216 uint8_t packetMSB = _spiPort->transfer (0 );
11991217 uint8_t channelNumber = _spiPort->transfer (0 );
12001218 uint8_t sequenceNumber = _spiPort->transfer (0 ); // Not sure if we need to store this or not
1201-
1219+
12021220 // Store the header info
12031221 shtpHeader[0 ] = packetLSB;
12041222 shtpHeader[1 ] = packetMSB;
12051223 shtpHeader[2 ] = channelNumber;
12061224 shtpHeader[3 ] = sequenceNumber;
1207-
1225+
12081226 // Calculate the number of data bytes in this packet
12091227 uint16_t dataLength = ((uint16_t )packetMSB << 8 | packetLSB);
12101228 dataLength &= ~(1 << 15 ); // Clear the MSbit.
@@ -1226,7 +1244,7 @@ boolean BNO080::receivePacket(void)
12261244 }
12271245
12281246 digitalWrite (_cs, HIGH); // Release BNO080
1229-
1247+
12301248 _spiPort->endTransaction ();
12311249 // printPacket();
12321250 }
0 commit comments