BMM150class.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include <Arduino.h>
  2. #include <Wire.h>
  3. #include "Preferences.h"
  4. #include "M5Stack.h"
  5. #include "math.h"
  6. #include "bmm150.h"
  7. #include "bmm150_defs.h"
  8. class BMM150class
  9. {
  10. public:
  11. Preferences prefs;
  12. struct bmm150_dev dev;
  13. bmm150_mag_data mag_offset;
  14. bmm150_mag_data mag_scale; // for Soft iron distortion
  15. bmm150_mag_data mag_max;
  16. bmm150_mag_data mag_min;
  17. bmm150_mag_data mag_chord; // for Soft iron distortion
  18. private:
  19. // int8_t i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *read_data, uint16_t len);
  20. // int8_t i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *read_data, uint16_t len);
  21. int8_t bmm150_initialization();
  22. void bmm150_offset_save();
  23. void bmm150_offset_load();
  24. // void setup();
  25. public:
  26. BMM150class();
  27. void Init(void);
  28. void bmm150_calibrate(uint32_t calibrate_time);
  29. void getMagnetData(float *mx, float *my, float *mz);
  30. void getMagnetOffset(float *mx, float *my, float *mz); // hard iron
  31. void getMagnetScale(float *mx, float *my, float *mz); // soft iron
  32. };