Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
HMC5883.h
00001 // based on http://mbed.org/users/BlazeX/code/HMC5883/ 00002 00003 #ifndef HMC5883_H 00004 #define HMC5883_H 00005 00006 #include "mbed.h" 00007 #include "I2C_Sensor.h" 00008 00009 #define HMC5883_I2C_ADDRESS 0x3C 00010 00011 #define HMC5883_CONF_REG_A 0x00 00012 #define HMC5883_CONF_REG_B 0x01 00013 #define HMC5883_MODE_REG 0x02 00014 #define HMC5883_DATA_OUT_X_MSB 0x03 00015 00016 class HMC5883 : public I2C_Sensor 00017 { 00018 public: 00019 HMC5883(PinName sda, PinName scl); 00020 float data[3]; // where the measured data is saved 00021 void read(); // read all axis from register to array data 00022 void calibrate(int s); 00023 float get_angle(); 00024 00025 private: 00026 int raw[3]; 00027 void readraw(); // function to get raw data 00028 00029 float scale[3]; // calibration parameters 00030 float offset[3]; 00031 }; 00032 00033 #endif
Generated on Tue Jul 12 2022 20:54:01 by
1.7.2
