The class library that will be used in this section is:
-
LCD_DISCO_F429ZI - Class library to drive the 800 x 480 TFT LCD display present on the DISCO-F469NI board.
As this library requires additional board support (BSP) files, it can be a bit tricky importing the correct libraries as you are accustomed to. The easiest method is:
-
Create a new program
-
Select DISCO-F469NI from the Platform list (make sure that you add the platform to your compiler beforehand)
-
Select Basic example showing how to drive the LCD from the Template list.
-
Type a name for the program and click OK.
This will ensure that all the required libraries are automatically added to the program.
The following example programs will demonstrate the principles of using the LCD_DISCO_F469NI class library (an explanation to the library functions follows at the end of this page):
The class library functions that were used in the above examples can be summarized as follows:
Colors in the library are described in ARGB(8-8-8-8) format (e.g. 0xFF0000FF for BLUE) or by using the following color constants:
LCD_COLOR_BLUE
LCD_COLOR_GREEN
LCD_COLOR_RED
LCD_COLOR_CYAN
LCD_COLOR_MAGENTA
LCD_COLOR_YELLOW
LCD_COLOR_LIGHTBLUE
LCD_COLOR_LIGHTGREEN
LCD_COLOR_LIGHTRED
LCD_COLOR_LIGHTCYAN
LCD_COLOR_LIGHTMAGENTA
LCD_COLOR_LIGHTYELLOW
LCD_COLOR_DARKBLUE
LCD_COLOR_DARKGREEN
LCD_COLOR_DARKRED
LCD_COLOR_DARKCYAN
LCD_COLOR_DARKMAGENTA
LCD_COLOR_DARKYELLOW
LCD_COLOR_WHITE
LCD_COLOR_LIGHTGRAY
LCD_COLOR_GRAY
LCD_COLOR_DARKGRAY
LCD_COLOR_BLACK
LCD_COLOR_BROWN
LCD_COLOR_ORANGE
LCD_COLOR_TRANSPARENT
SetFont(sFONT *pFonts)
Sets the text font.
Parameters:
pFonts - The font to be used based on the pixel height of the characters. Options are: &Font8, &Font12, &Font16, &Font20, &Font24
SetTextColor(uint32_t Color)
Sets the foreground color for the text.
Parameters:
Color - the color constant or code ARGB(8-8-8-8)
SetBackColor(uint32_t Color)
Sets the background color for the text.
Parameters:
Color - the color constant or code ARGB(8-8-8-8)
Clear(uint32_t Color)
Clears the LCD by filling it with the required color.
Parameters:
Color - the color constant or code ARGB(8-8-8-8)
DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii)
Displays one character at a x,y position on the LCD.
Parameters:
Xpos - x position (in pixel)
Ypos - y position (in pixel). You can also make use of the LINE(linenum) function to convert the linenum value to pixel format to use as the Ypos parameter in the DisplayChar function. The number of lines available are dependant on the font being used.
Ascii - character ascii code (must be between 0x20 and 0x7E).
DisplayStringAt(uint16_t X, uint16_t Y, uint8_t *pText, Text_AlignModeTypdef mode)
Displays a string of maximum 60 characters at a x,y position on the LCD.
Parameters:
X - x position (in pixel)
Y - y position (in pixel). You can also make use of the LINE(linenum) function to convert the linenum value to pixel format to use as the Y parameter in the DisplayStringAt function. The number of lines available are dependant on the font being used.
pText - pointer to string to display on LCD
mode - the string alignment mode. Options are: CENTER_MODE, RIGHT_MODE, LEFT_MODE
DisplayStringAtLine(uint16_t Line, uint8_t *ptr)
Displays a string of maximum of 20 characters on a specific line on the LCD.
Parameters:
Line - the line where to display the string. The number of lines available are dependant on the font being used.
ptr - pointer to string to display on LCD
ClearStringLine(uint16_t Line)
Clears the selected line on the LCD.
Parameters:
Line - the line to be cleared
DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code)
Draws a pixel on the LCD.
Parameters:
Xpos - the x position
Ypos - the y position
RGB_Code - the pixel color constant or code ARGB(8-8-8-8)
ReadPixel(uint16_t Xpos, uint16_t Ypos)
Reads a pixel on the LCD.
Parameters:
Xpos - the x position
Ypos - the y position
Returns:
The pixel color constant or code ARGB(8-8-8-8) at the x,y coordinate
DrawHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
Displays a horizontal line.
Parameters:
Xpos - the x position
Ypos - the y position
Length - the line length
DrawVLine(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
Displays a vertical line.
Parameters:
Xpos - the x position
Ypos - the y position
Length - the line length
DrawLine(uint16_t X1, uint16_t Y1, uint16_t X2, uint16_t Y2)
Displays an uni-line (between two points) using the current text color.
Parameters:
X1 - the point 1 X position
Y1- the point 1 Y position
X2 - the point 2 X position
Y2- the point 2 Y position
DrawRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
Displays a rectangle using the current text color.
Parameters:
Xpos - the x position (left)
Ypos - the y position (top)
Width - rectangle width
Height- rectangle height
FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
Displays a filled rectangle using the current text color.
Parameters:
Xpos - the x position (left)
Ypos - the y position (top)
Width - rectangle width
Height- rectangle height
DrawCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
Displays a circle using the current text color.
Parameters:
Xpos - the x position
Ypos - the y position
Radius - the circle radius
FillCircle(uint16_t Xpos, uint16_t Ypos, uint16_t Radius)
Displays a filled circle using the current text color.
Parameters:
Xpos - the x position
Ypos - the y position
Radius - the circle radius
DrawEllipse(uint16_t Xpos, uint16_t Ypos, int XRadius, int YRadius)
Displays an ellipse using the current text color.
Parameters:
Xpos - the x position
Ypos - the y position
XRadius - the X radius of ellipse
YRadius - the Y radius of ellipse
FillEllipse(uint16_t Xpos, uint16_t Ypos, int XRadius, int YRadius)
Displays a filled ellipse using the current text color.
Parameters:
Xpos - the x position
Ypos - the y position
XRadius - the X radius of ellipse
YRadius - the Y radius of ellipse
FillTriangle(uint16_t X1, uint16_t X2, uint16_t X3, uint16_t Y1, uint16_t Y2, uint16_t Y3)
Displays a filled triangle using the current text color.
Parameters:
X1 - the point 1 X position
X2 - the point 2 X position
X3 - the point 3 X position
Y1 - the point 1 Y position
Y2 - the point 2 Y position
Y3 - the point 3 Y position
DrawPolygon(pPoint Points, uint16_t PointCount)
Displays a poly-line (between many points) using the current text color.
Parameters:
Point - pointer to the points array
PointCount - Number of points
FillPolygon(pPoint Points, uint16_t PointCount)
Displays a filled poly-line (between many points) using the current text color.
Parameters:
Point - pointer to the points array
PointCount - Number of points