@@ -55,11 +55,7 @@ extern "C" {
5555 .benchmark = { \
5656 .filter_mode = TOUCH_BM_IIR_FILTER_4, \
5757 .jitter_step = 4, \
58- .update = { \
59- .pos_thresh = TOUCH_UPDATE_BM_POS_THRESH_1_4, \
60- .neg_thresh = TOUCH_UPDATE_BM_NEG_THRESH_1_4, \
61- .neg_limit = 5, \
62- }, \
58+ .denoise_lvl = 1, \
6359 }, \
6460 .data = { \
6561 .smooth_filter = TOUCH_SMOOTH_IIR_FILTER_2, \
@@ -115,35 +111,6 @@ typedef enum {
115111 TOUCH_BM_JITTER_FILTER , /*!< Jitter Filter for benchmark, raw value +/- jitter_step */
116112} touch_benchmark_filter_mode_t ;
117113
118- /**
119- * @brief Positive noise limitation of benchmark
120- * benchmark will only update gradually when
121- * the smooth data within the positive noise limitation
122- *
123- */
124- typedef enum {
125- TOUCH_UPDATE_BM_POS_ALWAYS = -1 , /*!< Always update benchmark when (smooth_data - benchmark) > 0 */
126- TOUCH_UPDATE_BM_POS_THRESH_1_2 = 0 , /*!< Only update benchmark when the (smooth_data - benchmark) < 1/2 * activate_threshold */
127- TOUCH_UPDATE_BM_POS_THRESH_3_8 , /*!< Only update benchmark when the (smooth_data - benchmark) < 3/8 * activate_threshold */
128- TOUCH_UPDATE_BM_POS_THRESH_1_4 , /*!< Only update benchmark when the (smooth_data - benchmark) < 1/4 * activate_threshold */
129- TOUCH_UPDATE_BM_POS_THRESH_1 , /*!< Only update benchmark when the (smooth_data - benchmark) < 1 * activate_threshold */
130- } touch_benchmark_pos_thresh_t ;
131-
132- /**
133- * @brief Negative noise limitation of benchmark
134- * benchmark will only update gradually when
135- * the smooth data within the negative noise limitation
136- *
137- */
138- typedef enum {
139- TOUCH_UPDATE_BM_NEG_NEVER = -2 , /*!< Never update benchmark when (benchmark - smooth_data) > 0 */
140- TOUCH_UPDATE_BM_NEG_ALWAYS = -1 , /*!< Always update benchmark when (benchmark - smooth_data) > 0 */
141- TOUCH_UPDATE_BM_NEG_THRESH_1_2 = 0 , /*!< Only update benchmark when the (benchmark - smooth_data) < 1/2 * activate_threshold */
142- TOUCH_UPDATE_BM_NEG_THRESH_3_8 , /*!< Only update benchmark when the (benchmark - smooth_data) < 3/8 * activate_threshold */
143- TOUCH_UPDATE_BM_NEG_THRESH_1_4 , /*!< Only update benchmark when the (benchmark - smooth_data) < 1/4 * activate_threshold */
144- TOUCH_UPDATE_BM_NEG_THRESH_1 , /*!< Only update benchmark when the (benchmark - smooth_data) < 1 * activate_threshold */
145- } touch_benchmark_neg_thresh_t ;
146-
147114/**
148115 * @brief Touch channel Infinite Impulse Response (IIR) filter for smooth data
149116 *
@@ -222,31 +189,11 @@ typedef struct {
222189 touch_benchmark_filter_mode_t filter_mode ; /*!< Benchmark filter mode. IIR filter and Jitter filter can be selected,
223190 * TOUCH_BM_IIR_FILTER_16 is recommended
224191 */
225- uint32_t jitter_step ; /*!< Jitter filter step size, only takes effect when the `filter_mode` is TOUCH_BM_JITTER_FILTER. Range: 0 ~ 15 */
226- /**
227- * @brief Benchmark update strategy
228- */
229- struct {
230- touch_benchmark_pos_thresh_t pos_thresh ; /*!< Select the positive noise threshold. Higher = More noise resistance.
231- * Range: [-1 ~ 3]. The coefficient of the positive threshold are -1: always; 0: 4/8; 1: 3/8; 2: 2/8; 3: 1;
232- * Once the data of the channel exceeded the positive threshold (i.e., benchmark + coefficient * touch threshold),
233- * the benchmark will stop updated to that value.
234- * -1: ignore the positive threshold and always update the benchmark for positive noise
235- */
236- touch_benchmark_neg_thresh_t neg_thresh ; /*!< Select the negative noise threshold. Higher = More noise resistance.
237- * Range: [-2 ~ 3]. The coefficient of the negative threshold are -2: never; -1: always; 0: 4/8; 1: 3/8; 2: 2/8; 3: 1;
238- * Once the data of the channel below the negative threshold (i.e., benchmark - coefficient * touch threshold),
239- * the benchmark will stop updated to that value,
240- * unless the data keep below the negative threshold for more than the limitation of `neg_limit`
241- * -1: ignore the negative threshold and always update the benchmark for negative noise
242- * -2: never update the benchmark for negative noise
243- */
244- uint32_t neg_limit ; /*!< Set the time limitation of the negative threshold.
245- * The benchmark will be updated to the value that below to the negative threshold after the limited time.
246- * Normally the negative update is used at the beginning, as the initial benchmark is a very large value.
247- * (the unit of `neg_limit` is the tick of the slow clock source)
192+ uint32_t jitter_step ; /*!< Jitter filter step size, only takes effect when the `filter_mode` is TOUCH_BM_JITTER_FILTER. Range: [0 ~ 15] */
193+ int denoise_lvl ; /*!< The denoise level, which determines the noise bouncing range that won't trigger benchmark update.
194+ * Range: [0 ~ 4]. The greater the denoise_lvl is, more noise resistance will be. Specially, `0` stands for no denoise
195+ * Typically, recommend to set this field to 1.
248196 */
249- } update ; /*!< The benchmark update strategy */
250197 } benchmark ; /*!< Benchmark filter */
251198 /**
252199 * @brief Data configuration
0 commit comments