touchpad5 2.0.0.0
main.c File Reference

TouchPad5 Click example. More...

#include "board.h"
#include "log.h"
#include "touchpad5.h"

Macros

#define SNAP_BUFFER_SIZE   ( 8 )
 
#define SNAP_NUMBER_OF_CHANNELS   ( 8 )
 
#define SNAP_MAX_NO_CONSECUTIVE_SAMPLES   ( 3 )
 
#define TOUCH_STRENGTH_THRESHOLD   ( 30 )
 

Functions

bool touchpad5_get_snap_sample (touchpad5_t *ctx, uint16_t *snap_data)
 TouchPad 5 snap sample getter.
 
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.
 
void application_init (void)
 
void application_task (void)
 
int main (void)
 

Detailed Description

TouchPad5 Click 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.

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.

Note
This example relies on the IQS5xx-A000 firmware of the touch-pad controller.
Author
Stefan Popovic

Macro Definition Documentation

◆ SNAP_BUFFER_SIZE

#define SNAP_BUFFER_SIZE   ( 8 )

◆ SNAP_MAX_NO_CONSECUTIVE_SAMPLES

#define SNAP_MAX_NO_CONSECUTIVE_SAMPLES   ( 3 )

◆ SNAP_NUMBER_OF_CHANNELS

#define SNAP_NUMBER_OF_CHANNELS   ( 8 )

◆ TOUCH_STRENGTH_THRESHOLD

#define TOUCH_STRENGTH_THRESHOLD   ( 30 )

Function Documentation

◆ application_init()

void application_init ( void )

< Logger config object.

< Click config object.

Logger initialization. Default baud rate: 115200 Default log level: LOG_LEVEL_DEBUG

Note
If USB_UART_RX and USB_UART_TX are defined as HAL_PIN_NC, you will need to define them manually for log to work. See LOG_MAP_USB_UART macro definition for detailed explanation.

◆ application_task()

void application_task ( void )

◆ main()

int main ( void )

◆ touchpad5_detect_snap()

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.

This function checks for snap criteria defined by snap reference and predefined number of consecutive samples deviating from said reference.

Parameters
[in]ctx: Click context object. See touchpad5_t object definition for detailed explanation.
[out]snap_buffer: Snap buffer with snap status data .
[in]snap_buffer_size: Buffer size of the 16-bit snap data.
[out]snap_reference: Pointer to the reference data calculated inside within each iteration.
Returns
true - Snap detected, false - Snap not detected.
Note
Snap functionality must be enabled in control settings byte second byte.

◆ touchpad5_get_snap_sample()

bool touchpad5_get_snap_sample ( touchpad5_t * ctx,
uint16_t * snap_data )

TouchPad 5 snap sample getter.

This function gets the snap sample value as the averaged value of the predefined number of channels.

Parameters
[in]ctx: Click context object. See touchpad5_t object definition for detailed explanation.
[out]snap_data: Pointer to the memory location of the buffer where data is stored.
Returns
true - Success, false - Error.
Note
Snap functionality must be enabled in control settings byte second byte.