Atmel QTouch Library User Guide
Atmel QTouch Library User Guide Atmel QTouch Library User Guide
channel 0channel 1channel 2channel 3channel 4channel 5channel 6channel 7QTouch/QMatrix Channel Acquisition Methodchannel_signals[]optional qt_filter_callback() functionpost-processingmodified channel_signals[]modified channel_signals[]qt_touch_status.sensor_states[]qt_touch_status_rotor_slider_values[]Figure 5-10 : Block diagram to represent usage of filter callback functionExample: Averaging the Last Four Signal Values1. 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];448207K-AT42-09/11
}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 fouractual signal values.Allocating unused Port Pins for User ApplicationThe GPIO pins within a port that are not used for QTouch or QMatrix acquisition methods can beused for user application. The usage of pins for QTouch is based on the channels that are beingconfigured while enabling the sensors (keys/rotors/sliders).The example below configuring 4 keys, a rotor and a slider shows how the pin configurability isachieved by configuring the sensor channels. The code snippet configures a specific 10 channelsof a 16 channel library based on the GPIO port pins available for QTouch.Port Configuration:#define SNSK1#define SNS1#define SNSK2#define SNS2CDABChannel/Pin Configuration:/* enable a key on channel 0 */qt_enable_key( CHANNEL_0, AKS_GROUP_2, 10u, HYST_6_25 );/* enable a slider on channels 2 to 4 */qt_enable_slider( CHANNEL_2, CHANNEL_4, AKS_GROUP_1, 16u, HYST_6_25,RES_8_BIT, 0u );/* enable a key on channel 6 */qt_enable_key( CHANNEL_6, AKS_GROUP_2, 10u, HYST_6_25 );/* enable a key on channel 7 */qt_enable_key( CHANNEL_7, AKS_GROUP_2, 10u, HYST_6_25 );/* enable a rotor on channels 12 to14 */qt_enable_rotor( CHANNEL_12, CHANNEL_14, AKS_GROUP_1, 16u,HYST_6_25, RES_8_BIT, 0u );/* enable a key on channel 15 */qt_enable_key( CHANNEL_15, AKS_GROUP_2, 10u, HYST_6_25 );The channel numbers 0,2,3,4,6,7 are allocated to pins 0,2,3,4,6,7 of (D,C) port pair respectively.Pins 1 and 5 of ports C and D can be used for user application. Similarly the channel numbers12,13,14,15 are allocated to pins 4,5,6,7 of (B,A) port pair respectively. Pins 1, 2, 3 and 4 of portsB and A are again unused by the QTouch library and can be used for user application.45
- Page 1: Atmel QTouch LibraryUser GuideSuppo
- Page 4: 5.6.11.6.1 Debug Support in the sam
- Page 7 and 8: 6.3.16.21 touch_info_t ............
- Page 12 and 13: • ARM: refers to a device in the
- Page 14 and 15: Libraries for AVR microcontrollers
- Page 16 and 17: QMatrix charge transfer is labeled
- Page 18 and 19: Maximum ON DurationIf an object uni
- Page 20 and 21: Setting Variable name Data Type Uni
- Page 22 and 23: Guard ChannelGuard channel in Qtouc
- Page 24 and 25: 7 AKS groups are supported by the l
- Page 26 and 27: Data structuresThis section lists t
- Page 28 and 29: The signal gain for each sensor is
- Page 30 and 31: • This function can be called any
- Page 32 and 33: unit16_t qt_measure_sensors( uint16
- Page 34 and 35: Channel NumberingChannel numbering
- Page 36 and 37: qt_reset_sensing()qt_enable_xxx()qt
- Page 38 and 39: Port AAll SNSK pinsterminatedon thi
- Page 40 and 41: Example:Pins A0 ,A3 and A5 of PORT
- Page 42 and 43: Channel 47 N/A N/A N/A N/A N/A X7Y5
- Page 46 and 47: Disabling and Enabling of Pull-up f
- Page 48 and 49: ‣ Recommended threshold should be
- Page 50 and 51: QMatrix acquisitionmethod libraries
- Page 52 and 53: definition is not required.QT_NUM_C
- Page 54 and 55: SNS1 and SNSK1 pins usethe same por
- Page 56 and 57: • It is recommended to disable PU
- Page 58 and 59: Table 4 :List of configurable param
- Page 60 and 61: Number ofchannels requiredfor the a
- Page 62 and 63: 2. The above definitions should be
- Page 64 and 65: NUM_Y_LINES_ROTOR_SLIDER_QT_MAX_NUM
- Page 66 and 67: has Four Comparators (AC0A , AC1A ,
- Page 68 and 69: Note: When using the IAR IDE / comp
- Page 70 and 71: Figure 5-11: Selecting the right co
- Page 72 and 73: SNS1 - SNSK1 & SNS2 -SNSK2QT_NUM_CH
- Page 74 and 75: Selecting the right configurationTh
- Page 76 and 77: Figure 5-20 : Specifying QMatrix ac
- Page 78 and 79: Debug Support in Example applicatio
- Page 80 and 81: Support for different compiler tool
- Page 82 and 83: Maximum number of rotor / sliders s
- Page 84 and 85: Tips on pin assignments for the sen
- Page 86 and 87: ATtiny88)v1g1s2(ATtiny461,ATmega16a
- Page 88 and 89: X0,X1,X2,X3 are on PB0,PB1,PB2,PB3N
- Page 90 and 91: 1. The channel numbers are allocate
- Page 92 and 93: SNSK_array[1][1]=0x00; (SNSK odd ma
}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 <strong>QTouch</strong> <strong>Library</strong> are now the mean of the last fouractual signal values.Allocating unused Port Pins for <strong>User</strong> ApplicationThe GPIO pins within a port that are not used for <strong>QTouch</strong> or QMatrix acquisition methods can beused for user application. The usage of pins for <strong>QTouch</strong> is based on the channels that are beingconfigured while enabling the sensors (keys/rotors/sliders).The example below configuring 4 keys, a rotor and a slider shows how the pin configurability isachieved by configuring the sensor channels. The code snippet configures a specific 10 channelsof a 16 channel library based on the GPIO port pins available for <strong>QTouch</strong>.Port Configuration:#define SNSK1#define SNS1#define SNSK2#define SNS2CDABChannel/Pin Configuration:/* enable a key on channel 0 */qt_enable_key( CHANNEL_0, AKS_GROUP_2, 10u, HYST_6_25 );/* enable a slider on channels 2 to 4 */qt_enable_slider( CHANNEL_2, CHANNEL_4, AKS_GROUP_1, 16u, HYST_6_25,RES_8_BIT, 0u );/* enable a key on channel 6 */qt_enable_key( CHANNEL_6, AKS_GROUP_2, 10u, HYST_6_25 );/* enable a key on channel 7 */qt_enable_key( CHANNEL_7, AKS_GROUP_2, 10u, HYST_6_25 );/* enable a rotor on channels 12 to14 */qt_enable_rotor( CHANNEL_12, CHANNEL_14, AKS_GROUP_1, 16u,HYST_6_25, RES_8_BIT, 0u );/* enable a key on channel 15 */qt_enable_key( CHANNEL_15, AKS_GROUP_2, 10u, HYST_6_25 );The channel numbers 0,2,3,4,6,7 are allocated to pins 0,2,3,4,6,7 of (D,C) port pair respectively.Pins 1 and 5 of ports C and D can be used for user application. Similarly the channel numbers12,13,14,15 are allocated to pins 4,5,6,7 of (B,A) port pair respectively. Pins 1, 2, 3 and 4 of portsB and A are again unused by the <strong>QTouch</strong> library and can be used for user application.45