当前位置:网站首页>Weidongshan digital photo frame project learning (IV) simple TXT document display (e-paper book)
Weidongshan digital photo frame project learning (IV) simple TXT document display (e-paper book)
2022-07-27 06:05:00 【qq_ three million three hundred and twenty-two thousand nine hu】
Weidong mountain Digital photo frame Project learning ( Four ) Simple TXT Document display ( Electronic paper book )
With the previous about LCD、freetype Learning from , It's ready to start TXT The preparation of document display . The whole implementation process is not complicated , What must be made clear is freetype Library usage , Chinese character dot matrix LCD The transformation of coordinates and Cartesian coordinates and in LCD Processing of some details when displaying on .
Experimental results
This time, only the most basic functions are realized , stay LCD Displayed on the UTF-8 Coded txt file , Let's look at the experimental results first 
GIF The picture effect of has been cut , The actual effect will refresh a page every two seconds .
Application framework
The following figure is a simple TXT The frame of the document display , It's simple , It is mainly to master the idea of stratification , Familiar with the basic framework .
The framework of the whole program is divided into three parts : Show 、 typeface 、 File encoding
Display management
disp_manager It abstracts a layer , Extract the commonness of display devices , On the next floor framebuffer Or other display devices , Just use disp_manager Functions provided by layer , Distribute 、 Set up 、 Sign up for a T_DispOpr Just the structure , Here is given T_DispOpr Structure code
typedef struct T_DispOpr {
char *name;
int iXres;
int iYres;
int iBpp;
int (*DeviceInit)(void);
int (*ScreenClean)(unsigned int dwBackColor);
int (*DrawPixel)(int iX, int iY, unsigned int dwColor);
struct T_DispOpr *ptNext;
}T_DispOpr, *PT_DispOpr;
Is it simple , Function currently has only three functions , Initialization 、 Clear the screen 、 And the point function , With these three functions , The most important thing is to describe the point function , With the point function , We can expand other interesting functions based on it .
Underlying code , Just assign 、 Set up 、 By registering your own structure, you can add devices to our framework .
Distribute 、 Setting up a structure is simple , So how to register ?
The answer is the following function
int RegisterDispOpr(PT_DispOpr ptDispOpr);
This function is in the disp_manager.c To implement inside , It mainly calls the underlying application , Register the underlying application's own structure to disp_manager Maintain a linked list , To put it bluntly, it is the addition of linked list nodes .
int RegisterDispOpr(PT_DispOpr ptDispOpr)
{
if(!ptDispOpr)
{
DBG_PRINT("ptDispOpr is NULL\n");
return -1;
}
ptDispOpr->ptNext = g_tDispOprs;
g_tDispOprs = ptDispOpr;
return 0;
}
This function is very simple , First, judge whether the structure to be registered is empty , Then add the newly registered item to the front of the linked list .
Then our application can use disp_manager Functions provided by this layer , Register to... Through the underlying application disp_manager The structure of this layer accesses the services provided by the underlying application , Here is framebuffer Displayed services .
Do this when modifying the underlying application , There is no need to make too many changes to the code of the upper application .
Font management
font_manager here , We mainly extract freetype And Chinese character library (HZK16) Commonalities of lattice provided , Abstract out such a structure ----T_FontBitmap, This structure is the information description of a text lattice
typedef struct T_FontBitmap {
int iXLeft; /* LCD coordinate , top left corner x coordinate */
int iYTop; /* LCD coordinate , top left corner x coordinate */
int iXMax; /* LCD coordinate ,x Axis width */
int iYMax; /* LCD coordinate ,y Axis width */
int iBpp; /* How many bits are used to represent a pixel */
int iPitch; /* The spacing of each line of the dot matrix of a character */
int iCurOriginX; /* The input variable */
int iCurOriginY; /* The input variable */
int iNextOriginX; /* Output variables */
int iNextOriginY; /* Output variables */
unsigned char *pucBuffer;
}T_FontBitmap, *PT_FontBitmap;
Every variable here is and LCD Coordinate related , because freetype according to unicode The lattice data returned by the code is the data in Cartesian coordinates , stay LCD When it is shown on the screen , Some details need to be handled . This is an interesting place .
Code management
stay encoding_manager here , I only achieved the right UTF-8 Parsing and output of , Get to know UTF-8 The encoding format of can be quickly obtained from the file data unicode code . Here I have learned a lot about the coding of files ,UTF-8 The documents are divided into UTF-8 And belt BOM Of UTF-8, We have to choose to take BOM Of UTF-8, Because I didn't bring it BOM Of UTF-8 There are three files without the beginning of the file UTF-8 logo
There's another problem that hasn't been solved , It's about the compatibility between the big and small ends , I am here Windows It was edited on UTF-8 The file is in big end format , Upload to ubuntu It becomes a small end mode , stay 157 It is also a small end format storage , But I don't know why , Later, it was successful to read and write files in big format , I hope you can give me some advice .
Complete code
The complete code is given in the form of a compressed package
Full code link ( No points required ): Complete code
边栏推荐
- Essential tool for making video special effects: nuke 13
- 古老的艺术-用好长尾关键词
- [Haowen planting grass] knowledge of root domain name - Ruan Yifeng's Weblog
- socket编程一:使用fork()实现最基础的并发模式
- 【头歌】重生之我在py入门实训中(12):Matplotlib接口和常用图形
- Gbase 8C - SQL reference 6 SQL syntax (9)
- 小技巧-彻底删除U盘中的文件
- pytorch中交叉熵损失函数的细节
- 使用-Wall清除代码隐患
- 对于windows下的Redis,只能读不能写的问题
猜你喜欢

ps 2022 六月更新,都新增了哪些功能

13. Logistic regression

Digital image processing Chapter 2 fundamentals of digital image

Digital image processing Chapter 5 - image restoration and reconstruction

Auto Encoder(AE),Denoising Auto Encoder(DAE), Variational Auto Encoder(VAE) 区别

制作视频后期特效需要什么工具?

数字图像处理第四章——频率域滤波

8. Mathematical operation and attribute statistics

向量和矩阵的范数
![[Haowen planting grass] knowledge of root domain name - Ruan Yifeng's Weblog](/img/75/8f41db9f9c077b43751d63b7b5b57e.png)
[Haowen planting grass] knowledge of root domain name - Ruan Yifeng's Weblog
随机推荐
Live Home 3D Pro interior home design tool
数字图像处理第五章——图像复原与重建
Greedy high performance neural network and AI chip application research and training
std::bind与std::function的一些应用
18. Convolutional neural network
Chrome 如何快速将一组正在浏览的网页(tabs)转移到另一台设备(电脑)上
pytorch模型
Stm32-fsmc extended memory SRAM
3. Classification problems - initial experience of handwritten digit recognition
Uboot supports LCD and HDMI to display different logo images
李宏毅 2020 深度学习与人类语言处理 DLHLP-Conditional Generation by RNN and Attention-p22
13. Logistic regression
能替代ps的修图软件?
方差与协方差
向量和矩阵的范数
数字图像处理第四章——频率域滤波
8. Mathematical operation and attribute statistics
Xmind 思维导图 2022 v12.0.3中文版更新了哪些内容?
Performance optimization of common ADB commands
DSGAN退化网络