Revision fcd68623 Adafruit_BNO055.cpp
Adafruit_BNO055.cpp | ||
---|---|---|
306 | 306 |
} |
307 | 307 |
|
308 | 308 |
/**************************************************************************/ |
309 |
/* |
|
310 |
Prints a float or double with the specified number of decimal places. |
|
311 |
|
|
312 |
'precision' should be 1 followed by a zero for every decimal place |
|
313 |
desired, so '100' will produce two decimal places: |
|
314 |
|
|
315 |
print_double(3.1415, 100); // Output = 3.14 |
|
316 |
*/ |
|
317 |
/**************************************************************************/ |
|
318 |
void Adafruit_BNO055::printDouble(double val, unsigned int precision) |
|
319 |
{ |
|
320 |
/* Print the integer portion */ |
|
321 |
Serial.print (int(val)); |
|
322 |
Serial.print("."); |
|
323 |
|
|
324 |
/* Print the fraction portion */ |
|
325 |
unsigned int frac; |
|
326 |
if(val >= 0) |
|
327 |
{ |
|
328 |
frac = (val - int(val)) * precision; |
|
329 |
} |
|
330 |
else |
|
331 |
{ |
|
332 |
frac = (int(val)- val ) * precision; |
|
333 |
} |
|
334 |
Serial.println(frac,DEC) ; |
|
335 |
} |
|
336 |
|
|
337 |
/**************************************************************************/ |
|
309 | 338 |
/*! |
310 | 339 |
@brief Provides the sensor_t data for this sensor |
311 | 340 |
*/ |
... | ... | |
334 | 363 |
/**************************************************************************/ |
335 | 364 |
bool Adafruit_BNO055::getEvent(sensors_event_t *event) |
336 | 365 |
{ |
337 |
float orientation; |
|
338 |
|
|
339 | 366 |
/* Clear the event */ |
340 | 367 |
memset(event, 0, sizeof(sensors_event_t)); |
341 | 368 |
|
342 | 369 |
event->version = sizeof(sensors_event_t); |
343 | 370 |
event->sensor_id = _sensorID; |
344 | 371 |
event->type = SENSOR_TYPE_ORIENTATION; |
345 |
event->timestamp = 0; |
|
346 |
/* |
|
347 |
getPressure(&pressure_kPa); |
|
348 |
event->pressure = pressure_kPa / 100.0F; |
|
349 |
*/ |
|
350 |
|
|
372 |
event->timestamp = millis(); |
|
373 |
|
|
374 |
/* Get a Euler angle sample for orientation */ |
|
375 |
imu::Vector<3> euler = getVector(Adafruit_BNO055::VECTOR_EULER); |
|
376 |
event->orientation.x = euler.x(); |
|
377 |
event->orientation.y = euler.y(); |
|
378 |
event->orientation.z = euler.z(); |
|
379 |
|
|
351 | 380 |
return true; |
352 | 381 |
} |
353 | 382 |
|
Also available in: Unified diff