日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁(yè) > 單片機(jī) > 單片機(jī)
[導(dǎo)讀]將接近檢測(cè)傳感器集成到系統(tǒng)后,一個(gè)經(jīng)常遇到的問(wèn)題是如何正確選擇接近檢測(cè)的門(mén)限,以便在用戶(hù)通話(huà)期間打開(kāi)或關(guān)閉屏幕。門(mén)限設(shè)置須確保出現(xiàn)錯(cuò)誤判斷的幾率非常低,而且能夠支持絕大多數(shù)使用者的情況。 門(mén)限滯回例程

將接近檢測(cè)傳感器集成到系統(tǒng)后,一個(gè)經(jīng)常遇到的問(wèn)題是如何正確選擇接近檢測(cè)的門(mén)限,以便在用戶(hù)通話(huà)期間打開(kāi)或關(guān)閉屏幕。門(mén)限設(shè)置須確保出現(xiàn)錯(cuò)誤判斷的幾率非常低,而且能夠支持絕大多數(shù)使用者的情況。
門(mén)限滯回例程

 

#define MAX44000_ADDR	0x94
#define INT_STATUS_REG	0x00
#define OFF_THRESHOLD	4600
#define OFF_DELAY		1
#define ON_THRESHOLD	4000
#define ON_DELAY		3

uint8 screenStatus;	// 0 means off, 1 means on

/*
  i2cWriteBytes()
  
  Arguments:
	uint8 address - device address
	uint8 start_reg - register where the first byte is written
	uint8 *data - data to write
	uint8 nbytes - number of bytes to write

  Consecutively writes several bytes to some i2c device starting at some 
  specified address -- implemented elsewhere
*/
void i2cWriteBytes(uint8 address,uint8 start_reg,uint8 *data,uint8 nbytes);

/*
  MAX44000InterruptHandler()

 

以下代碼用于實(shí)現(xiàn)MAX44000 INT引腳的中斷處理,假設(shè)MAX44000的接近檢測(cè)傳感器設(shè)置為14位模式,并已使能中斷。此外,假設(shè)屏幕狀態(tài)初始化為1或0,詳細(xì)信息請(qǐng)參閱數(shù)據(jù)資料的寄存器說(shuō)明部分。

 

*/
void MAX44000InterruptHandler() {

	uint8 i2cData[3];
	
	i2cRead1Byte(MAX44000_ADDR,INT_STATUS_REG,&i2cData);
	if (i2cData&0x01 != 0)
		return;	// check to make sure interrupt really fired
				// this simultaneously clears the interrupt flag
	
	if (screenStatus) {
		i2cData[0] = ON_DELAY;	
		i2cData[1] = ON_THRESHOLD >> 8 & 0xBF; // set ABOVE = 0
		i2cData[2] = ON_THRESHOLD & 0xFF;
	} else {
		i2cData[0] = OFF_DELAY;	 
		i2cData[1] = OFF_THRESHOLD >> 8 | 0x40; // set ABOVE = 1
		i2cData[2] = OFF_THRESHOLD & 0xFF;
	} // set the new threshold depending on what the screen status was
	
	// set the delay and threshold after each interrupt
	i2cWriteBytes(MAX44000_ADDR,0x0A,i2cData,3);
	
	return;
} // MAX44000InterruptHandler
本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專(zhuān)欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