Microchip® Advanced Software Framework

multi-touch_demo.c File Reference

mXT143E Xplained multi-touch demo application

Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include <stdio.h>

Data Structures

struct  finger
 Struct for touch visualization data. More...


 Background color of display. More...
 Define to enable display of touch coordinates with each square. More...
 Define to enable resizing of the touch square based on the touch size. More...
#define MAX_TOUCHES   8
 Maximum number of touches to track. More...
 Address of the mXT143E on TWI bus. More...
#define MIN_SQUARE_SIZE   70
 Minimum size of touch squares to draw. More...


static void draw_finger_square (const struct finger *draw_finger, const gfx_color_t color)
 Draw square around a finger. More...
static void get_finger_display_coordinates (const struct mxt_touch_event *touch_event, struct finger *finger_data)
 Compute display coordinates for touch. More...
int main (void)
 Main application loop. More...
static void mxt_handler (struct mxt_device *device)
 Handle maXTouch messages. More...
static void mxt_init (struct mxt_device *device)
 Set maXTouch configuration. More...


Background color of display.

Referenced by main(), and mxt_handler().


Define to enable display of touch coordinates with each square.


Define to enable resizing of the touch square based on the touch size.

#define MAX_TOUCHES   8

Maximum number of touches to track.

Referenced by mxt_handler().


Address of the mXT143E on TWI bus.

Referenced by mxt_init().

#define MIN_SQUARE_SIZE   70

Minimum size of touch squares to draw.

Referenced by draw_finger_square().

static void draw_finger_square ( const struct finger draw_finger,
const gfx_color_t  color 

Draw square around a finger.

This function draws an unfilled square around the specified finger.

draw_fingerPointer to finger struct
colorColor to draw with

References GFX_COLOR_TRANSPARENT, gfx_draw_string(), gfx_generic_draw_rect(), gfx_get_string_bounding_box(), MIN_SQUARE_SIZE, finger::size, sysfont, finger::x, and finger::y.

Referenced by mxt_handler().

static void get_finger_display_coordinates ( const struct mxt_touch_event touch_event,
struct finger finger_data 

Compute display coordinates for touch.

This function computes the display coordinates for a given touch event, and stores it in the specified X- and Y-coordinate containers.

touch_eventPointer to touch event
finger_dataPointer to finger struct

References gfx_get_height(), gfx_get_width(), finger::size, mxt_touch_event::size, finger::x, mxt_touch_event::x, finger::y, and mxt_touch_event::y.

Referenced by mxt_handler().

int main ( void  )

Main application loop.

This is the main application function, which runs all the initialization code, clears the display and enters a loop in which it continuously polls for new messages from the maXTouch device. If one or more messages are pending, the maXTouch message handler is invoked.

References board_init(), DISPLAY_COLOR, gfx_draw_filled_rect, gfx_get_height(), gfx_get_width(), gfx_init, mxt_handler(), mxt_init(), mxt_is_message_pending(), and sysclk_init().

static void mxt_handler ( struct mxt_device device)

Handle maXTouch messages.

This function handles the maXTouch messages, triggering the drawing of squares around new or moved touches, and removing the squares around released touches.

devicePointer to mxt_device struct

References DISPLAY_COLOR, draw_finger_square(), finger::enable, get_finger_display_coordinates(), GFX_COLOR_BLUE, GFX_COLOR_CYAN, GFX_COLOR_GRAY, GFX_COLOR_GREEN, GFX_COLOR_MAGENTA, GFX_COLOR_RED, GFX_COLOR_WHITE, GFX_COLOR_YELLOW, mxt_touch_event::id, MAX_TOUCHES, mxt_is_message_pending(), MXT_MOVE_EVENT, MXT_PRESS_EVENT, mxt_read_touch_event(), MXT_RELEASE_EVENT, mxt_touch_event::status, and STATUS_OK.

static void mxt_init ( struct mxt_device device)