[GD32E503 Review]——step04. Domestic M33 for uCgui transplantation
[Copy link]
Embedded GUIs include: MicroWindows, MiniGui, QT for MCU, GTK+, OpenGUI, FLTK, EFL (Enlightenment Foundation Libraries), AWTK (Toolkit AnyWhere), Wayland/Weston , SDL (Simple DirectMedia Layer), DirectFB , LittlevGL , Nuklear, touchGFX, uGFX, emWIN, uCgui and other GUI frameworks. This article focuses on the porting of uCgui.
【uCgui Background Introduction】
When people who work on embedded systems in China start to learn OS, they should all choose uC/OS. Why? Because the code is open source and there is a lot of information. Because of uC/OS, everyone must have come into contact with the uC/GUI embedded graphics software library. In fact, the core code of uC/Gui is not developed by Micrium, but a graphics software library customized by Segger for Micrium, and of course it is also developed based on Segger's emwin graphics software library. So uC/GUI is actually a simplified version of emwin.
In the older versions of the program, the source code of uC/Gui was open source (can be found on the Internet), but the new versions of the program emWin and uC/gui only provide library files to users and are not open source.
In addition to providing customized uC/GUI versions to Micrium, Segger also provides customized services to other IC manufacturers. For example, it sold the copyright of emWin to ST, so ST also obtained a customized version of emWin and changed its name to STemWin. When users use the emWin software library on STM32 chips, they do not need to pay emWin or ST. NXP also uses the emWin graphics library, and people do not need to pay when using NXP chips.
In a word, uC/GUI and STemWin are both emWin products of Segger, and their version numbers are unified. For example, the latest version of uC/GUI is named uC-GUI V5.24, the latest version of STemWin is named STemWin Library V5.24, and the latest version of emWin is emWin V5.24. Therefore, to compare the functional differences of these three software libraries, you only need to look at their version numbers.
【uCgui transplantation preparation】
First, run the official demo example directly. The touch LCD sample has implemented the initialization of exmc, spi and related peripherals, and added a 320 * 240 size LCD driver interface. So start with the example to get familiar with the principle of driving LCD. After running the example, the screen displays as follows:
Several buttons are shown above. When you touch the corresponding button, you can see the indicator LED on the board have corresponding display feedback.
【uCgui transplantation steps】
After running the official routines, I have become familiar with the principles and implementations of each driver interface. Next, I will officially proceed with the porting of uCgui.
Step 1: Get the source code package of uCgui 3.90a through the official website or other resource channels. The official website may only open the lib package instead of the source code. The following is the source code directory structure:
Items marked with "*" are optional and may differ in different versions.)
Note: When porting, special attention should be paid to the configuration files Config and GUI/LCDDriver.
①. The GUI/LCDDriver folder contains some LCD driver codes. If you are using an LCD, you can find the codes here. You can directly use the following code in LCDConfig.h in Config:
#define LCD_CONTROLLER -1 // -1: Indicates that no LCD driver is selected, but the sample program inside is used for modification.
Which LCDs are supported by uCGUI? You can refer to Chapter 22 LCD Driver in the uCGUI User Manual. It explains in detail which LCD controllers are supported.
②. In the project, you only need to load the required LCD driver code file. If it is set to -1, select to load the LCDDummy.C or LCDTemplate.C file (the file name of this code may be different for different versions).
Step 2: After obtaining the source code package, add all related files to the project and add the relevant compilation path. The project structure is as follows:
Step 3: The following driver functions of the LCD in LCDDummy.C must be written. The underlying driver needs to include the following functions:
①. LCD_INIT_CONTROLLER() : LCD initialization function.
②. LCD_SetPixel(): LCD dot drawing function.
③. LCD_GetPixel(): LCD pixel reading function.
Step 4: Modify the configuration .h file of GUI_config as needed. The touch and OS functions will not be transplanted for the time being. The configuration is as follows:
Step 6: Copy the files in the GUI_X folder in the example:
①.GUI_X.C: No system
②. GUI_X_embOS.C: embOS system
③. GUI_X_uCOS.C: uCOS system
Add different files according to different conditions. If you add files without a system, ①, otherwise add files according to the system, or write files. Special instructions for the following functions:
a. int GUI_X_GetTime(void);
This function calls the system time. If your system has a real-time clock or something like that, you can put the real-time clock driver here. If not, it doesn't matter. It's just that the functions related to calling the system time cannot be used. Maybe many people will not use this function.
b. void GUI_X_Delay(int Period);
This function is used for GUI delay. Since there is no running system, I wrote a delay program manually. Other functions can be left blank.
Step 7: At the application level, you need to initialize the MCU-related clock and LCD peripheral interface driver first, then complete GUI_Init and write the application according to the API manual. Here, the character display comparison of different sizes, colors, and positions is implemented, and a simple progress bar function is also implemented:
【Conclusion of uCgui transplantation experiment】
After porting the uCgui library, we will complete a simple progress bar display test. Later, we can add uCos and touch driver functions, and use uC tools to quickly build the UI interface to simplify the complexity of C language programming.
进度条显示.mp4
(1.29 MB, downloads: 13)
Project_GD32E50x_LCD_uCgui_V1.0.rar
(1.66 MB, downloads: 27)
|