如题,ch582采用libCH573_TKY.a,版本105触摸按键库,滤波模式1和 2能够正常识别触摸按键。设置成滤波模式 3 时,
BaseLine为6679,远超过4096,估算应该是正确值的2倍,请问如何调节?是否库的问题?
keyData = TKY_PollForFilterMode_3_4(); //62.5ms调用一次
串口打印的数值
TOUCH0 INIT OK!
TOUCH Version =105
INIT baseLine=3341,init GetCurQueueBaseLine=3341 (初始化值,及初始化时检测的BL值)
ch0 GetCurQueueValue=3335,GetCurQueueBaseLine=6679 (每2S刷新一次数据)
ch0 GetCurQueueValue=3335,GetCurQueueBaseLine=6675
ch0 GetCurQueueValue=3337,GetCurQueueBaseLine=6678
配置参数
------触摸按键基础设置初始化--------
TKY_BaseInitStructure.filterMode = FILTER_MODE_3;
TKY_BaseInitStructure.shieldEn = 0;
TKY_BaseInitStructure.filterGrade = 1;
TKY_BaseInitStructure.maxQueueNum = MAX_QUEUE_NUM;
TKY_BaseInitStructure.baseRefreshOnPress = 0;
//---基线更新速度,baseRefreshSampleNum和filterGrade,与基线更新速度成反比,基线更新速度还与代码结构相关,可通过函数GetCurQueueBaseLine来观察---
TKY_BaseInitStructure.baseRefreshSampleNum = 1;
TKY_BaseInitStructure.baseUpRefreshDouble = 2;
TKY_BaseInitStructure.baseDownRefreshSlow = 100;
TKY_BaseInitStructure.tkyBufP = tkyBuf;
TKY_BaseInit(TKY_BaseInitStructure);
//--------对触摸通道0进行初始化,并列为检测队列中第1位----------
GPIOA_ModeCfg(GPIO_Pin_5, GPIO_ModeIN_Floating);
TKY_ChannelInitStructure.queueNum = 0;
TKY_ChannelInitStructure.channelNum = 1;
TKY_ChannelInitStructure.threshold = 200; //---门槛阈值和PCB板相关,请根据实际情况调整---
TKY_ChannelInitStructure.threshold2 = 170;
TKY_ChannelInitStructure.chargeTime = 2; //---请根据具体电路调节,使得原始测量数据在3000~3800左右较佳---
TKY_ChannelInitStructure.disChargeTime = 2;
//----如果存在手指按着触摸按键上电的可能,可采用每隔一段时间保存基线值至掉电不丢失的存储器(eeprom、铁电等),上电读取。
//----采样下面方式进行初始化,必须加快基线更新速度或基线向上更新速度----
TKY_ChannelInitStructure.baseLine = TKY_GetCurChannelMean(TKY_ChannelInitStructure.channelNum, TKY_ChannelInitStructure.chargeTime, TKY_ChannelInitStructure.disChargeTime, 10000);
TKY_CHInit(TKY_ChannelInitStructure);