//public
	//constructor
	InterruptSensor::InterruptSensor(const __FlashStringHelper *name, byte pin, bool iState, bool pullup, long numReqCounts) :
		Sensor(name),
		m_bInterruptState(iState),
		m_bStatus(false),
		m_bPullup(pullup),
		m_bInitRequired(true),
		m_nRequiredCounts(numReqCounts),
		m_nCurrentUpCount(0),
		m_nCurrentDownCount(numReqCounts)
		{
			setInterruptPin(pin);
		}
Example #2
0
void MPR121_t::applySettings(MPR121_settings_t *settings){
	bool wasRunning = running;
	if(wasRunning) stop();  // can't change most regs when running - checking 
							// here avoids multiple stop() / run() calls

	setRegister(MHDR,settings->MHDR);
	setRegister(NHDR,settings->NHDR);
	setRegister(NCLR,settings->NCLR);
	setRegister(FDLR,settings->FDLR);
	setRegister(MHDF,settings->MHDF);
	setRegister(NHDF,settings->NHDF);
	setRegister(NCLF,settings->NCLF);
	setRegister(FDLF,settings->FDLF);
	setRegister(NHDT,settings->NHDT);
	setRegister(NCLT,settings->NCLT);
	setRegister(FDLT,settings->FDLT);
	setRegister(MHDPROXR,settings->MHDPROXR);
	setRegister(NHDPROXR,settings->NHDPROXR);
	setRegister(NCLPROXR,settings->NCLPROXR);
	setRegister(FDLPROXR,settings->FDLPROXR);
	setRegister(MHDPROXF,settings->MHDPROXF);
	setRegister(NHDPROXF,settings->NHDPROXF);
	setRegister(NCLPROXF,settings->NCLPROXF);
	setRegister(FDLPROXF,settings->FDLPROXF);
	setRegister(NHDPROXT,settings->NHDPROXT);
	setRegister(NCLPROXT,settings->NCLPROXT);
	setRegister(FDLPROXT,settings->FDLPROXT);
  	setRegister(DTR, settings->DTR);
	setRegister(AFE1, settings->AFE1);  
	setRegister(AFE2, settings->AFE2);
	setRegister(ACCR0, settings->ACCR0);
	setRegister(ACCR1, settings->ACCR1);
	setRegister(USL, settings->USL); 
	setRegister(LSL, settings->LSL); 
	setRegister(TL, settings->TL); 
	
	setRegister(ECR, settings->ECR);	
	
	error &= ~(1<<NOT_INITED_BIT); // clear not inited error as we have just inited!
	setTouchThreshold(settings->TTHRESH);
	setReleaseThreshold(settings->RTHRESH);
	setInterruptPin(settings->INTERRUPT);	
	
	if(wasRunning) run();	
}
Example #3
0
/******************************** MPU6050 Functions ********************************/
void initializeIMU()
{

	//Init Interrupt Output Pin
	P1REN |= BIT4;
	P1OUT |= BIT4;
	P1IFG &= ~BIT4;                           // P1.4 IFG cleared
	P1IE |= BIT4;                             // P1.4 interrupt enabled

	P4SEL |= BIT1 + BIT2;					  // P4.1 & P4.2 SDA/SCL Select

	// Delays do not need to be this long. Delays are present to keep I2C line clear.
	// This functions can be altered by the user. Check MPU6050.h file by Jeff Rowberg to determine the sensitivty variables.
	setClockSource(MPU6050_CLOCK_PLL_XGYRO);	// Set MPU6050 clock
	msDelay(100);
	setFullScaleGyroRange(MPU6050_GYRO_FS_2000);	// Gyroscope sensitivity set to 2000 degrees/sec
	msDelay(100);
	setFullScaleAccelRange(MPU6050_ACCEL_FS_4);	// Accelerometer sensitivity set to 4g
	msDelay(100);
	setDLPFConfig(MPU6050_DLPF_BW_5);		// Digital Low Pass Filter Configuration
	setInterruptPin();
	setSleepEnabled(0);	// Wake up device.
	msDelay(100);
}