touchpad3 2.0.0.0
Main Page

Touchpad 3 click

Touchpad 3 Click is a compact add-on board that allows users to easily integrate projected capacitive touch into their applications. This board features the MTCH6301, a turnkey capacitive touch controller that makes it easy for users to use popular multitouch and gesture interfaces from Microchip. This controller’s sophisticated combination of Self and Mutual capacitive scanning for XY touchscreens and touchpads enables several features, including single and dual-touch drawing, the reporting of 11 single-finger gestures, and the detection of up to 10 touches. This Click board™ is suitable for human-machine interfaces, keypad or scrolling functions, single-finger gesture-based interfaces, and more.

click Product page


Click library

  • Author : Jelena Milosavljevic
  • Date : Jul 2021.
  • Type : I2C type

Software Support

We provide a library for the Touchpad3 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

‍This library contains API for Touchpad3 Click driver.

Standard key functions :

Example key functions :

Example Description

‍This example prints the coordinate points of the position we touch on a click. We use RST and INT pins. The whole project is done through i2c communication.

The demo application is composed of two sections :

Application Init

‍Initialization driver enables - Initializes I2C, set RST pin as an output, set INT pin as input and start to write log. I2C, perform a hardware reset, configuration (general, decoding, sensor mapping), get device ID and enable the touch, also write log.

void application_init ( void ) {
log_cfg_t log_cfg;
touchpad3_cfg_t touchpad3_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
touchpad3_cfg_setup( &touchpad3_cfg );
TOUCHPAD3_MAP_MIKROBUS( touchpad3_cfg, MIKROBUS_1 );
err_t init_flag = touchpad3_init( &touchpad3, &touchpad3_cfg );
if ( I2C_MASTER_ERROR == init_flag ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
touchpad3_default_cfg ( &touchpad3 );
log_printf( &logger, "------------------------------\r\n" );
Delay_ms ( 100 );
log_printf( &logger, " Get Device ID : %d \r\n ", device_id );
log_printf( &logger, "------------------------------\r\n" );
Delay_ms ( 100 );
log_info( &logger, " Application Task " );
Delay_ms ( 100 );
log_printf( &logger, " Touch Enable Status: \r\n");
log_printf( &logger, "------------------------------\r\n" );
Delay_ms ( 100 );
}
#define TOUCHPAD3_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition touchpad3.h:412
#define TOUCHPAD3_TOUCH_GESTURE_ENABLE
Definition touchpad3.h:328
uint32_t touchpad3_get_device_id(touchpad3_t *ctx)
Touchpad 3 get device id function.
uint8_t touchpad3_config_touch(touchpad3_t *ctx, uint8_t en_touch)
Touchpad 3 configure touch function.
uint8_t touch_id_state
Definition main.c:29
void application_init(void)
Definition main.c:76
uint32_t device_id
Definition main.c:33
void display_status(void)
Definition main.c:36
uint8_t status_data
Definition main.c:30

Application Task

‍This is an example that demonstrates the use of the TouchPad 3 click board. TouchPad 3 click board uses USB UART log to display X and Y coordinates of the touch, depending on the selected Touch ID.

void application_task ( void ) {
if ( touchpad3_get_int( &touchpad3 ) == TOUCHPAD3_INT_STATUS_HIGH ) {
Delay_ms ( 100 );
log_printf( &logger, " X Coordinate : %d \r\n" , x_axis );
log_printf( &logger, " Y Coordinate : %d \r\n" , y_axis );
log_printf( &logger, "------------------------------\r\n" );
Delay_ms ( 100 );
}
}
}
#define TOUCHPAD3_INT_STATUS_HIGH
Definition touchpad3.h:371
#define TOUCHPAD3_STATE_TCH
Touchpad 3 Touch or Gesture state.
Definition touchpad3.h:384
uint8_t touchpad3_get_touch(touchpad3_t *ctx, touch_data_t *tch_data, uint16_t *x_axis, uint16_t *y_axis)
Touchpad 3 get touch data function.
uint8_t touchpad3_get_int(touchpad3_t *ctx)
Touchpad 3 get interrupt function..
uint16_t x_axis
Definition main.c:31
void application_task(void)
Definition main.c:124
uint16_t y_axis
Definition main.c:32
touch_data_t touch_data
Definition main.c:34
uint8_t tch_state
Definition touchpad3.h:461
uint8_t touch_id
Definition touchpad3.h:460

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Touchpad3

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. UART terminal is available in all MikroElektronika compilers.