当前位置:网站首页>Summary of the third course of weidongshan
Summary of the third course of weidongshan
2022-07-08 00:19:00 【Seventeen 47】
Summary of the third course of weidongshan
- 1 File browser & Digital photo frame
- 1.1 System framework of digital photo frame
- 2.1 Digital photo frame - Character encoding
- 2.2 Digital photo frame - Dot matrix representation of characters
- 2.3.1 Digital photo frame -freetype The theory is introduced
- 2.3.3 Digital photo frame - stay LCD Display a vector font on the
- 6.1 Learn network programming in an hour
- 7 libjpeg Use
- 8.1 Digital photo frame function and program framework
- 8.2 Digital photo frame programming - First write the frame
- 8.3.1 Digital photo frame programming - The icon displays bmp Data Extraction
- 8.3.2 Digital photo frame programming - Zoom icon display
- 8.3.3 Digital photo frame programming - Icon display test
- 8.4.1 Digital photo frame programming -MainPage Video memory management
- 8.4.2 Digital photo frame programming -MainPage Page planning
- 8.4.3 Digital photo frame programming -MainPage Input function
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
边栏推荐
- Smart regulation enters the market, where will meituan and other Internet service platforms go
- Set up personal network disk with nextcloud
- Handwriting a simulated reentrantlock
- Trust orbtk development issues 2022
- QT creator add JSON based Wizard
- Vscode software
- The underlying principles and templates of new and delete
- After going to ByteDance, I learned that there are so many test engineers with an annual salary of 40W?
- 3 years of experience, can't you get 20K for the interview and test post? Such a hole?
- DNS 系列(一):为什么更新了 DNS 记录不生效?
猜你喜欢
[basis of recommendation system] sampling and construction of positive and negative samples
关于组织2021-2022全国青少年电子信息智能创新大赛西南赛区(四川)复赛的通知
2022-07-07:原本数组中都是大于0、小于等于k的数字,是一个单调不减的数组, 其中可能有相等的数字,总体趋势是递增的。 但是其中有些位置的数被替换成了0,我们需要求出所有的把0替换的方案数量:
【编程题】【Scratch二级】2019.12 绘制十个正方形
去了字节跳动,才知道年薪 40w 的测试工程师有这么多?
STM32F1與STM32CubeIDE編程實例-旋轉編碼器驅動
Reptile practice (VIII): reptile expression pack
第四期SFO销毁,Starfish OS如何对SFO价值赋能?
[研发人员必备]paddle 如何制作自己的数据集,并显示。
Automated testing: robot framework is a practical skill that 90% of people want to know
随机推荐
[programming problem] [scratch Level 2] draw ten squares in December 2019
[basis of recommendation system] sampling and construction of positive and negative samples
Notice on organizing the second round of the Southwest Division (Sichuan) of the 2021-2022 National Youth electronic information intelligent innovation competition
Use filters to count URL request time
redis你到底懂不懂之list
"An excellent programmer is worth five ordinary programmers", and the gap lies in these seven key points
全自动化处理每月缺卡数据,输出缺卡人员信息
某马旅游网站开发(登录注册退出功能的实现)
Seven years' experience of a test engineer -- to you who walk alone all the way (don't give up)
每日刷题记录 (十六)
The function is really powerful!
ROS from entry to mastery (IX) initial experience of visual simulation: turtlebot3
商品的设计等整个生命周期,都可以将其纳入到产业互联网的范畴内
Development of a horse tourism website (optimization of servlet)
Trust orbtk development issues 2022
华为交换机S5735S-L24T4S-QA2无法telnet远程访问
Linkedblockingqueue source code analysis - add and delete
Using Google test in QT
Vscode software
limit 与offset的用法(转载)