Microchip Technology AC164127-7 Data Sheet

Page of 34
AN1368
DS01368A-page 24
 2011 Microchip Technology Inc.
USER MESSAGE INTERFACE
The user message interface is a sublayer of the GOL
which is enabled if the GOL is used. This sublayer is
used to facilitate the message passing between
widgets and user input. For example, if the user
presses a button, then a message is sent to a call back
function, called GOLMsgCallback(), where the
message indicating that the button is pressed is
checked and an action is taken. This callback function
must be present in the application code if the GOL is
being used, no matter if message passing is being
used or not. If the message passing is not used, the
function body must return a ‘1’.
Similar to GOLDraw(),  GOLMsg() must be called
continuously in a loop inside the application code to
facilitate message collection and passing.
The usage of GOLDraw(),  GOLDrawCallback(),
GOLMsg()
 and GOLMsgCallback() are explained in
 an
APPLICATION LAYER
In this layer, the user has full control of the application.
Initially, the user must initialize the Microchip Graphics
Library. The initialization is done by calling GOLInit() if
all the layers are being used, InitGraph() if the GOL
is not being used but the Primitive and Display Driver
layers are being used, or by calling ResetDevice() if
only the Display Driver layer is being used. After the
initialization routine, the Primitive and Driver layers’ APIs
can be called to achieve the required draw functionality.
To use GOL objects (like buttons), the widgets must be
created by calling the widget’s create function (e.g.,
BtnCreate()
), one by one, until all of the widgets are
created. This step will not display the widgets. The
created widgets are drawn on the screen when the
GOLDraw()
 function is called repeatedly in a while loop.
The messages are processed by calling the GOLMsg()
inside the same loop, as shown in 
.
After GOLDraw() is done, messages are received
from the touch screen driver and hard buttons driver.
The obtained message is passed to GOLMsg() to
process and to output a widget-specific message. For
example, it converts a “USER TOUCHED POSITION
100, 100” message to BUTTON1_PRESSED.
Additionally, the application must possess the
GOLDrawCallback()
 and GOLMsgCallback()
functions.
If custom drawing is not done, then the draw callback is
used, as shown in 
.
EXAMPLE 4:
The message callback handles the processed
message sent out by the widgets, as shown in
.
If the application already uses a main loop,
GOLDraw()
 and GOLMsg() can be called within the
loop (see 
Note 1:
Refer to the application note, AN1136, How
to Use Widgets in Microchip Graphics
Library
” for creating a simple application.
2:
Refer to the Microchip Graphics Library
Help file for the list of related application
notes.
WORD GOLDrawCallback(void)
{
return (1);
}