Guest columnist Paul Silcock, technical solutions manager at Future Electronics, asks can free libraries for embedded applications be suitable for production designs?
Many embedded applications include a user interface (UI) for control and display, traditionally in the form of LEDs or a segment LCD with push-buttons.
Until recently, the development of more sophisticated UIs was limited by the small size of the ROM and RAM memories in microcontrollers. Adding a dedicated graphics controller to the circuit opened up many more design options, but the cost was prohibitive for most embedded products.
Recent advances in smartphone technology, however, have changed the game for embedded developers. The massive volumes of smartphones in production today, typically characterised by a colour graphical display and a touch panel, have driven down the cost of displays with serial or parallel interfaces and on-board display RAM.
The popular demand for these devices has also made it desirable to incorporate their attractive UI features into modern embedded designs.
Of course, smartphone manufacturers have dedicated UI design teams and massive financial resources to invest in UI development. So how can embedded developers create sophisticated graphical displays given that they generally work under severe time and cost constraints?
Professional graphics libraries are available from a number of vendors, but their price generally makes them unsuitable for developers of low-volume embedded products.
This is a problem that several of the large microcontroller manufacturers have now addressed by providing free graphics libraries which run on their devices, adapted to the requirements of embedded device OEMs.
What is a graphics library?
A graphics library is a collection of graphical elements which may be used to create a display image or menu screen.
These elements can be categorised as:
■ Graphics primitives – the fundamental building blocks such as lines, arcs and points.
■ Graphics objects or widgets – shapes such as buttons, checkboxes and dials used to display data or to provide user input.
■ Glyphs – typeface elements such as alphanumeric characters and punctuation marks, in a particular font.
Free libraries are available from a number of microcontroller manufacturers. For instance, Microchip has a graphics library for use with PIC24 and PIC32 devices. Supporting information on the Microchip website includes application notes, example code and tools.
Freescale Semiconductor’s free graphical library is called the Embedded Graphical User Interface or eGUI and is designed to run on ColdFire and Kinetis microcontrollers. It can be used as a stand-alone product or integrated into the MQX operating system which Freescale supplies free with its 32-bit devices.
The application programming interface (API) for the eGUI library is POSIX-compliant and so can be integrated easily with the MQX RTOS, eCOS or Linux. Users of 8-bit, 16-bit and 32-bit microcontrollers from STMicroelectronics can work with the company’s general purpose graphics library. Application Note AN3128 (available at www.st.com) describes the features of the library and its APIs.
Configuring the display
A fundamental decision for the designer to make is about the type of display to use.
There is a wide choice, from simple segment LCD types to TFT colour LCDs. This decision will be influenced by the issues of cost, power consumption, resolution, colour depth and update speed. The display must also be sized to fit the intended enclosure.
Clearly, as the resolution and colour depth increase, the memory required to store an image increases. In order to control the display hardware from the graphics library, a display driver file is required.
This file describes the target display in terms of resolution and colour depth, defines the electrical signals required to control the driver IC and maps (x,y) co-ordinates to an image memory address. It also defines the display initialisation procedure.
Now that the basic building blocks have been explored, it is important to understand how they fit together.
How to use a graphical library
To create a menu system on the selected microcontroller, the designer must first choose the display to be used.
In order to implement the hardware set-up, the user must ensure that the correct driver file is included in the project.
Where the display device driver is not provided, some work may be required to edit a similar file.
It is often easiest to start with a simple project provided for the target microcontroller and make changes to the driver file as required.
Once the user can successfully drive the display, he must decide how many different display screens will be required and which functions will be called by each displayed widget.
The simplest design might have a single screen, displaying a selection of system parameters and offering control of one or more functions in the application.
More complex systems might have several sub-menu levels, requiring a large number of screens and an increased memory requirement.
Each screen is designed using the library’s API calls, which define the position, size, colour and behaviour of each on-screen element.
Some vendors also provide tools for designing screens in a PC application which then generates the required code.
For instance, Microchip provides a tool called Graphics Display Designer (www.microchip.com/gdd). Both Freescale and Microchip provide tools for converting images and fonts to C files for embedding in application code.
Once widgets have been placed, the user can add function calls to the code, enabling the selection of any given widget to trigger actions such as to load a new screen, update some system variables or run some application code.
For example, in an audio player the selection of a transport bar widget marked “Play” might load a new screen displaying the track details and a progress bar, while also starting audio playback.
The availability of low-cost display modules, together with the emergence of complimentary embedded graphics libraries, now enables embedded system designers to realise highly desirable user interfaces with a contemporary feel, but without incurring significant increases in system cost or development time.
Future Electronics