-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd6805e
commit bcded56
Showing
8 changed files
with
220 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 0 additions & 63 deletions
63
examples/LSM6DSO_Wire1_SimpleAccelerometer/LSM6DSO_Wire1_SimpleAccelerometer.ino
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
examples/sensor_fusion/sensor_calibration_read/sensor_calibration_read.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "Adafruit_Sensor_Calibration.h" | ||
|
||
// select either EEPROM or SPI FLASH storage: | ||
#ifdef ADAFRUIT_SENSOR_CALIBRATION_USE_EEPROM | ||
Adafruit_Sensor_Calibration_EEPROM cal; | ||
#else | ||
Adafruit_Sensor_Calibration_SDFat cal; | ||
#endif | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
while (!Serial) delay(10); | ||
|
||
delay(100); | ||
Serial.println("Calibration filesys test"); | ||
if (!cal.begin()) { | ||
Serial.println("Failed to initialize calibration helper"); | ||
while (1) yield(); | ||
} | ||
Serial.print("Has EEPROM: "); Serial.println(cal.hasEEPROM()); | ||
Serial.print("Has FLASH: "); Serial.println(cal.hasFLASH()); | ||
|
||
if (! cal.loadCalibration()) { | ||
Serial.println("**WARNING** No calibration loaded/found"); | ||
} | ||
cal.printSavedCalibration(); | ||
|
||
Serial.println("Calibrations found: "); | ||
Serial.print("\tMagnetic Hard Offset: "); | ||
for (int i=0; i<3; i++) { | ||
Serial.print(cal.mag_hardiron[i]); | ||
if (i != 2) Serial.print(", "); | ||
} | ||
Serial.println(); | ||
|
||
Serial.print("\tMagnetic Soft Offset: "); | ||
for (int i=0; i<9; i++) { | ||
Serial.print(cal.mag_softiron[i]); | ||
if (i != 8) Serial.print(", "); | ||
} | ||
Serial.println(); | ||
|
||
Serial.print("\tMagnetic Field Magnitude: "); | ||
Serial.println(cal.mag_field); | ||
|
||
Serial.print("\tGyro Zero Rate Offset: "); | ||
for (int i=0; i<3; i++) { | ||
Serial.print(cal.gyro_zerorate[i]); | ||
if (i != 2) Serial.print(", "); | ||
} | ||
Serial.println(); | ||
|
||
Serial.print("\tAccel Zero G Offset: "); | ||
for (int i=0; i<3; i++) { | ||
Serial.print(cal.accel_zerog[i]); | ||
if (i != 2) Serial.print(", "); | ||
} | ||
Serial.println(); | ||
} | ||
|
||
void loop() { | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
examples/sensor_fusion/sensor_calibration_write/sensor_calibration_write.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include "Adafruit_Sensor_Calibration.h" | ||
|
||
// select either EEPROM or SPI FLASH storage: | ||
#ifdef ADAFRUIT_SENSOR_CALIBRATION_USE_EEPROM | ||
Adafruit_Sensor_Calibration_EEPROM cal; | ||
#else | ||
Adafruit_Sensor_Calibration_SDFat cal; | ||
#endif | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
while (!Serial) delay(10); | ||
|
||
delay(100); | ||
Serial.println("Calibration filesys test"); | ||
if (!cal.begin()) { | ||
Serial.println("Failed to initialize calibration helper"); | ||
while (1) yield(); | ||
} | ||
Serial.print("Has EEPROM: "); Serial.println(cal.hasEEPROM()); | ||
Serial.print("Has FLASH: "); Serial.println(cal.hasFLASH()); | ||
|
||
if (! cal.loadCalibration()) { | ||
Serial.println("No calibration loaded/found... will start with defaults"); | ||
} else { | ||
Serial.println("Loaded existing calibration"); | ||
} | ||
|
||
// in uTesla | ||
cal.mag_hardiron[0] = 9.7; | ||
cal.mag_hardiron[1] = -0.41; | ||
cal.mag_hardiron[2] = 3.57; | ||
|
||
// in uTesla | ||
cal.mag_softiron[0] = 0.991; | ||
cal.mag_softiron[1] = -0.001; | ||
cal.mag_softiron[2] = 0.002; | ||
cal.mag_softiron[3] = -0.001; | ||
cal.mag_softiron[4] = 1.002; | ||
cal.mag_softiron[5] = -0.011; | ||
cal.mag_softiron[6] = 0.002; | ||
cal.mag_softiron[7] = 0.011; | ||
cal.mag_softiron[8] = 1.008; | ||
// Earth total magnetic field strength in uTesla (dependent on location and time of the year), | ||
// visit: https://www.ngdc.noaa.gov/geomag/calculators/magcalc.shtml#igrfwmm) | ||
cal.mag_field = 47.27; // approximate value for locations along the equator | ||
|
||
// in Radians/s | ||
cal.gyro_zerorate[0] = 0.0; | ||
cal.gyro_zerorate[1] = 0.0; | ||
cal.gyro_zerorate[2] = 0.0; | ||
|
||
cal.accel_zerog[0] = 0.0; | ||
cal.accel_zerog[1] = 0.0; | ||
cal.accel_zerog[2] = 0.0; | ||
|
||
if (! cal.saveCalibration()) { | ||
Serial.println("**WARNING** Couldn't save calibration"); | ||
} else { | ||
Serial.println("Wrote calibration"); | ||
} | ||
|
||
cal.printSavedCalibration(); | ||
} | ||
|
||
void loop() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.