This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
在TI的官方库中ctsStatusReg 这个寄存器的DOI位是这样定义的:DOI Bit 1 Direction of interest:
0: Increasing capacitance //这个位为0表示感兴趣的方向是电容增加
1: Decreasing capacitance //这个位为1表示感兴趣的方向是电容减小
但是库中有这么一个函数,感到纳闷:
void TI_CAPT_Update_Tracking_DOI(uint8_t direction)
{
if(direction)
{
ctsStatusReg |= DOI_INC; //direction of interest is an increase in capacitance.
}
else
{
ctsStatusReg &= ~DOI_INC; //direction of interest is a decrease in capacitance.
}
}
Inputs: The direction of interest.
Outputs: None.
Function: If the input is true (non-zero), then the direction of interest is an increase in capacitance. If the
input is 0x00, then the direction of interest is a decrease in capacitance.
首先你可以在library里看到这么一个定义,uint16_t ctsStatusReg = (DOI_INC+TRADOI_FAST+TRIDOI_SLOW); 也就是初始时候定义了,电容的变化方向是增大的,为什么是增大呢?其实当我们的手靠近电容按键时,会耦合一部分电容到里面,从振荡数据上也可以看到,在一样的时间里,振荡次数会减少。这也是触摸按键最基本的原理。那么为什么定义一个TI_CAPT_Update_Tracking_DOI函数,我的理解是,大多数情况下,我们是手触摸电容按键,但也有一种情况是,我们手指全贴在电容按键上时,检测那个手指移开了。或者类似这种的情形。那么这个时候电容值的变化是减小,那么就需要改变算法的状态。这时候就是 DOI_INC / ~DOI_INC决定的。