src/ModMMA8452Q.cpp
void MMA8452Q::setupTap(byte xThs, byte yThs, byte zThs, byte timeLimit, byte latency, byte window)
{
    standby();
	// Set up single, for more info check out this app note:
	// http://cache.freescale.com/files/sensors/doc/app_note/AN4072.pdf
	// Set the threshold - minimum required acceleration to cause a tap.
	byte temp = 0;
	if (!(xThs & 0x80)) // If top bit ISN'T set
	{
		//temp |= 0x3; // Enable taps on x
		temp |= 0x1; // Enable single-tap on x
		writeRegister(PULSE_THSX, xThs);  // x thresh
	}
	if (!(yThs & 0x80))
	{
		//temp |= 0xC; // Enable taps on y
		temp |= 0x4; // Enable single-tap on y
		writeRegister(PULSE_THSY, yThs);  // y thresh
	}
	if (!(zThs & 0x80))
	{
	    //temp |= 0x30; // Enable taps on z
	    temp |= 0x10; // Enable single-tap on z
		writeRegister(PULSE_THSZ, zThs);  // z thresh
	}
	// Set up single and/or double tap detection on each axis individually.
	writeRegister(PULSE_CFG, temp | 0x40);
	// Set the time limit - the maximum time that a tap can be above the thresh
	//writeRegister(PULSE_TMLT, 0x30);  // 30ms time limit at 800Hz odr
	writeRegister(PULSE_TMLT, timeLimit);  // 30ms time limit at 800Hz odr
	// Set the pulse latency - the minimum required time between pulses
	writeRegister(PULSE_LTCY, latency);  // 200ms (at 800Hz odr) between taps min
	//writeRegister(PULSE_LTCY, 0x40);  // 200ms (at 800Hz odr) between taps min
	// Set the second pulse window - maximum allowed time between end of
	//	latency and start of second pulse
	writeRegister(PULSE_WIND, window);  // 5. 318ms (max value) between taps max

	active();
}
// SET UP TAP DETECTION
//	This function can set up tap detection on the x, y, and/or z axes.
//	The xThs, yThs, and zThs parameters serve two functions:
//		1. Enable tap detection on an axis. If the 7th bit is SET (0x80)
//			tap detection on that axis will be DISABLED.
//		2. Set tap g's threshold. The lower 7 bits will set the tap threshold
//			on that axis.
SET UP TAP DETECTION
This function can set up tap detection on the x, y, and/or z axes.
The xThs, yThs, and zThs parameters serve two functions:
1. Enable tap detection on an axis. If the 7th bit is SET (0x80)
tap detection on that axis will be DISABLED.
2. Set tap g's threshold. The lower 7 bits will set the tap threshold
on that axis.
SET UP TAP DETECTION This function can set up tap detection on the x y and / or z axes . The xThs yThs and zThs parameters serve two functions : 1 . Enable tap detection on an axis . If the 7th bit is SET ( 0x80 ) tap detection on that axis will be DISABLED . 2 . Set tap g ' s threshold . The lower 7 bits will set the tap threshold on that axis .
void MMA8452Q::setupTap(byte xThs, byte yThs, byte zThs, byte timeLimit, byte latency, byte window)
{
    standby();
	byte temp = 0;
	if (!(xThs & 0x80)) 
	{
		temp |= 0x1; 
		writeRegister(PULSE_THSX, xThs);  
	}
	if (!(yThs & 0x80))
	{
		temp |= 0x4; 
		writeRegister(PULSE_THSY, yThs);  
	}
	if (!(zThs & 0x80))
	{
	    temp |= 0x10; 
		writeRegister(PULSE_THSZ, zThs);  
	}
	writeRegister(PULSE_CFG, temp | 0x40);
	writeRegister(PULSE_TMLT, timeLimit);  
	writeRegister(PULSE_LTCY, latency);  
	//writeRegister(PULSE_LTCY, 0x40);  
	writeRegister(PULSE_WIND, window);  
	active();
}
void MMA8452Q :: setupTap ( byte xThs , byte yThs , byte zThs , byte timeLimit , byte latency , byte window ) { standby ( ) ; byte temp = 0 ; if ( ! ( xThs & 0x80 ) ) { temp |= 0x1 ; writeRegister ( PULSE_THSX , xThs ) ; } if ( ! ( yThs & 0x80 ) ) { temp |= 0x4 ; writeRegister ( PULSE_THSY , yThs ) ; } if ( ! ( zThs & 0x80 ) ) { temp |= 0x10 ; writeRegister ( PULSE_THSZ , zThs ) ; } writeRegister ( PULSE_CFG , temp | 0x40 ) ; writeRegister ( PULSE_TMLT , timeLimit ) ; writeRegister ( PULSE_LTCY , latency ) ; writeRegister ( PULSE_WIND , window ) ; active ( ) ; }
SET UP TAP DETECTION
This function can set up tap detection on the x, y, and/or z axes.
SET UP TAP DETECTION This function can set up tap detection on the x y and / or z axes .
// Set up single, for more info check out this app note: // http://cache.freescale.com/files/sensors/doc/app_note/AN4072.pdf // Set the threshold - minimum required acceleration to cause a tap. // If top bit ISN'T set //temp |= 0x3; // Enable taps on x // Enable single-tap on x // x thresh //temp |= 0xC; // Enable taps on y // Enable single-tap on y // y thresh //temp |= 0x30; // Enable taps on z // Enable single-tap on z // z thresh // Set up single and/or double tap detection on each axis individually. // Set the time limit - the maximum time that a tap can be above the thresh //writeRegister(PULSE_TMLT, 0x30);  // 30ms time limit at 800Hz odr // 30ms time limit at 800Hz odr // Set the pulse latency - the minimum required time between pulses // 200ms (at 800Hz odr) between taps min //writeRegister(PULSE_LTCY, 0x40);  // 200ms (at 800Hz odr) between taps min // Set the second pulse window - maximum allowed time between end of //	latency and start of second pulse // 5. 318ms (max value) between taps max