当前位置:网站首页>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
边栏推荐
- 【编程题】【Scratch二级】2019.09 绘制雪花图案
- How to measure whether the product is "just needed, high frequency, pain points"
- Su embedded training - day4
- 攻防世界Web进阶区unserialize3题解
- 【编程题】【Scratch二级】2019.12 飞翔的小鸟
- 【转载】解决conda安装pytorch过慢的问题
- 动态库基本原理和使用方法,-fPIC 选项的来龙去脉
- 单机高并发模型设计
- 他们齐聚 2022 ECUG Con,只为「中国技术力量」
- Cmake learning notes (1) compile single source programs with cmake
猜你喜欢

Single machine high concurrency model design

52歲的周鴻禕,還年輕嗎?

Using Google test in QT

Seven years' experience of a test engineer -- to you who walk alone all the way (don't give up)
![[programming problem] [scratch Level 2] 2019.09 make bat Challenge Game](/img/81/c84432a7d7c2fe8ef377d8c13991d6.png)
[programming problem] [scratch Level 2] 2019.09 make bat Challenge Game

C# 泛型及性能比较

Smart regulation enters the market, where will meituan and other Internet service platforms go

Notice on organizing the second round of the Southwest Division (Sichuan) of the 2021-2022 National Youth electronic information intelligent innovation competition

DNS 系列(一):为什么更新了 DNS 记录不生效?

Kubectl's handy command line tool: Oh my Zsh tips and tricks
随机推荐
Tools for debugging makefiles - tool for debugging makefiles
52岁的周鸿祎,还年轻吗?
Tencent security released the white paper on BOT Management | interpreting BOT attacks and exploring ways to protect
The difference between -s and -d when downloading packages using NPM
某马旅游网站开发(登录注册退出功能的实现)
【编程题】【Scratch二级】2019.12 飞翔的小鸟
C language 001: download, install, create the first C project and execute the first C language program of CodeBlocks
limit 与offset的用法(转载)
How does the markdown editor of CSDN input mathematical formulas--- Latex syntax summary
35岁真就成了职业危机?不,我的技术在积累,我还越吃越香了
全自动化处理每月缺卡数据,输出缺卡人员信息
他们齐聚 2022 ECUG Con,只为「中国技术力量」
The standby database has been delayed. Check that the MRP is wait_ for_ Log, apply after restarting MRP_ Log but wait again later_ for_ log
[question de programmation] [scratch niveau 2] oiseaux volants en décembre 2019
大数据开源项目,一站式全自动化全生命周期运维管家ChengYing(承影)走向何方?
When creating body middleware, express Is there any difference between setting extended to true and false in urlencoded?
商品的设计等整个生命周期,都可以将其纳入到产业互联网的范畴内
去了字节跳动,才知道年薪 40w 的测试工程师有这么多?
关于组织2021-2022全国青少年电子信息智能创新大赛西南赛区(四川)复赛的通知
第四期SFO销毁,Starfish OS如何对SFO价值赋能?