当前位置:网站首页>Summary of the third course of weidongshan

Summary of the third course of weidongshan

2022-07-08 00:19:00 Seventeen 47

1 File browser & Digital photo frame

1.1 System framework of digital photo frame

   Introduce the requirements and design framework of the whole project , Last 33min Here is a simple explanation of why we need to write multiple processes 、 Multithreaded programs .

2.1 Digital photo frame - Character encoding

   speak ASCII code , Chinese code , A byte means ASCII code , Mainland Chinese generally uses two bytes , The world is unified unicode Encoding table , In three bytes .unicode Three bytes , Too wasteful , The solution is to evolve UTF-8 UTF-16LE( The small end ) UTF-16BE( Big end ) Equal representation Unicode Methods . UTF-16 use 16 Who said Unicode, That is, the high order is omitted .UTF-8 Not with 8 Who said Unicode, It's a way of changing the length , It can be big or small. , The most widely used , It will change the length according to whether it is English characters or Chinese .

It's just code , That is, what specific characters a binary corresponds to , But how can this character be displayed into different words through dot matrix , What font are these words , For example, Song typeface .
actually , Different Fonts , For example, Song typeface , Regular script, etc , Represents different font files ( Different lattice methods ), These font files also contain coding tables . That is to say, only one font file is needed in the end .

Source files are written in different coding methods , Can lead to different results , For example, Chinese expressions are different , Lead to printf The result is different , Therefore, the character set should be specified when compiling the program , The specific settings are in the video 48min, If not set , The default is UTF-8.

2.2 Digital photo frame - Dot matrix representation of characters

2.1 It is about how the computer recognizes the characters it represents through binary , For characters in LCD For the display on ,LCD It's pixel by pixel , A single pixel can only represent one color point , Cannot represent characters , Characters are usually represented by a combination of many pixels . stay Linux There are already files about character dot matrix representation in the kernel ,font_xx.c, such as font_8x16.c Represents a character with 8 ride 16 Pixels to represent , The illumination and extinction of these pixels form a character , So storing a character's lattice information requires 8 ride 16 bits , That is to say 16 Bytes , This information has been put in font_8x16.c in .

14min in the future , Programming begins , adopt LCD drive , stay LCD Display a character on , There are designs inside HZK16 Some uses of , It's a little difficult to output Chinese with dot matrix , It is suggested that you can use it , Don't look at the specific function implementation .43min How to pass from the beginning LCD A function of coloring a single pixel lcd_put_pixel.
The whole video is in LCD Drive on , I wrote a passage for LCD Driver application , The last part of the video is the test of this application .

2.3.1 Digital photo frame -freetype The theory is introduced

2.2 There is a disadvantage of displaying through dot matrix , That is, the size of each word is fixed , Cannot scale . Improved to vector font , Vector fonts only store the key nodes of fonts , Use mathematical curve when displaying ( Bessel curve ) Connect keys .

freeetype It's someone else's Library , Used to implement vector fonts , The video mainly introduces how to use this library .

2.3.3 Digital photo frame - stay LCD Display a vector font on the

6.1 Learn network programming in an hour

Why network programming : The output of our board is usually output through the serial port , If there are thousands of devices that need to print debugging information , Using serial port is too troublesome and difficult to manage ; And serial port printing is very slow , If there are too many devices that need to print information , The program will be slow ; And serial port printing is usually done during debugging , After debugging, it will be removed , In this way, if there is a problem in the actual operation , There is no error printing function , The solution is to print the information to another machine through network programming , Easy to observe at any time .

The so-called network programming , In fact, it is data transmission through the network . All data transmission can be summarized into three aspects : Sender 、 The receiving party 、 Transfer protocol . In network programming , The sender and receiver are generally servers and clients , The client actively initiates data transmission requests , The server passively responds to data transmission . The protocol for data transmission between the server and the client through the network is TCP perhaps UDP. Client and server actually refer to two programs , Client program and server program , These two programs can run on two machines ( Realize network transmission between two machines ), It can also run on the same machine ( Spontaneous self collection ).

