@@ -172,36 +172,38 @@ void BNO080::enableDebugging(Stream &debugPort)
172
172
// Updates the latest variables if possible
173
173
// Returns false if new readings are not available
174
174
bool BNO080::dataAvailable (void )
175
+ {
176
+ return (getReadings () != 0 );
177
+ }
178
+
179
+ uint16_t BNO080::getReadings (void )
175
180
{
176
181
// If we have an interrupt pin connection available, check if data is available.
177
182
// If int pin is not set, then we'll rely on receivePacket() to timeout
178
183
// See issue 13: https://github.com/sparkfun/SparkFun_BNO080_Arduino_Library/issues/13
179
184
if (_int != 255 )
180
185
{
181
186
if (digitalRead (_int) == HIGH)
182
- return ( false ) ;
187
+ return 0 ;
183
188
}
184
189
185
190
if (receivePacket () == true )
186
191
{
187
192
// Check to see if this packet is a sensor reporting its data to us
188
193
if (shtpHeader[2 ] == CHANNEL_REPORTS && shtpData[0 ] == SHTP_REPORT_BASE_TIMESTAMP)
189
194
{
190
- parseInputReport (); // This will update the rawAccelX, etc variables depending on which feature report is found
191
- return (true );
195
+ return parseInputReport (); // This will update the rawAccelX, etc variables depending on which feature report is found
192
196
}
193
197
else if (shtpHeader[2 ] == CHANNEL_CONTROL)
194
198
{
195
- parseCommandReport (); // This will update responses to commands, calibrationStatus, etc.
196
- return (true );
199
+ return parseCommandReport (); // This will update responses to commands, calibrationStatus, etc.
197
200
}
198
201
else if (shtpHeader[2 ] == CHANNEL_GYRO)
199
202
{
200
- parseInputReport (); // This will update the rawAccelX, etc variables depending on which feature report is found
201
- return (true );
203
+ return parseInputReport (); // This will update the rawAccelX, etc variables depending on which feature report is found
202
204
}
203
205
}
204
- return ( false ) ;
206
+ return 0 ;
205
207
}
206
208
207
209
// This function pulls the data from the command response report
@@ -222,7 +224,7 @@ bool BNO080::dataAvailable(void)
222
224
// shtpData[5 + 6]: R6
223
225
// shtpData[5 + 7]: R7
224
226
// shtpData[5 + 8]: R8
225
- void BNO080::parseCommandReport (void )
227
+ uint16_t BNO080::parseCommandReport (void )
226
228
{
227
229
if (shtpData[0 ] == SHTP_REPORT_COMMAND_RESPONSE)
228
230
{
@@ -233,6 +235,7 @@ void BNO080::parseCommandReport(void)
233
235
{
234
236
calibrationStatus = shtpData[5 + 0 ]; // R0 - Status (0 = success, non-zero = fail)
235
237
}
238
+ return shtpData[0 ];
236
239
}
237
240
else
238
241
{
@@ -241,6 +244,7 @@ void BNO080::parseCommandReport(void)
241
244
}
242
245
243
246
// TODO additional feature reports may be strung together. Parse them all.
247
+ return 0 ;
244
248
}
245
249
246
250
// This function pulls the data from the input report
@@ -258,7 +262,7 @@ void BNO080::parseCommandReport(void)
258
262
// shtpData[8:9]: k/accel z/gyro z/etc
259
263
// shtpData[10:11]: real/gyro temp/etc
260
264
// shtpData[12:13]: Accuracy estimate
261
- void BNO080::parseInputReport (void )
265
+ uint16_t BNO080::parseInputReport (void )
262
266
{
263
267
// Calculate the number of data bytes in this packet
264
268
int16_t dataLength = ((uint16_t )shtpHeader[1 ] << 8 | shtpHeader[0 ]);
@@ -279,7 +283,7 @@ void BNO080::parseInputReport(void)
279
283
rawFastGyroY = (uint16_t )shtpData[11 ] << 8 | shtpData[10 ];
280
284
rawFastGyroZ = (uint16_t )shtpData[13 ] << 8 | shtpData[12 ];
281
285
282
- return ;
286
+ return SENSOR_REPORTID_GYRO_INTEGRATED_ROTATION_VECTOR ;
283
287
}
284
288
285
289
uint8_t status = shtpData[5 + 2 ] & 0x03 ; // Get status bits
@@ -398,9 +402,11 @@ void BNO080::parseInputReport(void)
398
402
{
399
403
// This sensor report ID is unhandled.
400
404
// See reference manual to add additional feature reports as needed
405
+ return 0 ;
401
406
}
402
407
403
408
// TODO additional feature reports may be strung together. Parse them all.
409
+ return shtpData[5 ];
404
410
}
405
411
406
412
// Quaternion to Euler conversion
0 commit comments