The ATMEL QTouch Library API provides a function pointer called “qt_filter_callback”. The user can use this hook to apply filter functions to the measured signal values.
If the pointer is non-NULL, the library calls the function after library has made capacitive channel measurements, but before the library has processed the channel information and determining the sensor states.

/* 1. Add a static variable in the main module: */
/* filter for channel signals */
static uint16_t filter[QT_NUM_CHANNELS][4];
/* 2. Add a filter function prototype to the main module: */
/* example signal filtering function */
static void filter_data_mean_4( void );
/* 3. When configuring the ATMEL QTouch library, set the
callback function pointer: */
/* set callback function */
qt_filter_callback = filter_data_mean_4;
/* 4. Add the filter function: */
void filter_data_mean_4( void )
{
uint8_t i;
/*
* Shift previously stored channel signal data.
* Store new channel signal data.
* Set library channel signal data = mean of last 4 values.
*/
for( i = 0u; i < QT_NUM_CHANNELS; i++ )
{
filter[i][0] = filter[i][1];
filter[i][1] = filter[i][2];
filter[i][2] = filter[i][3];
filter[i][3] = qt_measure_data.channel_signals[i];
qt_measure_data.channel_signals[i] = (filter[i][0] +
filter[i][1] +
filter[i][2] +
filter[i][3]) / 4u;
}
}
The signal values processed by the ATMEL QTouch Library are now the mean of the last four actual signal values.