June 2011 Doc ID 16918 Rev 5 1/105
AN3128
Application note
STM32 embedded graphic objects/touchscreen library
Introduction
This library is a firmware package which contains a collection of routines, data structures,
and macros covering the main features of a graphic library and supporting a HID device to
interact with the graphic objects (touchscreen, joystick, and pushbutton).
The library is general purpose and can be executed on any CPU, 8/16/32-bit, to guarantee
the maximum portability of any architecture or LCD controller, and it provides a graphical
user interface (GUI) for any application that operates with a graphical LCD.
While the firmware library functions with all currently available STM32 microcontrollers,
(STM32F10xxx, STM32L1xx and STM32F2xx series), this document describes the
firmware library through the implementation of a graphic library for embedded systems
based on the STM32F10xxx microcontroller family.
It can easily be used in the user application without an in-depth study of STM32 registers,
SPI, and I
2
C read/write operation steps. As a result, using the firmware library saves
significant time that would otherwise be spent in coding, while at the same time reducing the
application development and integration costs.
The firmware architecture is developed in separate layers and the HAL (hardware
abstraction layer) makes it independent from the microcontroller used in the final
application.
A set of fonts is included: 8x12 and 16x24.
Even though the firmware library source code is developed in 'ANSI-C', the code
architecture follows an OOP (object oriented programming) approach.
Section 1 describes the document and library rules.
Section 2 highlights the features of the STMPE811 and explains its hardware interface with
a device microcontroller (STM32 in this case).
Section 3 and 4 describe the library features, its architecture and its exported APIs
(application programming interfaces) in detail.
Section 5 contains an example application source code describing how to configure and use
the library.
Section 6 contains information about the embedded GUI resource editor application.
www.st.com
Contents AN3128
2/105 Doc ID 16918 Rev 5
Contents
1 Document and library rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.1 Acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2 Touchscreen controller hardware description . . . . . . . . . . . . . . . . . . . 11
2.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3 STMPE811 functional overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.4 Touchscreen controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.5 Interfacing touchscreen with microcontroller with the STMPE811 via I2C 13
3 Multi-input embedded GUI library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2 Graphic object introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3 Library package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.4 Library architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.4.1 API layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.4.2 HAL layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4 Multi-input embedded GUI library firmware . . . . . . . . . . . . . . . . . . . . . 21
4.1 Graphic object API functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.1.1 NewLabel API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.1.2 NewButton API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.1.3 NewCheckbox API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.1.4 NewSwitch API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.1.5 NewIcon API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.1.6 NewRadioButtonGrp API global function . . . . . . . . . . . . . . . . . . . . . . . . 28
4.1.7 AddRadioOption API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.1.8 NewComboBoxGrp API global function . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.1.9 AddComboOption API global function . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.1.10 NewSlidebar API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.1.11 NewHistogram API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.1.12 NewGraphChart API global function . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.1.13 AddPageControlObj API global function . . . . . . . . . . . . . . . . . . . . . . . . 36