Professional Documents
Culture Documents
Architecture
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 1
1
Agenda
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 2
The main focus of this presentation is to introduce you to the different components
of the library and give you a first hand look on how to use the library.
2
Agenda
z Library Overview
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 3
First we will take a brief look at the Microchip Library Architecture and give an
overview of each layer.
3
Agenda
z Library Overview
z Graphics Object Layer
z Advanced Graphics Objects
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 4
Next we take a look at the Graphics Object Layer which covers the Advanced
Graphics Objects or commonly known as widgets. These will probably be the most
commonly used items in the library and I would like to give you a brief summary on
the different Objects that the library supports.
4
Agenda
z Library Overview
z Graphics Object Layer
z Advanced Graphics Objects
z Message Interface
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 5
Next we will take a look at the Message Interface that the library provides. This will
introduce how messaging simplifies integration of application, user interface
modules and library components.
5
Agenda
z Library Overview
z Graphics Object Layer
z Advanced Graphics Objects
z Message Interface
z Graphics Library Usage
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 6
We will also take a look at a basic example to give you a jump start on how to use
the library. This will assist you to easily navigate through the documentation and get
you up and running with your application using Microchip’s graphic system solution.
6
Library Overview
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 7
7
Library Overview
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 8
A single C file implements the most basic functions (ex: PutPixel, GetPixel Set Color) needed to
initialize and use the display device. This is usually through the display device controller.
8
Library Overview
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 9
In some cases, a Graphical Accelerator is implemented in the display controller which performs a
basic rendering function efficiently. This may be enabled by writing to some special registers in
the device controller. This comprises the Device Driver Layer.
9
Library Overview
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 10
10
Library Overview
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 11
This layer calls the basic functions in the Device Driver Layer to render primitive shapes. For
example, a Line function in the Graphics Primitive Layer will call a PutPixel function of the Device
Driver Layer repeatedly with the controlled changes to the x and y positions. Each pixels
identified by the x and y positions will be set to the color chosen for the line.
11
Library Overview
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 12
12
Library Overview
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 13
In this layer, advanced objects such as Widgets are implemented. This layer also automatically
handles management of objects from creation to destruction. Throughout this session, we will
refer to widgets as Objects.
13
Library Overview
Application Layer
Mouse Key Pad Touch Screen
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 14
The library assumes the application layer to contain the modules that initializes and controls the user
interface modules (ex: keypad, touchscreen).
14
Library Overview
Application Layer
Mouse Key Pad Touch Screen
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 15
A user interface is provided by the Graphics Object Layer to facilitate easy integration of user
interface modules. This allows the library to be portable to systems with different user interface
modules.
15
Library Overview
Application Layer
Mouse Key Pad Touch Screen
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 16
Through the message interface, the application can communicate with the Objects. Together with the
Graphics Object Layer API, applications can now fully integrate the Objects into the application
functions.
16
Library Overview
Application Layer
Application
Mouse Key Pad Touch Screen Specific
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 17
We see the three layers of the system. The library integrates some Device Specific and Application
Specific modules and create a solution that is easy to use, and portable.
17
Library Overview
Application Layer
Application
Mouse Key Pad Touch Screen Specific
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 18
Furthermore, the application has the facility to directly communicate with any layer of the library.
18
Library Overview
Application Layer
Application
Mouse Key Pad Touch Screen Specific
Graphics Display
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 19
19
Graphics Object Layer
Advanced Graphics Objects (Widgets)
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 20
20
Graphics Object Layer
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 21
21
Graphics Object Layer
Image
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 22
22
Graphics Object Layer
Rounded
Button
Image
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 23
A rounded button with red color scheme is shown. The green button shows a
pressed state.
23
Graphics Object Layer
Rounded
Button
Circular
Button
Image
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 24
24
Graphics Object Layer
Scroll Bar
Rounded
Button
Circular
Button
Image
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 25
25
Graphics Object Layer
Scroll Bar
Check
Box
Rounded
Button
Circular
Button
Image
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 26
26
Graphics Object Layer
Scroll Bar
Meter
Check
Box
Rounded
Button
Circular
Button
Image
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 27
27
Advanced Graphics Object
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 28
28
Advanced Graphics Object
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 29
29
Advanced Graphics Object
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 30
2. Object behavior is based on its present state and user action on the Object.
30
Advanced Graphics Object
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 31
31
Advanced Graphics Object
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 32
32
Advanced Graphics Object
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 33
33
Message Interface
Application Layer
Mouse Key Pad Touch Screen
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 34
The best user experience is achieved when the user input device works cohesively
with the display. This is the reason why the library integrates the basic
management of the Objects based on the user actions.
Benefits derived from this implementation are the following:
1. This simplifies the Object management from the application point of view.
34
Message Interface
Application Layer
Mouse Key Pad Touch Screen
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 35
35
Message Interface
Application Layer
Mouse Key Pad Touch Screen
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 36
36
Message Interface
Application Layer
Mouse Key Pad Touch Screen
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 37
4. And provides a seamless integration of the input devices with the Objects in the
screen.
37
Graphics Library Usage
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 38
How do we use the library? How easy is it to implement the Objects and use it in
your application?
Let’s take a look at a simple example:
38
Graphics Library Usage
Initialize Graphics
InitGraph()
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 39
First InitGraph() is called to reset the display device controller, move the cursor
position to (0, 0) position, and initialize the display to black.
39
Graphics Library Usage
Initialize Graphics
InitGraph()
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 40
Next GOLCreateScheme() is called to define the style scheme used for the
Objects. What is a style scheme? Let’s take a closer look.
40
Style Scheme
z By default, all objects uses a global style scheme
structure that defines the font table used and the
color scheme used.
typedef struct {
WORD EmbossDkColor;
WORD EmbossLtColor;
WORD TextColor0;
WORD TextColor1;
WORD TextColorDisabled;
WORD Color0;
WORD Color1;
WORD ColorDisabled;
WORD CommonBkColor;
char *pFont;
} GOL_SCHEME;
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 41
By default all objects uses a global style scheme structure that defines the font table
used and the color scheme used.
41
Style Scheme
z By default, all objects uses a global style scheme
structure that defines the font table used and the
color scheme used.
typedef struct {
WORD EmbossDkColor;
WORD EmbossLtColor;
WORD TextColor0; Unpressed
WORD TextColor1;
WORD TextColorDisabled;
WORD Color0;
WORD Color1;
WORD ColorDisabled;
WORD CommonBkColor; Pressed
char *pFont;
} GOL_SCHEME;
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 42
42
Style Scheme
z By default, all objects uses a global style scheme
structure that defines the font table used and the
color scheme used.
typedef struct { EmbossDkColor
EmbossLtColor
WORD EmbossDkColor;
WORD EmbossLtColor;
WORD TextColor0; Unpressed
WORD TextColor1;
WORD TextColorDisabled;
WORD Color0;
WORD Color1;
WORD ColorDisabled;
WORD CommonBkColor; Pressed
char *pFont; EmbossDkColor
} GOL_SCHEME;
EmbossLtColor
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 43
To emulate 3 dimensional press effect we interchange the emboss dark and light
color when the object is pressed or released.
43
Style Scheme
z By default, all objects uses a global style scheme
structure that defines the font table used and the
color scheme used.
typedef struct { EmbossDkColor
EmbossLtColor
WORD EmbossDkColor;
WORD EmbossLtColor; TextColor1
WORD TextColor0; Unpressed
WORD TextColor1;
WORD TextColorDisabled;
WORD Color0;
TextColor0
WORD Color1;
WORD ColorDisabled;
WORD CommonBkColor; Pressed
char *pFont; EmbossDkColor
} GOL_SCHEME;
EmbossLtColor
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 44
44
Style Scheme
z By default, all objects uses a global style scheme
structure that defines the font table used and the
color scheme used.
typedef struct { EmbossDkColor
EmbossLtColor
WORD EmbossDkColor;
WORD EmbossLtColor; TextColor1
WORD TextColor0; Unpressed
WORD TextColor1;
WORD TextColorDisabled; Color1
WORD Color0;
TextColor0
WORD Color1;
WORD ColorDisabled; Color0
WORD CommonBkColor; Pressed
char *pFont; EmbossDkColor
} GOL_SCHEME;
EmbossLtColor
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 45
45
Style Scheme
z By default, all objects uses a global style scheme
structure that defines the font table used and the
color scheme used.
typedef struct { EmbossDkColor
EmbossLtColor
WORD EmbossDkColor;
WORD EmbossLtColor; TextColor1
WORD TextColor0; Unpressed
WORD TextColor1;
pFont
WORD TextColorDisabled; Color1
WORD Color0;
TextColor0
WORD Color1;
WORD ColorDisabled; Color0
WORD CommonBkColor; Pressed
char *pFont; EmbossDkColor
} GOL_SCHEME;
EmbossLtColor
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 46
46
Style Scheme
z By default, all objects uses a global style scheme
structure that defines the font table used and the
color scheme used.
typedef struct { EmbossDkColor
EmbossLtColor
WORD EmbossDkColor;
WORD EmbossLtColor; TextColor1
WORD TextColor0; Unpressed
WORD TextColor1;
pFont
WORD TextColorDisabled; Color1
WORD Color0;
TextColor0
WORD Color1;
WORD ColorDisabled; Color0
WORD CommonBkColor; Pressed
char *pFont; EmbossDkColor
} GOL_SCHEME;
EmbossLtColor
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 47
Common background color is used to hide the object from the screen.
TextColorDisabled and ColorDisabled is used to show that the object is in a
disabled state.
47
Graphics Library Usage
Initialize Graphics
InitGraph()
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 48
If the no changes to the style scheme will be specified, the default style scheme is
used.
48
Graphics Library Usage
Initialize Graphics
InitGraph()
GOL Init()
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 49
49
Graphics Library Usage
Initialize Graphics
InitGraph()
GOL Init()
Create Objects
ObjCreate(,,)
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 50
Next step is to create the Objects. ObjCreate( , , ) function represents the multiple
Objects that will be created. This can be a single create function call to create
one Object or a series of calls to different create functions. For example to
create a Button BtnCreate() function is used.
50
Button Example
BUTTON *BtnCreate(
WORD ID,
SHORT
Button
left,top,
right,bottom,
state,
char *pBitmap,
*pText,
GOL_SCHEME *pScheme
)
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 51
51
Button Example
BUTTON *BtnCreate(
WORD ID,
SHORT
Button
left,top,
right,bottom,
state,
char *pBitmap,
*pText,
GOL_SCHEME *pScheme
)
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 52
52
Button Example
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 53
left, top, right & bottom defines the dimension of the object.
53
Button Example
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 54
state defines the current state of the Object. For each Object type a defined
state list is used.
54
Button Example
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 55
The following list shows the state definition for the button. The way the Button
Object is redrawn on the screen is based on which bit states are set or reset.
BTN_DRAW and BTN_REMOVE are drawing states indicating the objects are to be
refreshed in the display based on the other three state bits: BTN_FOCUSED,
BTN_PRESSED and BTN_DISABLED.
55
Button Example
z To create a button, the
following parameters are
needed: left, top
BUTTON *BtnCreate(
WORD ID,
SHORT Button
left,top,
right,bottom, right, bottom
state,
char *pBitmap,
*pText,
GOL_SCHEME *pScheme
)
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 56
pBitmap and pText are set to NULL if no text or bitmap is used. Text is drawn
on top of the bitmap if both are specified. Text drawn on the button face can
be aligned left, right, top or bottom. In the example above we use the word
“Button” as center aligned text.
pScheme – can be user defined or if set to NULL will use the default style
scheme.
56
Button Example
z To create a button, the
following parameters are
needed: left, top
BUTTON *BtnCreate(
WORD ID,
SHORT Button
left,top,
right,bottom, right, bottom
state,
*pBitmap – Set to NULL
char *pBitmap, when not using bitmaps.
*pText,
*pScheme – User defined
GOL_SCHEME *pScheme or set to NULL to use
) default settings.
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 57
pBitmap and pText are set to NULL if no text or bitmap is used. Text is drawn
on top of the bitmap if both are specified. Text drawn on the button face can
be aligned left, right, top or bottom. In the example above we use the word
“Button” as center aligned text.
pScheme – can be user defined or if set to NULL will use the default style
scheme.
57
Graphics Library Usage
Initialize Graphics
InitGraph()
GOL Init()
Create Objects
ObjCreate(,,)
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 58
After the Objects are created, they are drawn by calling the GOLDraw() function.
58
Graphics Library Usage
Create Objects
ObjCreate(,,)
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 59
This function parses the active Object’s link list and checks the drawing state of
each of the Objects. If an Object has a pending drawing state set, the Object will
be redrawn. After GOLDraw() renders the Object, it resets the pending drawing
state.
59
Button Example
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 60
To render the Button on the screen, BtnDraw(pb) is called where pB is the pointer to
the button object rendered.
60
Button Example
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 61
61
Button Example
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 62
62
Button Example
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 63
where stateBits are the bits of the state variable of the Button object described
earlier.
63
Button Example
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 64
64
Button Example
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 65
65
Button Example
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 66
66
Button Example
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 67
3. Style schemes can be assigned to individual objects. Even objects of the same
type can be assigned different style schemes.
67
Graphics Library Usage
Create Objects
ObjCreate(,,)
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 68
68
Graphics Library Usage
Create Objects
ObjCreate(,,)
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 69
Assume that a user interface module is implemented in the application that sends
messages to the library through the message interface. These messages
contain the user action on the objects in the screen.
69
Messaging
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 70
70
Messaging
z Message Structure
typedef struct {
BYTE type;
BYTE event;
SHORT param1;
SHORT param2;
} GOL_MSG;
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 71
71
Messaging
z Message Structure
typedef struct {
BYTE type;
BYTE event;
SHORT param1;
SHORT param2;
} GOL_MSG;
z type is used to determine keypad, touch screen or
pointing device. This also determines how param(n)
are interpreted.
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 72
type – defines the device type used. Examples are keypad, touch screen or pointing
devices.
72
Messaging
z Message Structure
typedef struct {
BYTE type;
BYTE event;
SHORT param1;
SHORT param2;
} GOL_MSG;
z type is used to determine keypad, touch screen or
pointing device. This also determines how param(n)
are interpreted.
− Example: Message from touch screen:
− param1 : x position
− param2 : y position
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 73
param1 and param2 – are interpreted based on the type. For the touch screen,
parameters 1 and 2 are defined as the x and y coordinate position respectively.
73
Messaging
z Message Structure
typedef struct {
BYTE type;
BYTE event;
SHORT param1;
SHORT param2;
} GOL_MSG;
z type is used to determine keypad, touch screen or
pointing device. This also determines how param(n)
are interpreted.
− Example: Message from touch screen:
− param1 : x position
− param2 : y position
− For keypad: parameters can be a key code
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 74
74
Messaging
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 75
Events is also interpreted as the messages specific to the input devices, more
precisely the user action. They are pre-defined and all devices of the same type
should use these messages.
75
Messaging
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 76
76
Messaging
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 77
For a keyboard:
• EVENT_PRESS
• EVENT_RELEASE
77
Messaging
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 78
78
Messaging
z User Action ID
− List of defined actions (or state change) that
an object has accepted.
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 79
When the receiving Object evaluated the message to be valid it replies with one of
the defined action ID. The Action ID is a list of defined actions that an object will
accept.
79
Messaging
z User Action ID
− List of defined actions (or state change) that
an object has accepted.
− Each object type has a predefined list.
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 80
80
Messaging
z User Action ID
− List of defined actions (or state change) that
an object has accepted.
− Each object type has a predefined list.
− Button Example:
− BTN_MSG_PRESSED
− BTN_MSG_RELEASED
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 81
For the Button example, the two predefined action ID are BTN_MSG_PRESSED
and BTN_MSG_RELEASED.
81
Messaging
z User Action ID
− List of defined actions (or state change) that
an object has accepted.
− Each object type has a predefined list.
− Button Example:
− BTN_MSG_PRESSED
− BTN_MSG_RELEASED
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 82
82
Graphics Library Usage
Create Objects
ObjCreate(,,)
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 83
83
Graphics Library Usage
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 84
GOLMsg() to process these messages and checks the active Object’s link list to
determine which Object will be affected by the message. An optional way to
modify object behavior is also provided. One way is through the message call
back.
84
Message Callback Example
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 85
85
Message Callback Example
WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg) {
WORD objectID;
objectID = GetObjID(pObj);
86
Message Callback Example
WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg) {
WORD objectID;
objectID = GetObjID(pObj);
switch(objectID) {
case ID_WINDOW1: // If x,y in client area draw red pixel
case ID_BUTTON2:
}
return 1; // Process message by default
}
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 87
In this example: there are three objects: WINDOW, BUTTON1 and BUTTON2.
87
Message Callback Example
WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg) {
WORD objectID;
objectID = GetObjID(pObj);
switch(objectID) {
case ID_WINDOW1: // If x,y in client area draw red pixel
if(objMsg == WND_MSG_CLIENT) {
SetColor(RED);
PutPixel(pMsg->param1,pMsg->param2);
}
return 0; // Don’t process by default
case ID_BUTTON2:
}
return 1; // Process message by default
}
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 88
For WINDOW: when touch screen touches the CLIENT area indicated by the
WND_MSG_CLIENT action ID, the pixel on the x,y location is set to red.
88
Message Callback Example
WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg) {
WORD objectID;
objectID = GetObjID(pObj);
switch(objectID) {
case ID_WINDOW1: // If x,y in client area draw red pixel
if(objMsg == WND_MSG_CLIENT) {
SetColor(RED);
PutPixel(pMsg->param1,pMsg->param2);
}
return 0; // Don’t process by default
case ID_BUTTON2:
}
return 1; // Process message by default
}
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 89
After drawing the red pixel, it returns 0 indicating that no further default action will be
processed on the message and the message is discarded.
89
Message Callback Example
WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg) {
WORD objectID;
objectID = GetObjID(pObj);
switch(objectID) {
case ID_WINDOW1: // If x,y in client area draw red pixel
if(objMsg == WND_MSG_CLIENT) {
SetColor(RED);
PutPixel(pMsg->param1,pMsg->param2);
}
return 0; // Don’t process by default
case ID_BUTTON2:
}
return 1; // Process message by default
}
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 90
For BUTTON1: If the touch screen presses this object as indicated by the
BTN_MSG_PRESSED action ID, the bitmap drawn on the object is changed to
duckPressed.
90
Message Callback Example
WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg) {
WORD objectID;
objectID = GetObjID(pObj);
switch(objectID) {
case ID_WINDOW1: // If x,y in client area draw red pixel
if(objMsg == WND_MSG_CLIENT) {
SetColor(RED);
PutPixel(pMsg->param1,pMsg->param2);
}
return 0; // Don’t process by default
case ID_BUTTON2:
}
return 1; // Process message by default
}
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 91
91
Message Callback Example
WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg) {
WORD objectID;
objectID = GetObjID(pObj);
switch(objectID) {
case ID_WINDOW1: // If x,y in client area draw red pixel
if(objMsg == WND_MSG_CLIENT) {
SetColor(RED);
PutPixel(pMsg->param1,pMsg->param2);
}
return 0; // Don’t process by default
case ID_BUTTON2:
}
return 1; // Process message by default
}
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 92
To complete the object’s press and release effect we must return 1 and let the
library manage the press and effect rendering of the button.
92
Message Callback Example
WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg) {
WORD objectID;
objectID = GetObjID(pObj);
switch(objectID) {
case ID_WINDOW1: // If x,y in client area draw red pixel
if(objMsg == WND_MSG_CLIENT) {
SetColor(RED);
PutPixel(pMsg->param1,pMsg->param2);
}
return 0; // Don’t process by default
case ID_BUTTON2:
break; // Do nothing process by default
}
return 1; // Process message by default
}
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 93
93
Message Callback Example
WORD GOLMsgCallback(WORD objMsg, OBJ_HEADER* pObj, GOL_MSG* pMsg) {
WORD objectID;
objectID = GetObjID(pObj);
switch(objectID) {
case ID_WINDOW1: // If x,y in client area draw red pixel
if(objMsg == WND_MSG_CLIENT) {
SetColor(RED);
PutPixel(pMsg->param1,pMsg->param2);
}
return 0; // Don’t process by default
}
return 1; // Process message by default
}
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 94
In fact if there is no action change needed we can remove this case in the switch.
Library will manage BUTTON2 for you.
94
Graphics Library Usage
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 95
95
Graphics Library Usage
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 96
GOLDraw() is again called to redraw the Objects. Thus completing the cycle.
96
Summary
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 97
97
Summary
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 98
The Microchip Graphics Library structure allows easy integration of user interface
devices, and display devices.
98
Summary
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 99
The modular solution allows easy migration from one display platform to another.
99
Summary
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 100
You have seen the simple usage of the library and with a small code integrate it into
your application.
100
Summary
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 101
This is a free graphics library solution for PIC microcontrollers. For source code and
API manual please go to www.microchip.com/graphics
101
THANK YOU
© 2007 Microchip Technology Incorporated. All Rights Reserved. Microchip Graphics Library Architecture Slide 102
102