Debounce settings
In order to improve the robustness of the application, the STMTouch driver provides the debounce feature. To validate a touch detection, the delta must exceed the threshold during a certain number of consecutive samples as shown in the figure below. This is to avoid a false-detection due to a noise peak.

Due to the use of a down-counter, the DEBOUNCE preprocessor constant must be set to n-1 while n consecutive sample must be measured below the detection threshold before triggering a detection (see the code below).
#define TSLPRM_DEBOUNCE_DETECT (2) //3 consecutive samples needed to enter in Detection.
The debounce feature is configurable for each state transition listed below:
- TSLPRM_DEBOUNCE_PROX: while switching from release state to proximity state
- TSLPRM_DEBOUNCE_DETECT: while switching from release state or proximity to touch detection state
- TSLPRM_DEBOUNCE_RELEASE: while switching from touch or proximity state to release state
- TSLPRM_DEBOUNCE_CALIB: while switching from release state to calibration state (compute again the reference)
- TSLPRM_DEBOUNCE_ERROR: while switching from any state to error state





