Messaging Structure for Graphics Applications

 Summary

This page describes the configuration and usage of the messaging data structure used in Microchip Graphics Applications. Defined in thegfx-gol.h file and typically named Msg by the application, this structure is used to communicate changes in system input to the graphics processing software. The input sources can be:

  • A Touch Screen
  • An Input Pin or PIC® Special Function Register (SFR)
  • Keypad Device

The Microchip supplied functionTouchGetMsg will populate Msg when using a touch-enabled display offered as part of a Microchip Development tool. For non-Microchip supported touch displays and for all non-touch input detection, the user's application is responsible for identifying input changes and filling in the Msg data structure.
When an input change has been recorded, the application will fill in Msg and pass it to the functionGFX_GOL_ObjectMessage for processing. The sections of this tutorial that coverprocessing user input and thegraphics overview provide the details of how Msg is processed.

Message Structure Definition

Defined in the filegfx-gol.h the structure of the message is:

GFX_GOL_MESSAGE.png

Msg can be defined in any file with the following code:

Structure for a Touch Enabled Display

When populated byTouchGetMsg for a touch enabled display, Msg will contain:

Msg-filled.png

For Touch Enabled Displays:
Msg.typealways contains value: TYPE_TOUCHSCREEN
Msg.param1 contains the X position of the event
Msg.param2 contains the Y position of the evnet
Msg.uiEvent contains the code for the specific event detected

uiEvent Codes for Touch Displays

Event CodeTouch Event Detected
EVENT_INVALID Screen wasuntouched last time and remainsuntouched
EVENT_MOVE Screen wastouched last time, this time thetouch is in a different location
EVENT_PRESS Screen wasuntouched last time and istouched this time
EVENT_STILLPRESS Screen wastouched last time and is stilltouched in the same location
EVENT_RELEASE Screen wastouched last time, but is nowuntouched

Once filled, Msg is passed on toGFX_GOL_ObjectMessage for processing.

Structure for Pin or SFR Changes

For non-touch display inputs, Msg is populated with the type set to TYPE_KEYBOARD.
TYPE_KEYBOARD is used when a change in an SFR needs to be reflected on the display. (Note: A change to an input pin will be reflected in the corresponding PORTx SFR.)

keyboard-msg.png

Example of an Analog Pin Change

For Analog Pin Changes:
Msg.typealways contains value: TYPE_KEYBOARD
Msg.uiEvent contains EVENT_KEYSCAN or EVENT_CHARCODE
Msg.param1ObjectID of the event recipient
Msg.param2 The new value of the ADC Result register

Expected uiEvent Codes for Analog Pin Changes

Event CodeEvent Detected
EVENT_INVALID Current ADC value is not significantly different from last reported value
EVENT_KEYSCAN Current value of the ADC requires the display to be updated
EVENT_CHARCODE Current value of the ADC requires the display to be updated ( same as EVENT_KEYSCAN)

Example of a Digital Pin Change

For Digital Pin Changes:
Msg.typealways contains value: TYPE_KEYBOARD
Msg.uiEvent contains valid Event code
Msg.param1ObjectID of the event recipient
Msg.param2 -Not Used-

Expected uiEvent Codes for Digital Pin Changes

Event CodeEvent Detected
EVENT_PRESS The Pin value is now High and was Low on previous read
EVENT_STILLPRESS Current and Previous value of the pin is High
EVENT_RELEASE The input value is now Low and was High on previous read

Structure for Keyboard Input

For keyboard inputs, Msg is populated with the type set to TYPE_KEYBOARD.
The message structure for keyboards is similar to the structure for changes in digital inputs.

keyboard-msg.png

Example of a Keyboard Input

For Analog Pin Changes:
Msg.typealways contains value: TYPE_KEYBOARD
Msg.uiEvent contains EVENT_KEYSCAN or EVENT_CHARCODE
Msg.param1ObjectID of the event recipient
Msg.param2 The value of the input character or scan code

Expected uiEvent Codes for Keyboard

Event CodeEvent Detected
EVENT_KEYSCAN Value of the Keyscan
EVENT_CHARCODE ASCII code for the keyboard input