TKY_BaseInitTypeDef TKY_BaseInitStructure;
TKY_ChannelInitTypeDef TKY_ChannelInitStructure;
//----------触摸按键基础设置初始化--------
TKY_BaseInitStructure.filterMode = FILTER_MODE_1;
TKY_BaseInitStructure.singlePressMod = 0;
TKY_BaseInitStructure.shieldEn = 1;
TKY_BaseInitStructure.filterGrade = 5;
TKY_BaseInitStructure.maxQueueNum = MAX_QUEUE_NUM;
TKY_BaseInitStructure.baseRefreshOnPress = 1;
//---基线更新速度,baseRefreshSampleNum和filterGrade,与基线更新速度成反比,基线更新速度还与代码结构相关,可通过函数GetCurQueueBaseLine来观察---
TKY_BaseInitStructure.baseRefreshSampleNum = 1000;
TKY_BaseInitStructure.baseUpRefreshDouble = 0;
TKY_BaseInitStructure.baseDownRefreshSlow = 100;
TKY_BaseInitStructure.tkyBufP = tkyBuf;
TKY_BaseInit(TKY_BaseInitStructure);
//--------对触摸通道1进行初始化,并列为检测队列中第1位----------
GPIOA_ModeCfg(TOUCH_KEY_PIN, GPIO_ModeIN_Floating);
TKY_ChannelInitStructure.queueNum = 0;
TKY_ChannelInitStructure.channelNum = 11;
TKY_ChannelInitStructure.threshold = 200; //---门槛阈值和PCB板相关,请根据实际情况调整---
TKY_ChannelInitStructure.threshold2 = 170;
TKY_ChannelInitStructure.chargeTime = 15; //---请根据具体电路调节,使得原始测量数据在3000~3800左右较佳---
TKY_ChannelInitStructure.disChargeTime = 5;
//----如果存在手指按着触摸按键上电的可能,可采用每隔一段时间保存基线值至掉电不丢失的存储器(eeprom、铁电等),上电读取。
//----采样下面方式进行初始化,必须加快基线更新速度或基线向上更新速度----
TKY_ChannelInitStructure.baseLine = TKY_GetCurChannelMean(TKY_ChannelInitStructure.channelNum, TKY_ChannelInitStructure.chargeTime, TKY_ChannelInitStructure.disChargeTime, 10000);
TKY_CHInit(TKY_ChannelInitStructure);
TKY_PollForFilterMode_1();