? ? 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,與基線更新速度成反比,基線更新速度還與代碼結構相關,可通過函數(shù)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板相關,請根據(jù)實際情況調整---
? ? TKY_ChannelInitStructure.threshold2 = 170;
? ? TKY_ChannelInitStructure.chargeTime = 15; //---請根據(jù)具體電路調節(jié),使得原始測量數(shù)據(jù)在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();