src/ModMMA8452Q.cpp
byte MMA8452Q::begin(MMA8452Q_Scale fsr, MMA8452Q_ODR odr)
{
	scale = fsr; // Haul fsr into our class variable, scale

	Wire.begin(); // Initialize I2C

	byte c = readRegister(WHO_AM_I);  // Read WHO_AM_I register

	if (c != 0x2A) // WHO_AM_I should always be 0x2A
	{
		return 0;
	}

	standby();  // Must be in standby to change registers

	setScale(scale);  // Set up accelerometer scale
	setODR(odr);  // Set up output data rate
	setupPL();  // Set up portrait/landscape detection
	// Multiply parameter by 0.0625g to calculate threshold.
	//setupTap(0x02, 0x02, 0x02); // Disable x, y, set z to 0.5g

	active();  // Set to active to start reading

	return 1;
}
// INITIALIZATION
//	This function initializes the MMA8452Q. It sets up the scale (either 2, 4,
//	or 8g), output data rate, portrait/landscape detection and tap detection.
//	It also checks the WHO_AM_I register to make sure we can communicate with
//	the sensor. Returns a 0 if communication failed, 1 if successful.
INITIALIZATION
This function initializes the MMA8452Q. It sets up the scale (either 2, 4,
or 8g), output data rate, portrait/landscape detection and tap detection.
It also checks the WHO_AM_I register to make sure we can communicate with
the sensor. Returns a 0 if communication failed, 1 if successful.
INITIALIZATION This function initializes the MMA8452Q . It sets up the scale ( either 2 4 or 8g ) output data rate portrait / landscape detection and tap detection . It also checks the WHO_AM_I register to make sure we can communicate with the sensor . Returns a 0 if communication failed 1 if successful .
byte MMA8452Q::begin(MMA8452Q_Scale fsr, MMA8452Q_ODR odr)
{
	scale = fsr; 
	Wire.begin(); 
	byte c = readRegister(WHO_AM_I);  
	if (c != 0x2A) 
	{
		return 0;
	}
	standby();  
	setScale(scale);  
	setODR(odr);  
	setupPL();  
	active();  
	return 1;
}
byte MMA8452Q :: begin ( MMA8452Q_Scale fsr , MMA8452Q_ODR odr ) { scale = fsr ; Wire . begin ( ) ; byte c = readRegister ( WHO_AM_I ) ; if ( c != 0x2A ) { return 0 ; } standby ( ) ; setScale ( scale ) ; setODR ( odr ) ; setupPL ( ) ; active ( ) ; return 1 ; }
INITIALIZATION
This function initializes the MMA8452Q.
INITIALIZATION This function initializes the MMA8452Q .
// Haul fsr into our class variable, scale // Initialize I2C // Read WHO_AM_I register // WHO_AM_I should always be 0x2A // Must be in standby to change registers // Set up accelerometer scale // Set up output data rate // Set up portrait/landscape detection // Multiply parameter by 0.0625g to calculate threshold. //setupTap(0x02, 0x02, 0x02); // Disable x, y, set z to 0.5g // Set to active to start reading