TCP agreement : TCP The protocol is reliable , There will be some verification information , For example, three or four handshakes , If a frame transmission error is found through the verification mechanism, it will be retransmitted .TCP Before sending data, you need to establish a link between the server and the client .TCP The function calls involved in the protocol are summarized in 17:00
UDP agreement : UDP The agreement is unreliable , No verification information , Just keep passing .UDP There is no need to establish a link between the server and the client before sending data

7 libjpeg Use

Want to be in LCD Show pictures on , Need to put jpg Extract the pictures RGB data , And then put these RGB Put data into video memory , Decompression requires libjpeg This library .
The whole video explains how to use this library to display pictures , The video can finally be in LCD The picture is displayed on .

8.1 Digital photo frame function and program framework

10min The so-called object-oriented programming idea is explained left and right , combination C++ The idea of classes and objects ; Multithreading is used to prepare in advance under the current interface , Possible next steps .

8.2 Digital photo frame programming - First write the frame

10min The so-called object-oriented programming idea is explained left and right , combination C++ The idea of classes and objects ; Multithreading is used to prepare in advance under the current interface , Possible next steps ( Weidongshan himself did not realize pre prepared multithreading ), In addition, multithreading is also used to monitor the information sent by the touch screen .

8.3.1 Digital photo frame programming - The icon displays bmp Data Extraction

The main speak bmp Icon parsing , Find it on the Internet bmp The file is converted to the layout format after hexadecimal , then malloc A space , Will open bmp The pixel information at the corresponding position in the file is copied to the memory space . Note that this is the icon , It's not a picture , The icon of this project only supports bmp Format . The main procedure is bmp.c.

8.3.2 Digital photo frame programming - Zoom icon display

The icon is too big , Need to shrink . Online search image scaling algorithm , Chose the simplest , Nearest neighbor sampling interpolation method to scale the picture , The idea is to scale , Calculate the scaled coordinate information according to the scale , The zoom program is mainly in zoom.c.38min in the future , The reduced image requires less video memory , And our video memory is very large , The pixel information of multiple reduced pictures can be combined , And then put it into the video memory .

8.3.3 Digital photo frame programming - Icon display test

Test the program written in the first two sections , Pay attention to his operation steps , adopt shell Pass the open file name to main, open bmp After the document passed mmap Map files to memory , Then zoom and display through the program written in the first two sections . The latter half of the videos are debugging and compiling .

8.4.1 Digital photo frame programming -MainPage Video memory management

Write LCD Driver , A fixed memory will be allocated in the memory for storing pixel data , be called framebuffer,LCD The controller will automatically framebuffer Take out the data in and send it to LCD, So as to display . For applications , To open the first LCD The driver , obtain framebuffer The address of , Then the pixel data can be written directly to framebuffer in , But if the system runs slowly , This will cause the displayed picture to be too laggy ( Why the card , It's because it's directly to framebuffer Write data in , It's written line by line , The program first opens the picture file from external memory , Parse it , Pixel data , Then the pixel data memcopy To the memory , Then write byte by byte from memory through cyclic statements framebuffer).

The way to improve is to malloc One piece and framebuffer The same amount of memory , Write the pixel data in advance malloc The memory of the , When it needs to be displayed, the whole malloc Memory through memcopy copy to framebuffer, Such a one-time copy , Will be faster . further , We can apply for several pieces framebuffer Size of memory , Store several required pages at the same time , Use a linked list to store the addresses of these spaces , Only when a page is displayed for the first time , You need the corresponding malloc Draw pixels in memory , Not the second time , It will be much faster , similar tlb Thought .

The assembly is in disp_manager.c Medium AllocVideoMem()、GetVideoMem();render.c Medium FlushVideoMemToDev()

8.4.2 Digital photo frame programming -MainPage Page planning

Plan the location of the three icons in the main interface , And display . The assembly is in render.c Medium GetPixelDatasForIcon()、file.c Medium MapFile()、page_manager.c Inside GeneratePage()

8.4.3 Digital photo frame programming -MainPage Input function

原网站

版权声明
本文为[Seventeen 47]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/189/202207072220428481.html