Overview of a typical Graphics Application's Software

Introduction

GFX_app_code.png

Typical Graphics Application
The code on the screen represents a typical PIC® MCU graphics application. Understanding the program flow is essential to developing graphics applications.

Navigation
The next few screens contain an explanation for each of these lines of code. After reviewing the program overview you will be able to explore the individual graphics topics and begin developing applications. To navigate to another screen select from the grey buttons in the header above.

User's Application Code

GFX_app_code.png

User's Application Code


These functions represent the non-graphics portion of the application program.

SYSTEM_InitializeBoard(); represents the user written function which performs the one-time start up initialization needed for the application to run.

APP_Tasks(); represents the function (or functions) which run infinitely to execute the non-graphics portion of the user application.

Initializing the Graphics Library

GFX_app_code.png
GFX_Initialize.png
right-arrow.png

Graphics Library Initialization


Before any graphics items can be output to the display DRVgfx_Initialize must be run to initialize the hardware drivers

GFX_Primitive_Initialize sets up the library to outputs Graphics Primitive elements.

Setting up the Callback Functions

GFX_app_code.png

Setting up the Callback Function


Microchip Graphics Applications utilize two callback functions: GFX_GOL_MessageCallback and GFX_GOL_DrawCallback. The user is responsible for writing the functions to perform these tasks and then setting these user-written functions as the call back routines.

This example shows the user-written APP_ObjectMessageCallback being set as the message callback function and APP_ObjectDrawCallback being set as the drawing callback function.

Creating Screens

GFX_app_code.png

Creating Screens to Display


APP_CreateScreens() represents a user written function that creates screens to display. A screen, or display list, is a list of interactive Graphics Objects linked together and kept in the MCU's heap memory. The application generates the display list at run time by making a series of object creating function calls.

In order to successfully create a screen you will need to understand the object creating functions, the object state bits, and style schemes.

Drawing Graphics Objects

GFX_app_code.png

Drawing Graphic Objects


GFX_GOL_ObjectListDraw() parses the linked list of objects and updates the frame buffer based on the state bits of the objects in the list.

When GFX_GOL_ObjectListDraw completes parsing the list a 'true' condition is returned

It may take more than one call to GFX_GOL_ObjectListDraw to complete processing the current linked list

The "Safe" Zone

GFX_app_code.png

The "Safe" Zone


Altering the state-bits of the display list while the list is being processed by GFX_GOL_ObjectListDraw can result in anomalies in the image being displayed.

To avoid problems with the display the only safe place to update the list of objects is after the drawing function returns a true condition

Getting Touch Input

GFX_app_code.png

Getting User Input


TouchGetMsg is a function supplied by Microchip to detect if (and where) there is a touch, release, or movement on a resistive-touch graphics display. This function populates the structure called msg with information on the touch event.

Processing Input

GFX_app_code.png

Processing Input


GFX_GOL_ObjectMessage() analyzes msg to detemine if the touch event impacts an existing graphics object.

If an object has been touched, the callback function GFX_GOL_MessageCallback is executed to process the event.

Message Callback Function

GFX_app_code.png

GOL_MessageCallback


  • Written by user and called by: GFX_GOL_ObjectMessage
  • Performs MCU actions based on input to an object. These actions may include starting a motor, turning on an LED, or any MCU controlled task
  • Changes the appearance of an object (or objects) in the display list and updates their status bit so they will be redrawn to the frame buffer by: GFX_GOL_ObjectListDraw.
  • Returns CPU control to: GFX_GOL_ObjectMessage

Draw Callback Function

GFX_app_code.png

GOL_DrawCallback


  • Written by user and called by: GFX_GOL_ObjectListDraw
  • Executes on each iteration of the main loop regardless of whether or not a touch event has occurred
  • Can be used in conjunction with the message callback function to determine how long a touch event has occurred. Timing a touch event facilitates taking a action based on how long a touch event has occurred (e.g. dimmer switches or volume control)
  • Returns control to:GFX_GOL_ObjectListDraw

20th Annual
Microchip MASTERs Conference 2016
Register now - Deadline: July 29

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.