driver(touch): fix touch sensor driver redundancy

This commit is contained in:
fuzhibo
2020-06-22 22:10:30 +08:00
committed by bot
parent 5593eae8cd
commit 1568b6913d
16 changed files with 246 additions and 466 deletions

View File

@@ -41,8 +41,8 @@ static const touch_pad_t button[TOUCH_BUTTON_NUM] = {
/*
* Touch threshold. The threshold determines the sensitivity of the touch.
* This threshold is derived by testing changes in readings from different touch channels.
* If (raw_data - baseline) > baseline * threshold, the pad be activated.
* If (raw_data - baseline) < baseline * threshold, the pad be inactivated.
* If (raw_data - benchmark) > benchmark * threshold, the pad be activated.
* If (raw_data - benchmark) < benchmark * threshold, the pad be inactivated.
*/
static const float button_threshold[TOUCH_BUTTON_NUM] = {
0.2, // 20%.
@@ -74,8 +74,8 @@ static void tp_example_set_thresholds(void)
{
uint32_t touch_value;
for (int i = 0; i < TOUCH_BUTTON_NUM; i++) {
//read baseline value
touch_pad_filter_read_baseline(button[i], &touch_value);
//read benchmark value
touch_pad_read_benchmark(button[i], &touch_value);
//set interrupt threshold.
touch_pad_set_thresh(button[i], touch_value * button_threshold[i]);
ESP_LOGI(TAG, "touch pad [%d] base %d, thresh %d", \
@@ -89,10 +89,7 @@ static void touchsensor_filter_set(touch_filter_mode_t mode)
touch_filter_config_t filter_info = {
.mode = mode, // Test jitter and filter 1/4.
.debounce_cnt = 1, // 1 time count.
.hysteresis_thr = 3, // 3%
.noise_thr = 0, // 50%
.noise_neg_thr = 0, // 50%
.neg_noise_limit = 10, // 10 time count.
.jitter_step = 4, // use for jitter mode.
.smh_lvl = TOUCH_PAD_SMOOTH_IIR_2,
};