Revision 8e095f02
| Adafruit_BNO055.cpp | ||
|---|---|---|
| 395 | 395 |
@brief Reads the sensor's offset registers into a byte array |
| 396 | 396 |
*/ |
| 397 | 397 |
/**************************************************************************/ |
| 398 |
bool Adafruit_BNO055::getSensorOffsets(int8_t* calibData) |
|
| 398 |
bool Adafruit_BNO055::getSensorOffsets(uint8_t* calibData)
|
|
| 399 | 399 |
{
|
| 400 | 400 |
if (isFullyCalibrated()) |
| 401 | 401 |
{
|
| ... | ... | |
| 450 | 450 |
@brief Writes an array of calibration values to the sensor's offset registers |
| 451 | 451 |
*/ |
| 452 | 452 |
/**************************************************************************/ |
| 453 |
void Adafruit_BNO055::setSensorOffsets(const int8_t* calibData) |
|
| 453 |
void Adafruit_BNO055::setSensorOffsets(const uint8_t* calibData)
|
|
| 454 | 454 |
{
|
| 455 | 455 |
adafruit_bno055_opmode_t lastMode = _mode; |
| 456 | 456 |
setMode(OPERATION_MODE_CONFIG); |
| Adafruit_BNO055.h | ||
|---|---|---|
| 44 | 44 |
|
| 45 | 45 |
typedef struct |
| 46 | 46 |
{
|
| 47 |
int16_t accel_offset_x; |
|
| 48 |
int16_t accel_offset_y; |
|
| 49 |
int16_t accel_offset_z; |
|
| 50 |
int16_t gyro_offset_x; |
|
| 51 |
int16_t gyro_offset_y; |
|
| 52 |
int16_t gyro_offset_z; |
|
| 53 |
int16_t mag_offset_x; |
|
| 54 |
int16_t mag_offset_y; |
|
| 55 |
int16_t mag_offset_z; |
|
| 56 |
|
|
| 57 |
int16_t accel_radius; |
|
| 58 |
int16_t mag_radius; |
|
| 47 |
uint16_t accel_offset_x;
|
|
| 48 |
uint16_t accel_offset_y;
|
|
| 49 |
uint16_t accel_offset_z;
|
|
| 50 |
uint16_t gyro_offset_x;
|
|
| 51 |
uint16_t gyro_offset_y;
|
|
| 52 |
uint16_t gyro_offset_z;
|
|
| 53 |
uint16_t mag_offset_x;
|
|
| 54 |
uint16_t mag_offset_y;
|
|
| 55 |
uint16_t mag_offset_z;
|
|
| 56 |
|
|
| 57 |
uint16_t accel_radius;
|
|
| 58 |
uint16_t mag_radius;
|
|
| 59 | 59 |
} adafruit_bno055_offsets_t; |
| 60 | 60 |
|
| 61 | 61 |
class Adafruit_BNO055 : public Adafruit_Sensor |
| ... | ... | |
| 279 | 279 |
void getSensor(sensor_t*); |
| 280 | 280 |
|
| 281 | 281 |
/* Functions to deal with raw calibration data */ |
| 282 |
bool getSensorOffsets(int8_t* calibData); |
|
| 282 |
bool getSensorOffsets(uint8_t* calibData);
|
|
| 283 | 283 |
bool getSensorOffsets(adafruit_bno055_offsets_t &offsets_type); |
| 284 |
void setSensorOffsets(const int8_t* calibData); |
|
| 284 |
void setSensorOffsets(const uint8_t* calibData);
|
|
| 285 | 285 |
void setSensorOffsets(const adafruit_bno055_offsets_t &offsets_type); |
| 286 | 286 |
bool isFullyCalibrated(void); |
| 287 | 287 |
|
| examples/restore_offsets/restore_offsets.ino | ||
|---|---|---|
| 177 | 177 |
bno.getSensor(&sensor); |
| 178 | 178 |
if (bnoID != sensor.sensor_id) |
| 179 | 179 |
{
|
| 180 |
Serial.println("No Calibration Data for this sensor exists in EEPROM");
|
|
| 180 |
Serial.println("\nNo Calibration Data for this sensor exists in EEPROM");
|
|
| 181 | 181 |
} |
| 182 | 182 |
else |
| 183 | 183 |
{
|
| 184 |
Serial.println("Found Calibration for this sensor in EEPROM.");
|
|
| 184 |
Serial.println("\nFound Calibration for this sensor in EEPROM.");
|
|
| 185 | 185 |
eeAddress += sizeof(long); |
| 186 | 186 |
EEPROM.get(eeAddress, calibrationData); |
| 187 | 187 |
|
| ... | ... | |
| 241 | 241 |
Serial.println("\nFully calibrated!");
|
| 242 | 242 |
Serial.println("--------------------------------");
|
| 243 | 243 |
Serial.println("Calibration Results: ");
|
| 244 |
bno.getSensorOffsets(calibrationData); |
|
| 245 |
displaySensorOffsets(calibrationData); |
|
| 244 |
adafruit_bno055_offsets_t newCalib; |
|
| 245 |
bno.getSensorOffsets(newCalib); |
|
| 246 |
displaySensorOffsets(newCalib); |
|
| 246 | 247 |
|
| 247 | 248 |
Serial.println("\n\nStoring calibration data to EEPROM...");
|
| 248 | 249 |
|
| ... | ... | |
| 253 | 254 |
EEPROM.put(eeAddress, bnoID); |
| 254 | 255 |
|
| 255 | 256 |
eeAddress += sizeof(long); |
| 256 |
EEPROM.put(eeAddress, calibrationData);
|
|
| 257 |
Serial.println("Data stored to EEPROM.\n");
|
|
| 257 |
EEPROM.put(eeAddress, newCalib);
|
|
| 258 |
Serial.println("Data stored to EEPROM.");
|
|
| 258 | 259 |
|
| 259 | 260 |
Serial.println("\n--------------------------------\n");
|
| 261 |
delay(500); |
|
| 260 | 262 |
} |
| 261 | 263 |
|
| 262 | 264 |
void loop() {
|
Also available in: Unified diff