Porting littleVGL to STM32 (personal notes)

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

insert image description here

After downloading, get the lvgl-masterfolder.

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).

insert image description here

Delete the irrelevant code of main.c, leaving only the main.ccore code

insert image description here

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).

insert image description here

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.

insert image description here

After the copy is completed, rename the root directory of the source code lv_conf_template.hto lv_conf.h, this is the global configuration file of littleVGL, which is very important.

insert image description here

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 .cfiles 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 .cfile. . . It can only be said that the IDE of Keil is not humanized enough]

insert image description here


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]

insert image description here
insert image description here

I almost forgot, I just finished adding the .cfiles, 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.

insert image description here


Before, I was still considering whether to manage the header files in the subdirectories, but after the first failure, I found that lvgl.halmost 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).

insert image description here

The second change is to refer to the punctual atomic transplantation tutorial and change the dynamic memory size.

insert image description here

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:

  1. The upper-level directory to be lv_conf.hmoved to src/, that is, the current lv_conf.hupper-level directory;
  2. Or add macro declarations LV_CONF_INCLUDE_SIMPLEso that the compiler will look for all included header file pathslv_conf.h

insert image description here

I didn't want to move the structure of the source file and chose to add the macro declaration:

insert image description here

Compile again, there is an error, this is C99the error that will be reported after the addition, the solution is to add a type before the functionvoid

insert image description here

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.

insert image description here

I searched for a long time, but I couldn't find the reason. I looked at the Build Outinformation carefully and found that there are some xx_1.ofiles of the same class. I suspected that the same .cfile was added .crepeatedly. 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 .cfiles, the error is still reported. But later I reopened the Keil software and compiled it again, and it was successful. . I don't understand.

insert image description here

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.

insert image description here

Fill in Misc Controls--diag_suppress=68 --diag_suppress=111 --diag_suppress=550

insert image description here
insert image description here

Porting the underlying display driver

The underlying display driver file provided by littleVGL is GUI/examples/porting/under the path,

insert image description here

Create a new folder in the GUI folder lvgl_driverto store the underlying driver code,

insert image description here

Also rename them (remove _template)

insert image description here

Then add the source file and header file path to the Keil project

insert image description here

Make the lv_port_disp.hfollowing modifications:

insert image description here

Make the lv_port_disp.cfollowing modifications:

Enable, and add the driver header file of the display screen at the same time

insert image description here
Set the cache mode, I choose 10 lines of cache, the screen resolution I use is 320*480, so the line width is 320,

insert image description here

set resolution

insert image description here

Call the LCD fill function of the punctual atom

insert image description here

Porting the underlying touch driver

Make the lv_port_indev.hfollowing modifications:

insert image description here

Make the lv_port_indev.cfollowing modifications:

Enable, and add the driver header file of the touch screen at the same time

insert image description here
Initialize shielding of devices other than touchscreens

insert image description here

insert image description here

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"

insert image description here

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.

insert image description here

Then add the source and header files

insert image description here

Modify the interrupt service function of timer 3

insert image description here

Initialize in main()

insert image description here
Finally don't forget to add the timer firmware library

insert image description here

run demo

Open lv_conf.h, enable a demo (I have failed several tests), and enable it elsewhere

insert image description here

Find the location of the demo you just enabled

insert image description here

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)

insert image description here

Finally, perform the relevant initialization in main.c and run the demo at the same time:

insert image description here
Compile and burn

This is a stress test demo.

Please add image description

Guess you like

Origin blog.csdn.net/weixin_43772810/article/details/123588612