The "TouchGetMsg" Function
Graphic Application projects created by Microchip typically have the function TouchGetMsg(&msg) as the first function called after the Display routine has finished processing the display list.
TouchGetMsg determines if and where a touch event has occurred. A touch event is a touch, a release, or a movement on the screen. If an event is observed the data structure MSG is populated with the touch info. The data structure is then passed on to GFX_GOL_ObjectMessage for processing.
Supplied by Microchip, TouchGetMsg is considered part of the application and not part of the Graphics Library. TouchGetMsg was written to read the specific resistive-touch display panels used on Microchip evaluation boards. Customers wishing to use display panels other than those offered by Microchip will have to rewrite the function to work with the selected display panel.
Msg Data Structure
TouchGetMsg will populate a data structure each time it is called. In Microchip Graphics applications this data structure is named Msg. In addition to display panels the Msg data structure was designed to record touch events on other media such as keypads or "side buttons".
This article explains how TouchGetMsg works with touch displays. For a complete description of the Msg data structure and how it works with other input devices, please review the Graphics Message Structure section of the Developer's help site.
Defined in the file gfx-gol.h the structure of the message is:
Msg can be defined in any file with the following code:
When Populated by TouchGetMsg Msg will contain:
* Msg.type always contains value: TYPE_TOUCHSCREEN
* Msg.param1 contains the X position of the event
* Msg.param2 contains the Y position of the event
* Msg.uiEvent contains the code for the specific event detected
|Event Code||Touch Event Detected|
|EVENT_INVALID||Screen was untouched last time and remains untouched|
|EVENT_MOVE||Screen was touched last time but this time the touch is in a different location|
|EVENT_PRESS||Screen was untouched last time and is touched this time|
|EVENT_STILLPRESS||Screen was touched last time and is still touched in the same location|
|EVENT_RELEASE||Screen was touched last time, but is now untouched|
Once filled, Msg is passed on to GFX_GOL_ObjectMessage for processing.