This post was last edited by qiao--- on 2024-1-22 02:27
Preface :
1. This evaluation is based on the previous evaluation project. If you have any questions, you can post questions or read the previous evaluation.
2. When I finished this interface, I had already exhausted the resources of this MCU. Why do I say that? Please see the picture below. I have used up its ROM. However, I am quite surprised that a 103RC series can run like this ACM.
In this review, I will show you how to use LVGL to make a mobile phone time interface, so that you can get familiar with the development steps of using LVGL. Let's take a look at the finished product first :
Video Demonstration:
IMG_8279
This small project is running in multiple tasks, and you can see that the green LED light is also flashing at a rate of 1s.
1. Implement RTC clock
To realize the time display, we cannot do without the clock function of RTC. We first implement the underlying driver part of RTC. The RTC of HAL library is relatively simple to implement.
We only need to set the current time in the following code. In fact, this part of the time setting is generally obtained from the network, parsing the JSON data in the network. There is no networked hardware on the board, so I set the current time manually.
After the RTC code is almost completed, we first verify on the serial port to see if the current time can be printed. The following is the program code for loop printing time.
Open the serial port to see if it can print normally. We can see that it can print normally, which means our RTC function has been successfully implemented.
2. Designing the LVGL interface
I designed the interface using GUI-Guider, which can directly generate C code. All we have to do in the end is port it to the project.
After entering GUI-Guider, we can directly select the latest version
Select the simulator, which will allow you to simulate and run the interface you wrote on VScode or other platforms.
Select an empty project
Next, we set the project path and the screen size to create it successfully.
I downloaded some icons from a website and took a screenshot of the EEworld logo. The picture is as follows
Under the project you created, you can directly drag and drop controls, adjust colors, and perform a series of operations, as shown in the figure below, which is my final creation result.
Next we can generate C code, click the icon in the upper right corner to generate
3. Transplant the generated C program
Let's first copy a copy of the lvgl+rtos project we evaluated before to facilitate our porting this time.
A series of files will be generated under our GUI-Guider, as shown in the figure below, and custom and generated are the two folders we need to transplant
We directly copy these two folders to the GUI/gui directory of our project
Open the project, include all .c files in our project, and add the header file path. At this time, my project directory is as follows
At this time, create a task and display our interface. The created task code is as follows
From now on, the lvgl interface designed by myself can be successfully displayed on the screen, but the time on it will not change, so we still need to modify some code.
4. Modify the lvgl code to display the time in real time
We classify this function as RTC. At this time, I just need to keep updating the time in the loop, so I define 3 character arrays to store the updated time.
Just add the following code to our serial port loop printing time code to update it in real time.
This review is now complete.
Summary : By programming the RTC function of ACM32 and cooperating with lvgl, a simple time interface can be designed. The RTC library of ACM32 is simple and easy to use, very friendly to novices, and the RTC routine program is very well written and has reference value.