LkdGui is a graphical library designed for monochrome displays. It's used in the industrial control field for the simple and beautiful graphic interface. Its source code is written in C language and conforms to the C99 standard. LkdGui contains commonly used graphical functions to drawing points, lines, rectangles, text display, button widgets and progress bars. It uses 'Windows' for unified management and scheduling of widgets, making the display modules lowly coupled and beneficial to application development.
The presentation video is posting on RT-Thread Youtube Channel!
LkdGui Source Code
lkdGui_source file: lkdGui all source code.
A. include file: It contains all the header files of GUI. This path should be added to the project when porting to a new platform.
- lkdGui.h: This file contains all the Gui function interfaces. This header file should be included when using the Gui functions.
- lkdGuiConfig.h: This file is used to configure and tailor Gui.
- lkdGuiTypedef.h: This file defines the GUI-related data structures that you don’t have to read it.
B. portFile: This file contains the porting files.
- fontDriver File: It includes commonly used font library, font library chip driver, and so on. You can add font-related drivers here.
- lcdDriverPort File: It contains a commonly-used LCD drive. You can add the LCD-related drive into here.
- lcdDriverPort.c: LCD drive porting interfaces of Gui. You can add the relevant functions inside.
- userFontPort.c: Font-driven porting interface of GUI. You can add the relevant functions inside.
- userAppPort.c: This input application layer, which contains initialization functions, window management functions and others. You can write the application here.
C. source file: Gui drawing function, window management function and other related functions to implement the source code.
The font porting interface contains fontDriver folder and userFontPort.c. The porting process is as follows:
A. You should look at the fontDriver folder to see if there is a font library or font library chip driver you want. If not you need to add it.
B. Then modify userFontPort.c. Fill in the related functions in this file.
- GetDfontData() This function is used to obtain a font model. The font library should contain a function that gets the font model, which can be called with this function.
- GetSfontData() This function is used to obtain the ASCII code model, such as GetDfontData ().
- Using lkdFont structure object to declare your own font->initialization->use GuiFontSet() as the system default font.
LCD Porting interface contains lcdDriverPort folder and lcdDriverPort.c. The porting process is as follows:
A. You should look at the lcdDriverPort folder to see if there has the LCD driver you want. If not you need to add it.
B. Then modify lcdDriverPort.c. Fill in the related functions in this file. (Some functions can be filled in as you need). Here are the required functions need to be fill in:
- GuiUpdateDisplayAll(): This function is used to flush cached data to the LCD.
- GuiDrawPoint(): Draw a point at the fixed position of the LCD.
Modify lkdGuiConfig.h in the LCD size related macro GUI_LCM_XMAX, GUI_LCM_YMAX.
User interface: Available user interface functions are included in lkdGui.h. userAppPort.c is a template that you can use.
lkdGui Window Introduction
LkdGui uses windows as a management and scheduling unit. All user drawings should be included in a specific window.
1、The GUIWINMANAGE_NUM in lkdGuiConfig.h is used to modify the maximum number of nested windows.
2、You should use it to initialize window-related resources when powering on GuiWinInit() systems.
3、GuiWinDisplay() is a window scheduling function that requires programs to execute all the time.
4、lkdWin is the structure of the window. Use it to create any number of window entity objects. lkdWin-WindowsFunction() is an interface for users to draw in this window, etc.
5、The GuiWinAdd() function is used to add window entity objects of the lkdWin structure to the window scheduling stack.
6、The GuiWinDeleteTop() function is used to remove the top window entity object from the window scheduling stack.
7、The GuiGetTopWin() function gets the window( the currently displayed window) at the top of the window scheduling stack.
The menu is a distinctive widget in lkdGui and is often used in industrial control.
LkdGui Font Introduction:
You can add a number of font libraries into LkdGui, using the GuiFontSet() function to switch among them at runtime. Use the GetCurrentFont() function can get the current font pointer;
Other Controls & Drawing Functions: Please refer to lkdGui.h. for detailed instructions.
How to Use lkdGui on RT-Thread:
Users can simply select lkdGui in the RT-Thread management tool env.
RT-Thread ENV User Manual
The following image shows the location of lkdGui in menuconfig:
Obtain lkdGui Source Code:
For more information about RT-Thread RTOS: github.com/RT-Thread
RT-Thread Contact Info: