SPMA082 August   2021 TM4C1230C3PM , TM4C1230D5PM , TM4C1230E6PM , TM4C1230H6PM , TM4C1231C3PM , TM4C1231D5PM , TM4C1231D5PZ , TM4C1231E6PM , TM4C1231E6PZ , TM4C1231H6PGE , TM4C1231H6PM , TM4C1231H6PZ , TM4C1232C3PM , TM4C1232D5PM , TM4C1232E6PM , TM4C1232H6PM , TM4C1233C3PM , TM4C1233D5PM , TM4C1233D5PZ , TM4C1233E6PM , TM4C1233E6PZ , TM4C1233H6PGE , TM4C1233H6PM , TM4C1233H6PZ , TM4C1236D5PM , TM4C1236E6PM , TM4C1236H6PM , TM4C1237D5PM , TM4C1237D5PZ , TM4C1237E6PM , TM4C1237E6PZ , TM4C1237H6PGE , TM4C1237H6PM , TM4C1237H6PZ , TM4C123AE6PM , TM4C123AH6PM , TM4C123BE6PM , TM4C123BE6PZ , TM4C123BH6PGE , TM4C123BH6PM , TM4C123BH6PZ , TM4C123BH6ZRB , TM4C123FE6PM , TM4C123FH6PM , TM4C123GE6PM , TM4C123GE6PZ , TM4C123GH6PGE , TM4C123GH6PM , TM4C123GH6PZ , TM4C123GH6ZRB , TM4C1290NCPDT , TM4C1290NCZAD , TM4C1292NCPDT , TM4C1292NCZAD , TM4C1294KCPDT , TM4C1294NCPDT , TM4C1294NCZAD , TM4C1297NCZAD , TM4C1299KCZAD , TM4C1299NCZAD , TM4C129CNCPDT , TM4C129CNCZAD , TM4C129DNCPDT , TM4C129DNCZAD , TM4C129EKCPDT , TM4C129ENCPDT , TM4C129ENCZAD , TM4C129LNCZAD , TM4C129XKCZAD , TM4C129XNCZAD


  1.   Trademarks
  2. 1TFT LCD Overview
    1. 1.1 Typical Interfaces
    2. 1.2 Frame Buffer
      1. 1.2.1 Frame Buffer Size Calculation
    3. 1.3 Frame Rate (FPS)
    4. 1.4 Touch Display
  3. 2LCD Controller Overview
    1. 2.1 Block Diagram
      1. 2.1.1 Raster Controller
      2. 2.1.2 LIDD Controller
  4. 3TivaWare Graphics Library (grlib)
    1. 3.1 Graphics Library Structure
      1. 3.1.1 Display Driver Overview
      2. 3.1.2 Low-Level Primitive Graphics API Overview
      3. 3.1.3 Widget API Overview
      4. 3.1.4 Input Driver Overview
  5. 4Display Driver Adaptation
    1. 4.1 Off-Screen Display Drivers
    2. 4.2 Individual Display Driver Functions
      1. 4.2.1 Init
      2. 4.2.2 ColorTranslate
      3. 4.2.3 PixelDraw
      4. 4.2.4 PixelDrawMultiple
      5. 4.2.5 LineDrawH
      6. 4.2.6 LineDrawV
      7. 4.2.7 RectFill
      8. 4.2.8 Flush
  6. 5Fonts
    1. 5.1 Creating Custom Fonts for Different Languages
  7. 6Useful Utilities
    1. 6.1 Pnmtoc
    2. 6.2 mkstringtable and ftrasterize
  8. 7References
  9.   A Appendix A

Display Driver Adaptation

The lowest level of the graphics library stack is the display driver. Although the display driver API is specified by the graphics library, the source is specific to the board and display hardware and can be found in the C:\ti\TivaWare_C_Series-\examples\boards\<board>\drivers directory. The driver source file name is typically derived from the display manufacturer, supported display controller part, display resolution, and bit depth. For example, the display driver for the dk-tm4c129x is named Kentec320x240x16_ssd2119.c since it supports a Kentec display using an SSD2119 controller and offers 320 x 240 resolution at 16 bits per pixel. The display driver for the SPI-based BOOSTXL-K350QVG-SI BoosterPack to be used on the EK-TM4C1294XL LaunchPad is named Kentec320x240x16_ssd2119_spi.c.

The display driver’s responsibility is to translate calls made to the standard display driver API into orders to draw pixels or lines on the display. The interface to the driver is intended to offer the absolute minimum subset of drawing orders required to support the main graphics library and, as a result, make it extremely straightforward to develop a driver for a new display very quickly.

The display driver API includes the following basic functions that must be supported by every display driver:

static void
PixelDraw(void *pvDisplayData, int32_t i32X,
                               int32_t i32Y, uint32_t ui32Value)

static void
PixelDrawMultiple(void *pvDisplayData, int32_t i32X,
                                       int32_t i32Y, int32_t i32X0,
                                       int32_t i32Count, int32_t i32BPP,
                                       const uint8_t *pui8Data,
                                       const uint8_t *pui8Palette)

static void
LineDrawH(void *pvDisplayData, int32_t i32X1,
                               int32_t i32X2, int32_t i32Y,
                               uint32_t ui32Value)

static void
LineDrawV(void *pvDisplayData, int32_t i32X,
                               int32_t i32Y1, int32_t i32Y2,
                               uint32_t ui32Value)

static void
RectFill(void *pvDisplayData, const tRectangle *psRect,
                              uint32_t ui32Value)

static uint32_t
ColorTranslate(void *pvDisplayData, uint32_t ui32Value)

static void
2119Flush(void *pvDisplayData)

The actual names of these functions are not important since they are provided to the graphics library by means of a function pointer table. This can be found in the tDisplay structure that the display driver exports and that the applications uses when calling the graphics API function.

const tDisplay g_sKentec320x240x16_SSD2119 =
#if defined(PORTRAIT) || defined(PORTRAIT_FLIP)

Additionally, the display driver typically provides an initialization function (Kentec320x240x16_SSD2119Init()) that the application is expected to call prior to initializing the graphics library. This call is used to initialize the underlying graphics hardware and clear the screen.

Notice that the driver API contains significantly fewer graphics primitives than the low-level graphics API. Most graphics primitives are broken down by the higher-level code and passed to the driver in pieces. For example, an unfilled rectangle is drawn using two calls to the LineDrawV function and two calls to the LineDrawH function. Similarly, text is rendered using multiple calls to the PixelDraw and LineDrawH functions. This model works well with small, low-cost displays which do not typically include any graphics acceleration hardware but do often include the ability to choose drawing direction and copy lines of pixels.

The other higher-level feature carried out by the low-level graphics layer on behalf of the display driver is clipping. No coordinates that are outside the bounds of the display are ever passed to the display driver since this is checked for and handled in the layer above. Using this approach, it becomes quick and easy to produce a new graphics driver since only a small number of simple functions need to be developed.