Microchip® Advanced Software Framework

touch_interface.c File Reference

Touch screen interface functions for the UC3C-EK.

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

#include <asf.h>
#include "touch_interface.h"

Functions

static void touch_event_handler (rtouch_event_t const *event)
 Handler for the touchscreen touch event callback. More...
 
static void touch_interface_calibrate (void)
 Calibrates the touchscreen on the display. More...
 
static void touch_interface_get_calibration_point (rtouch_calibration_point_t *point)
 Prompts and stores a single calibration point on the display. More...
 
void touch_interface_init (void)
 Initializes the touchscreen, ready to detect user input. More...
 
static bool touch_interface_is_touched (void)
 Determine if the display is currently being touched. More...
 
bool touch_interface_read (struct win_pointer_event *win_touch_event)
 Convert touch events from the touchscreen into window pointer events. More...
 
static void touch_interface_wait_touch (void)
 Waits until a full display touch event has completed. More...
 

Variables

static bool touch_event_ready = false
 Flag to indicate that a new touch event is ready to be processed. More...
 

static void touch_event_handler ( rtouch_event_t const *  event)
static

Handler for the touchscreen touch event callback.

Callback function from the touchscreen driver when a new touch event has been generated.

Parameters
eventEvent generated from the touchscreen driver

References touch_event_ready.

Referenced by touch_interface_init().

static void touch_interface_get_calibration_point ( rtouch_calibration_point_t point)
static

Prompts and stores a single calibration point on the display.

Prompts the user for a single calibration point on the display at the nominated coordinates, and saves the resulting raw touch point.

Parameters
pointCalibration point structure to fill with a touch coordinate

References GFX_COLOR_BLUE, gfx_draw_circle, gfx_draw_filled_circle, GFX_WHOLE, rtouch_calibration_point_struct::panelX, rtouch_calibration_point_struct::panelY, rtouch_calibration_point_struct::rawX, rtouch_calibration_point_struct::rawY, rtouch_get_event(), and touch_interface_wait_touch().

Referenced by touch_interface_calibrate().

void touch_interface_init ( void  )

Initializes the touchscreen, ready to detect user input.

Performs and initialization and calibration of the touchscreen, so that it is ready for use.

References rtouch_enable(), rtouch_init(), rtouch_set_event_handler(), touch_event_handler(), and touch_interface_calibrate().

Referenced by main().

static bool touch_interface_is_touched ( void  )
static

Determine if the display is currently being touched.

Checks if the user is currently touching the display, with debouncing.

Returns
Boolean true if the display is being touched, false otherwise.

References delay_ms, and rtouch_is_touched().

Referenced by touch_interface_wait_touch().

bool touch_interface_read ( struct win_pointer_event win_touch_event)

Convert touch events from the touchscreen into window pointer events.

Reads touch events in from the touchscreen and converts them into a Window Manager pointer event, for enqueuing into the window event queue.

Returns
Boolean true if a touch event was read, false if no touch event or a corrupt touch event was received

References win_pointer_event::buttons, cpu_irq_restore(), cpu_irq_save(), win_pointer_event::is_relative, rtouch_event_struct::panelX, rtouch_event_struct::panelY, win_pointer_event::pos, rtouch_get_event(), RTOUCH_MOVE, RTOUCH_NO_EVENT, RTOUCH_PRESS, RTOUCH_RELEASE, touch_event_ready, rtouch_event_struct::type, win_pointer_event::type, WIN_POINTER_MOVE, WIN_POINTER_PRESS, WIN_POINTER_RELEASE, WIN_TOUCH_BUTTON, win_point::x, and win_point::y.

Referenced by main().

static void touch_interface_wait_touch ( void  )
static

Waits until a full display touch event has completed.

Reads touch events in from the touchscreen and waits for a full touch and release event before continuing.

References touch_interface_is_touched().

Referenced by touch_interface_get_calibration_point().

bool touch_event_ready = false
static

Flag to indicate that a new touch event is ready to be processed.

Referenced by touch_event_handler(), and touch_interface_read().