Refer to the LittleVGL porting tutorial for self-punctual atoms
Originally, I wanted to get started with littleVGL directly and quickly. The porting tutorial of Punctual Atomic is very good, but the version is V6.0 (now updated to V8.3), and I want to port the latest version, so I tested the water all the way, and the porting took a lot of time. I have encountered a lot of pits for most of the day. The following describes the process of my transplantation (the general steps are the same as those of punctual atoms, but the details are slightly different), for reference only.
Download littleVGL source code
The official website of littleVGL is: https://littlevgl.com
The github of littleVGL is: https://github.com/littlevgl/lvgl
The online documentation of littleVGL is: https://docs.littlevgl.com/zh-CN /html/index.html
I went directly to github to download the latest version of the source code, the current latest version is V8.3
After downloading, get the lvgl-master
folder.
Preparing for the Keil project
Here is the same as the Punctuality Atomic Transplantation Tutorial, using the Punctual Atom touch screen experimental project as the project template (you can download it from the Punctual Atomic Data Download Center).
Delete the irrelevant code of main.c, leaving only the main.c
core code
Import the littleVGL library into Keil
Create two folders in the root directory of the Keil project, GUI/ is used to store the littleVGL source code, and GUI_APP/ is used to store the image application (currently empty).
Copy the source code
punctual atomic tutorial only copied two folders to the Keil directory, but the source code directory structure of the latest version and V6.0 has changed a lot. To be on the safe side, I copied all the littleVGL files I just downloaded to the GUI folder (failed to transplant Experience summed up after many times~~) [However, the size of all files is 100M (of which demo/ accounts for 50M). If you want to reduce the space occupied by the project later, you can delete some files, but for the first transplant, just copy it all. 】
After the copy is completed, rename the root directory of the source code lv_conf_template.h
to lv_conf.h
, this is the global configuration file of littleVGL, which is very important.
The Keil directory modification is completed. Next, you need to add source files to the Keil project, create two new groups in the project directory structure, name GUI and GUI_APP, and then add src/
all the .c
files in the source directory to the GUI group (note that all! including files in subdirectories .c
). [This is a torturous job, because there are a lot of subdirectories, especially some subdirectories have multiple subdirectories, and many subdirectories are just one .c
file. . . It can only be said that the IDE of Keil is not humanized enough]
Be sure to add files carefully. For the first time, I reported various inexplicable errors because I added less source files.
After adding the file, we still need to do two more important small operations, increase the stack space of the project to 2KB and enable the C99 compiler function
. [I don't know why, the tutorial stipulates this, just follow it]
I almost forgot, I just finished adding the .c
files, but didn't declare their header file paths. Continue to use the magic wand to add the header file paths. The following two are enough, and the others need to be added later.
Before, I was still considering whether to manage the header files in the subdirectories, but after the first failure, I found that lvgl.h
almost all the header files in the source code root directory have been included, which is why I chose to copy the complete source code to The reason for the Keil project directory is that the province will be lost.
Modify lv_conf.h
This is a global configuration file with many configuration items, which is dazzling. In fact, this file does not need to be modified, at least I have not changed much (of course #if 0 must be changed).
The second change is to refer to the punctual atomic transplantation tutorial and change the dynamic memory size.
At this point, we compiled the Keil project and found that a lot of reports were not found lv_conf.h
. There are two solutions:
- The upper-level directory to be
lv_conf.h
moved tosrc/
, that is, the currentlv_conf.h
upper-level directory; - Or add macro declarations
LV_CONF_INCLUDE_SIMPLE
so that the compiler will look for all included header file pathslv_conf.h
I didn't want to move the structure of the source file and chose to add the macro declaration:
Compile again, there is an error, this is C99
the error that will be reported after the addition, the solution is to add a type before the functionvoid
I thought this was the last error, but I didn't expect that there would be errors in recompiling, and errors that were not encountered in the last successful transplant.
I searched for a long time, but I couldn't find the reason. I looked at the Build Out
information carefully and found that there are some xx_1.o
files of the same class. I suspected that the same .c
file was added .c
repeatedly. I thought it was very strange when I added the file. I used to add it repeatedly. (Keil has a bug). After deleting some duplicated .c
files, the error is still reported. But later I reopened the Keil software and compiled it again, and it was successful. . I don't understand.
But there are 19 warnings. There is one step in the punctual atomic transplantation tutorial to eliminate the warning. Although it is not the same as the warning I encountered, I tried it and it has a little effect, and the warning is less.
Fill in Misc Controls
--diag_suppress=68 --diag_suppress=111 --diag_suppress=550
Porting the underlying display driver
The underlying display driver file provided by littleVGL is GUI/examples/porting/
under the path,
Create a new folder in the GUI folder lvgl_driver
to store the underlying driver code,
Also rename them (remove _template)
Then add the source file and header file path to the Keil project
Make the lv_port_disp.h
following modifications:
Make the lv_port_disp.c
following modifications:
Enable, and add the driver header file of the display screen at the same time
Set the cache mode, I choose 10 lines of cache, the screen resolution I use is 320*480, so the line width is 320,
set resolution
Call the LCD fill function of the punctual atom
Porting the underlying touch driver
Make the lv_port_indev.h
following modifications:
Make the lv_port_indev.c
following modifications:
Enable, and add the driver header file of the touch screen at the same time
Initialize shielding of devices other than touchscreens
The touch screen driver modification is relatively simple, only need to add two parts of the underlying code "judging whether to press" and "getting the coordinates of the press"
Add GUI heartbeat beats
There is no timer function code in the punctual atomic touch screen experiment, and it needs to be added. In this section, we timer/
copy the folder of the timer experiment to our project.
Then add the source and header files
Modify the interrupt service function of timer 3
Initialize in main()
Finally don't forget to add the timer firmware library
run demo
Open lv_conf.h
, enable a demo (I have failed several tests), and enable it elsewhere
Find the location of the demo you just enabled
Add source files to the project. Since the header files of the entire source code are included in the project, if you want to use the functions in the demo, you only need to include a header file with an absolute path (as shown below)
Finally, perform the relevant initialization in main.c and run the demo at the same time:
Compile and burn
This is a stress test demo.