Ejemplo n.º 1
0
Compass::~Compass() throw()
{
    try
    {
        setMeasurementMode(MEASUREMENT_IDLE);
    }
    catch(...)
    {
    }
}
Ejemplo n.º 2
0
bool HMC5883L::init(int* _fd )
{
	fd = _fd;
	
	if(!setScale(1.3f)) {
		printf("ERROR in init of %s. setScale returns false\n", deviceName );
		return false;
	}
	
	if(!setMeasurementMode(HMC5883L_MEASUREMENT_CONTINUOUS)) {
		printf("ERROR in init of %s. setMeasurement returns false\n", deviceName );
		return false;
	}
	      
	return true;
}
bool grove_compass_write_setup(I2C_T *i2c)
{
	uint8_t regValue = 0x00;
	
	//setScale(i2c, (float)1.3); // Set the scale of the compass.
	regValue = 0x01;
	m_Scale = 0.92;
	// Setting is in the top 3 bits of the register.
	regValue = regValue << 5;
	//write(CONFIGURATION_REGISTERB, regValue);
	cmdbuf[0] = CONFIGURATION_REGISTERB;
	cmdbuf[1] = regValue;
	suli_i2c_write(i2c, HMC5883L_ADDRESS, cmdbuf, 2);
	setMeasurementMode(i2c, MEASUREMENT_CONTINUOUS); // Set the measurement mode to Continuous
	
    return true;
}
Ejemplo n.º 4
0
bool HMC5883L::begin()
{
    Wire.begin();

    if ((fastRegister8(HMC5883L_REG_IDENT_A) != 0x48)
    || (fastRegister8(HMC5883L_REG_IDENT_B) != 0x34)
    || (fastRegister8(HMC5883L_REG_IDENT_C) != 0x33))
    {
	return false;
    }

    setRange(HMC5883L_RANGE_1_3GA);
    setMeasurementMode(HMC5883L_CONTINOUS);
    setDataRate(HMC5883L_DATARATE_15HZ);
    setSamples(HMC5883L_SAMPLES_1);

    mgPerDigit = 0.92f;

    return true;
}