免费一级片网站-免费一级片在线-免费一级片在线观看-免费一级生活片-国产原创视频在线-国产原创中文字幕

歡迎來到我司Viking代理產(chǎn)品網(wǎng)站!
一個值得學習的LCD驅(qū)動器框架
Viking代理 2025-06-20

今天,我看到了由哥哥Xiao Yao分享的一篇文章:[體系結(jié)構(gòu)]如何在嵌入式編程中對代碼結(jié)構(gòu)進行分層,提到了高內(nèi)聚,低耦合,軟件分層等概念。

以前,一個小伙伴在后臺留下了一條消息,告訴我分享這樣的文章,所以今天就在這里!廢話不多,講太多理論是沒有道理的。

這些規(guī)則的本質(zhì)是基于與面向?qū)ο笤O(shè)計模式有關(guān)的一些理論。

設(shè)計模式是一組易于使用的前輩,他們發(fā)現(xiàn)了一些規(guī)則并在實踐中進行了總結(jié)。

框架,讓我們直接運送干貨,堅硬的肝臟!以Cubs提供的SPI OLED驅(qū)動程序為例。

我們將對原始開發(fā)套件中的LCD驅(qū)動器進行一些簡單的轉(zhuǎn)換。

然后根據(jù)需求設(shè)計以下驅(qū)動程序模型框架,分為三個部分:模型,驅(qū)動程序和設(shè)備。

考慮到過于詳細的內(nèi)容,一開始并不會使其變得特別復雜,不利于理解,因此我們構(gòu)建了以下框架思維導圖:1. LCD驅(qū)動程序框架數(shù)據(jù)結(jié)構(gòu)框架提供哪些功能?這就是我的操作方式,非常簡單:這是將驅(qū)動程序框架與驅(qū)動程序連接的能力,& amp; lcd_driver獲得了在驅(qū)動程序文件中定義的已分配結(jié)構(gòu)lcd_driver,因此當我進入“定義變量”時LCD_Driver_Model的位置,然后將此變量與驅(qū)動器結(jié)構(gòu)連接,以便您可以使用此變量來操作驅(qū)動器結(jié)構(gòu)中的接口。

2. LCD驅(qū)動器數(shù)據(jù)結(jié)構(gòu)LCD驅(qū)動器數(shù)據(jù)結(jié)構(gòu)要做的是提供一個用于操作LCD驅(qū)動器功能的接口。

該接口的設(shè)計與硬件無關(guān)。

如上一節(jié)所述,驅(qū)動程序框架取決于驅(qū)動程序接口。

在這種情況下,我們需要在驅(qū)動程序接口中實現(xiàn)該方法。

在相應的方法中,我們需要調(diào)用與LCD設(shè)備相關(guān)的接口來操作LCD設(shè)備。

以下是與該接口對應的實現(xiàn):3. LCD設(shè)備數(shù)據(jù)結(jié)構(gòu)LCD設(shè)備需要做的是將該數(shù)據(jù)結(jié)構(gòu)中的功能功能與實際的LCD驅(qū)動器接口相連。

例如,讓我們看一下LCD_Init接口的實現(xiàn)。

這是實際調(diào)用LCD的實際硬件操作:4.如何使用int& nbmain; & nbsp;& nbsp;& nbsp; / *& nbsp; USER  USER& nbsp ; CODEBEGIN& nbsp; * / & nbsp;& nbsp;& nbsp; LCD_Driver_Model& nbsp;& nbsp; lcd_model& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp; nbsp; LCD_Ascii_Show_Para& nbsp; ascii_para []  =& nbsp;& nbsp;& nbsp;& nbsp; {& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp; ;& nbsp;& nbsp; {80,& nbsp; 100,& nbsp; 240-80,“ RED”,& nbsp; BLACK,& nbsp; RED,& nbsp ; 32},& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp; {80,& nbsp; 100,& nbsp; 240 -80,“ GREEN”,“黑色”,“ GREEN”和“ 32”,& nbsp;& nbsp;& nbsp;& nbsp;& nbsp ;& nbsp; {80,& nbsp; 100,& nbsp; 240-80,“ BLUE”,& nbsp; BLACK,& nbsp; BLUE,& nbsp; 32}, & nbsp;& nbsp;& nbsp;};& ; nbsp; LCD_Fill_Para& nbsp; fill_para []& nbsp; =& nbsp;& nbsp;& nbsp; {& nbsp;& nbsp;& nbsp; {ascii_para [0]。

x,ascii_para [0] .max_width,ascii_para [0] .y,ascii_para [0] .y + 32},& nbsp;& nbsp; {ascii_para [1] .x,ascii_para [1] .max_width,ascii_para [1] .y,ascii_para [1] .y + 32},& nbsp;& nbsp;& nbsp; {ascii_para [2]。

x,ascii_para [2] .max_width,ascii_para [2] .y,as cii_para [2] .y + 32},& nbsp;}& nbsp ;;& nbsp;& nbsp;& amp; ; nbsp; / *& nbsp; USER& nbsp; CODE& nbsp; END& nbsp; 1& nbsp; * /& nbsp;& nbsp;& nbsp;& nbsp; / * * ; nbsp; MCU& nbsp;配置------------------------------------------ --- ----------- * /& nbsp;& nbsp;& nbsp; / *& nbsp;重置& nbsp; all& nbsp;全部 外圍設(shè)備,并初始化Flash和界面接口以及Systick。

* // nbsp;和/ nbsp;                    & nbsp; HAL_Init();& nbsp;& nbsp;& nbsp; / *& nbsp; USER& nbsp; CODE& nbsp; BEGIN& nbsp; Init& nbsp; * /& nbsp;& nbsp;& nbsp; / *& nbsp; USER& nbsp; CODE& nbsp; END& nbsp; Init& nbsp; * /& nbsp;& nbsp;& nbsp;  & nb sp; / *& nbsp;配置& nbsp;系統(tǒng)& nbsp; clock& nbsp; * /& nbsp;& nbsp;& nbsp;& nbsp; SystemClock_Config();  & nbsp;& nbsp; / *& nbsp;用戶  CODE& nbsp; BEGIN& nbsp; SysInit& nbsp; * /& nbsp;& nbsp;& nbsp;& n nbsp; / *& nbsp; USER& nbsp; CODE& nbsp;