PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 satır
1.3KB

  1. #include <NXPMotionSense.h>
  2. #include <Wire.h>
  3. #include <EEPROM.h>
  4. NXPMotionSense imu;
  5. void setup() {
  6. float offsets[9];
  7. float softIron[9];
  8. float fieldStrength;
  9. int i, j;
  10. Serial.begin(9600);
  11. while (!Serial) ; // wait for serial port open
  12. imu.begin();
  13. Serial.println("Calibration Data");
  14. Serial.println();
  15. imu.getCalibration(offsets, softIron, &fieldStrength);
  16. Serial.println("Magnetic (Hard Iron) Offsets");
  17. for (i=0; i<3; i++) {
  18. printnum(offsets[i + 6], 2);
  19. Serial.println(" uT");
  20. }
  21. Serial.println();
  22. Serial.println("Magnetic Soft Iron Mapping");
  23. for (i=0; i<3; i++) {
  24. for (j=0; j<3; j++) {
  25. printnum(softIron[i*3+j], 4);
  26. }
  27. Serial.println();
  28. }
  29. Serial.println();
  30. Serial.println("Expected Magnetic Field Strength");
  31. printnum(fieldStrength, 2);
  32. Serial.println(" uT");
  33. Serial.println();
  34. Serial.println("Accelerometer Offsets");
  35. for (i=0; i<3; i++) {
  36. printnum(offsets[i], 3);
  37. Serial.println(" g");
  38. }
  39. Serial.println();
  40. Serial.println("Gyroscope Offsets");
  41. for (i=0; i<3; i++) {
  42. printnum(offsets[i + 3], 3);
  43. Serial.println(" degrees/sec");
  44. }
  45. Serial.println();
  46. }
  47. void printnum(float num, int digits) {
  48. Serial.print(" ");
  49. if (num >= 0.0f) Serial.print(' ');
  50. Serial.print(num, digits);
  51. }
  52. void loop() {
  53. }