Touchpad 5 click
Touchpad 5 Click is a compact add-on board that easily integrates projected capacitive touch into user's applications. This board features the IQS550, a projected capacitive touch and proximity trackpad/touchscreen controller from Azoteq.
click Product page
Click library
- Author : Stefan Popovic
- Date : Apr 2022.
- Type : I2C type
Software Support
We provide a library for the Touchpad 5 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 Touchpad 5 Click driver.
Standard key functions :
touchpad5_cfg_setup
Config Object Initialization function.
void touchpad5_cfg_setup(touchpad5_cfg_t *cfg)
Touchpad 5 configuration object setup function.
Touchpad 5 Click configuration object.
Definition touchpad5.h:371
touchpad5_init
Initialization function.
err_t touchpad5_init(touchpad5_t *ctx, touchpad5_cfg_t *cfg)
Touchpad 5 initialization function.
Touchpad 5 Click context object.
Definition touchpad5.h:351
touchpad5_default_cfg
Click Default Configuration function.
err_t touchpad5_default_cfg(touchpad5_t *ctx)
Touchpad 5 default configuration function.
Example key functions :
touchpad5_get_touch
This function get touch XY data.
err_t touchpad5_get_touch(touchpad5_t *ctx, touchpad5_touch_t *touch_data)
TouchPad 5 get touch function.
TouchPad 5 XY data object.
Definition touchpad5.h:401
touchpad5_get_status
This function get status proximity, touch or snap data.
err_t touchpad5_get_status(touchpad5_t *ctx, uint8_t sel_status, uint16_t *rx_data, uint8_t num_of_samples)
TouchPad 5 get status function.
touchpad5_wait_ready
This function waits for the communication window to be available.
void touchpad5_wait_ready(touchpad5_t *ctx)
TouchPad 5 wait ready function.
Example Description
This example demonstrates the use of Touchpad 5 click board by utilizing the touchpad XY and snap functionalities.
The demo application is composed of two sections :
Application Init
Initializes the driver and USB UART logging and displays the device version information such as product number, project number, major/minor release number, hardware ID, hardware revision and bootloader status.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR ==
touchpad5_init( &touchpad5, &touchpad5_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
Delay_100ms();
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
Delay_1sec( );
{
log_error( &logger, " Cannot read version.\r\n " );
for ( ; ; );
}
Delay_100ms();
{
log_error( &logger, " Cannot read bootloader status.\r\n " );
for ( ; ; );
}
Delay_100ms();
{
log_error( &logger, " Incorrect product number.\r\n " );
for ( ; ; );
}
log_printf( &logger, "----------------------------------------------------------------\r\n" );
log_printf( &logger, " Product number %u \r\n", ( uint32_t ) ver_info.product_num );
log_printf( &logger, " Project number %u \r\n", ( uint32_t ) ver_info.project_num );
log_printf( &logger, " Version %.1f \r\n", ver_info.version );
log_printf( &logger, " Hardware ID %x \r\n", ( uint32_t ) ver_info.hw_id );
log_printf( &logger, " Hardware revision %x \r\n", ( uint32_t ) ver_info.hw_revision );
log_printf( &logger, " Bootloader status %x \r\n", ( uint16_t ) bl_status );
log_printf( &logger, "----------------------------------------------------------------\r\n" );
Delay_1sec( );
log_printf( &logger, "----------------------------------------------------------------\r\n" );
log_printf( &logger, " Waiting for a new touch or snap (click)\r\n" );
log_printf( &logger, "----------------------------------------------------------------\r\n" );
Delay_1sec( );
log_info( &logger, " Application Task " );
}
#define TOUCHPAD5_IQS550_PRODUCT_NUMBER
TouchPad 2 Product Number selection.
Definition touchpad5.h:340
#define TOUCHPAD5_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition touchpad5.h:323
err_t touchpad5_check_bl_status(touchpad5_t *ctx, uint8_t *rx_buf)
TouchPad 5 Check Bootloader Status.
err_t touchpad5_check_version(touchpad5_t *ctx, touchpad5_ver_info_t *ver_info)
TouchPad 5 Check Version function.
void application_init(void)
Definition main.c:93
@ TOUCHPAD5_ERROR
Definition touchpad5.h:462
Application Task
Task busy waits for the touchpad controller ready bit using polling operation. When the communication window is available, the snap functionality is being checked, as well as XY touchpad data. Based on the user's touch sensibility and duration, one of the two features is being determined and logged over UART terminal. Snap (click) corresponds to the shorter and lighter 'click' gesture, while the touch is detected as longer and stronger 'swipe' gesture.
{
{
log_printf( &logger, "----------------------------------------------------------------\r\n" );
log_printf( &logger, "\r\n* Snap (click) event occured with strength: %u *\r\n",
( uint16_t ) touch_data.touch_strength );
log_printf( &logger, "----------------------------------------------------------------\r\n" );
Delay_1sec( );
}
{
log_printf( &logger, "----------------------------------------------------------------\r\n" );
log_printf( &logger, " \r\nTouch with Tag ID %u detected\r\n", ( uint16_t ) touch_data.id_tag );
log_printf( &logger, "Coordinate X = %u \r\n", touch_data.x_pos );
log_printf( &logger, "Coordinate Y = %u \r\n", touch_data.y_pos );
log_printf( &logger, "Touch strength = %u \r\n", ( uint16_t ) touch_data.touch_strength );
log_printf( &logger, "----------------------------------------------------------------\r\n\r\n" );
Delay_ms ( 100 );
}
{
log_printf( &logger, "----------------------------------------------------------------\r\n" );
log_error( &logger, "\r\n Unexpected reset occured. \r\n" );
log_printf( &logger, "----------------------------------------------------------------\r\n\r\n" );
}
}
#define TOUCHPAD5_SHOW_RESET
TouchPad 5 description setting.
Definition touchpad5.h:128
void application_task(void)
Definition main.c:169
#define SNAP_BUFFER_SIZE
Definition main.c:35
bool touchpad5_detect_snap(touchpad5_t *ctx, uint16_t *snap_buffer, uint8_t snap_buffer_size, uint16_t *snap_reference)
TouchPad 5 snap detection function.
Definition main.c:248
#define TOUCH_STRENGTH_THRESHOLD
Definition main.c:44
Note
This example relies on the IQS5xx-A000 firmware of the touch-pad controller.
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.TouchPad5
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.