fusion_hat.modules.magnetometer module
- class fusion_hat.modules.magnetometer.MagnetometerType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum- mag_QMC6310 = 1
- mag_QMC5883P = 2
- mag_QMC5883L = 3
- mag_HMC5883L = 4
- fusion_hat.modules.magnetometer.i2c_ack(bus, addr)[source]
Check if a device responds at the specified I2C address
- Parameters:
bus – SMBus instance
addr – I2C address to check
- Returns:
True if the device responds, False otherwise
- Return type:
bool
- class fusion_hat.modules.magnetometer.QMC6310(bus: smbus2.SMBus, addr: int = 28, field_range='8G')[source]
Bases:
object- DEF_ADDR = 28
# Define register address of QMC6310 compass sensor
- QMC6310_REG_DATA_START = 1
- QMC6310_REG_DTAT_X = 1
- QMC6310_REG_DTAT_Y = 3
- QMC6310_REG_DTAT_Z = 5
- QMC6310_REG_STATUS = 9
- QMC6310_REG_CONTROL_1 = 10
- QMC6310_REG_CONTROL_2 = 11
# Define the register parameter configuration of the sensor
- QMC6310_VAL_MODE_SUSPEND = 0
- QMC6310_VAL_MODE_NORMAL = 1
- QMC6310_VAL_MODE_SINGLE = 2
- QMC6310_VAL_MODE_CONTINUOUS = 3
- QMC6310_VAL_ODR_10HZ = 0
- QMC6310_VAL_ODR_50HZ = 4
- QMC6310_VAL_ODR_100HZ = 8
- QMC6310_VAL_ODR_200HZ = 12
- QMC6310_VAL_OSR1_8 = 0
- QMC6310_VAL_OSR1_4 = 16
- QMC6310_VAL_OSR1_2 = 32
- QMC6310_VAL_OSR1_1 = 48
- QMC6310_VAL_OSR2_1 = 0
- QMC6310_VAL_OSR2_2 = 64
- QMC6310_VAL_OSR2_4 = 128
- QMC6310_VAL_OSR2_8 = 192
- QMC6310_VAL_MODE_SET_RESET_ON = 0
- QMC6310_VAL_MODE_SET_ON = 1
- QMC6310_VAL_MODE_SET_RESET_OFF = 2
- RANGE = {'12G': 4, '2G': 12, '30G': 0, '8G': 8}
- LSB = {'12G': 2.5, '2G': 15, '30G': 1, '8G': 3.75}
- QMC6310_VAL_SELF_TEST_ON = 64
- QMC6310_VAL_SELF_TEST_OFF = 0
- QMC6310_VAL_SOFT_RST_ON = 128
- QMC6310_VAL_SOFT_RST_OFF = 0
- class fusion_hat.modules.magnetometer.HMC5883L(bus: smbus2.SMBus, addr: int = 30)[source]
Bases:
objectHMC5883L 3-axis magnetometer sensor driver class Used to measure Earth’s magnetic field strength, suitable for direction detection and heading angle calculation
- DEF_ADDR = 30
- REG_CONFIG_A = 0
- REG_CONFIG_B = 1
- REG_MODE = 2
- REG_OUT_X_H = 3
- class fusion_hat.modules.magnetometer.QMC5883L(bus: smbus2.SMBus, addr: int = 13)[source]
Bases:
objectQMC5883L 3-axis magnetometer sensor driver class Used to measure Earth’s magnetic field strength, is a common alternative to HMC5883L
- DEF_ADDR = 13
- REG_CONTROL = 9
- REG_SET_RESET = 11
- REG_OUT_X_L = 0
- class fusion_hat.modules.magnetometer.QMC5883P(bus: smbus2.SMBus, addr: int = 44)[source]
Bases:
objectQMC5883P 3-axis magnetometer sensor driver class Another version of the QMC5883 series with I2C address 0x2C
- DEF_ADDR = 44
- REG_X_LSB = 1
- REG_STATUS = 9
- REG_MODE = 10
- REG_CONFIG = 11
- class fusion_hat.modules.magnetometer.Magnetometer(mag_type=None, field_range='8G')[source]
Bases:
objectMagnetometer sensor driver class Integrates QMC6310, HMC5883L, QMC5883L, and QMC5883P magnetometers