电容触摸传感的理论框架
if (INDEX == 3) {
// 如果扫描结束,则执行以下操作
if (PctArray[0] > PCT_ON) {
// (受影响程度最高的百分比是否大于PCT_ON值?.. 是)
// 按钮被按下
switch(IndxArray[0]) {
case 0: Buttons.BTN0 = 1; // 设置按键的标志
Buttons.BTN1 = 0;
Buttons.BTN2 = 0;
Buttons.BTN3 = 0;
break;
case 1: Buttons.BTN0 = 0;
Buttons.BTN1 = 1;
Buttons.BTN2 = 0;
Buttons.BTN3 = 0;
break;
case 2: Buttons.BTN0 = 0;
Buttons.BTN1 = 0;
Buttons.BTN2 = 1;
Buttons.BTN3 = 0;
break;
case 3: Buttons.BTN0 = 0;
Buttons.BTN1 = 0;
Buttons.BTN2 = 0;
Buttons.BTN3 = 1;
break;
default: break;
}
} else if (PctArray[0] < PCT_OFF) {
// 受影响程度最高的按钮是否高于开路时的程度?
// .. 释放所有按钮。
Buttons.BTN0 = 0;
Buttons.BTN1 = 0;
Buttons.BTN2 = 0;
Buttons.BTN3 = 0;
}
} // 结束:if (INDEX == 3){ , 仅限于完整的扫描
评论