更改

跳转至: 导航搜索

谷雨显示接口原理说明

添加24,704字节2018年12月18日 (二) 05:48
无编辑摘要
== 简介 ==
为方便对各显示设备进行操作,现将各显示设备驱动进行整合。在开发者层面,将保持接口统一,而在具本硬件相关的方面,将设备抽象为统一个接口,由上层使用。这样在添加新的显示设备时,只要将显示设备按统一接口规定实现抽象接口即可。在与显示设备通信接口方面,系统中也将其抽象为接口,开发者只要实现这些硬件接口即可实现与具本的显示设备进行通信。

在组织结构上,整个驱动分成四个部分。用户调用接口,字体,图片功能块,屏幕操作接口,硬件接口。在逻辑结构上,四个模块存在上下调用关系,如图下图结构框图所示。
[[文件:Frame1.png|无|缩略图]]

== 用户调用接口 ==
此小节将介绍用户调用接口相关内容,包括相关函数与结构体。它主要包含gui.c,gui_dispstr.c,gui_dispval.c,gui_drawBitmap.c文件。

=== 显示上下文结构体GUI_CONTEXT ===
GUI_Context结构,记录着显示系统当前重要信息,包括位置,中英字体,颜色等。<syntaxhighlight lang="c" line="1">
typedef struct
{
COLOR_INFO colorInfo; //背景色,前景色
const GUI_FONT* pENFont; //英文字体
const GUI_FONT* pZHFont; //中文字体(部分)
int paddingLeft; //距左边距离(单位相素)
int lineSize; //换行时,Y轴尺寸
U16 dispX; //当前X 轴位置
U16 dispY; //当前y 轴位置
U16 xMax; //x轴最大位置
U16 yMax; //y轴最大位置
}GUI_CONTEXT;
</syntaxhighlight>其中COLOR_INFO也是一个结构,只是将背景色与前景色放到一起而已。<syntaxhighlight lang="c" line="1">
//******************************************************************************
// Name : COLOR_INFO
//
// Brief :
typedef struct
{
GUI_COLOR ftColor; //前景色
GUI_COLOR bkColor; //背景色
}COLOR_INFO;
</syntaxhighlight>中英文件字体结构将在字本与图片部分进行说明。

=== 用户接口函数原型 ===
{| class="wikitable"
|+函数原型列表
!序号
!原型
!说明
|-
|1
|void GUI_Init(void)
|初始化整个显示系统,包括各变量与硬件
|-
|2
|void GUI_SetColor(GUI_COLOR color)
|设置显示前景色
color : 传入的前景色
|-
|3
|void GUI_SetBkColor(GUI_COLOR color)
|设置显示背景色
color : 传入的背景色
|-
|4
|void GUI_Clear(void)
|清屏(用背景色覆盖整个屏幕)
|-
|5
|void GUI_GotoXY(U16 x, U16 y)
|设置当前显示位置
x : x 轴位置

y : y轴位置
|-
|6
|GUI_GotoX(U16 x)
|设置当前x轴显示位置
x : x 轴位置
|-
|7
|void GUI_GotoY(U16 y)
|设置当前y轴显示位置
y : y轴位置
|-
|8
|void GUI_DispChar(U16 c)
|在当前位置显示指字的字符
c : 字符的ASCII码
|-
|9
|void GUI_DispCharAt(U16 c, U16 x, U16 y)
|在指定位置显示字符
c : 字符的ASCII码

x : x 位置

y : y 位置
|-
|10
|void GUI_DispChars(U16 c, U16 cnt)
|在当前位置显示cnt个字符
c : 字符的ASCII码

cnt : 个数
|-
|11
|void GUI_DispString(const char *s)
|在当前位置显示字符串
s : 指向字符串指针
|-
|12
|void GUI_DispStringAt(const char*s ,U16 x, U16 y)
|在指定位置显示字符串
s : 指向字符串指针

x : x 位置

y : y 位置
|-
|13
|void GUI_DispNextLine(void)
|回车换行
|-
|14
|void GUI_DispDec(I32 v)
|在当前位置显示10进制数据
v : 数值
|-
|15
|void GUI_DispDecAt(I32 v, U16 x, U16 y)
|在指定位置显示10进制数据
v : 数值

x : x位置

y : y位置
|-
|16
|void GUI_DispHex (U32 v, U8 len)
|在当前位置显示16进制数据
v : 数值

len : 显示数字长度,如果实际长度大于len,将以实际长度为准。

如果实际长度小于len,将补0,达到len长度。
|-
|17
|void GUI_DispHexAt(U32 v, U16 x, U16 y, U8 len)
|在指定位置显示16进制数据
v : 数值

x : x位置

y : y位置

len : 显示数字长度,如果实际长度大于len,将以实际长度为准。

如果实际长度小于len,将补0,达到len长度。
|-
|18
|void GUI_DrawBitmap (const GUI_BITMAP * pBM, int x, int y)
|在指定位置显示一张BMP格式图片
pBM : 指向BITMAP指针

x : x轴位置

y : y轴位置
|}

== 字体图片 ==
在显示驱动中,支持中文字体与英文字体。英文字库中只包含ASCII码32到127,中文字库中只包含使用的汉字。对字体信息使用,采用三个结构体,FONT_INFO,ZHFONT_INFO,GUI_FONT。(驱动中默认提供了Font4x6,Font8x8,Font8x16,Font12x24,FontZH16x16_simsum,FontZH24x24_simsum字体)

其FONT_INFO主要用于英文字体,描述字库的范围,及字体X轴大小等信息。其结构具本内容如下。<syntaxhighlight lang="c" line="1">
//******************************************************************************
// Name : FONT_MONO
//
// Brief : FONT
typedef struct {
const U8 * pData; //字库数据
U16 FirstChar; //起始字符
U16 LastChar; //最后字符

U8 XSize; //字体X轴大小
U8 BytesPerLine; //一行几个字节
} FONT_INFO;
</syntaxhighlight>ZHFONT_INFO用于汉字字体,描述字体X轴大小,及支持的汉字编码与字库数据对应表。其结构内容如下。<syntaxhighlight lang="c" line="1">
//******************************************************************************
// Name : ZHFont_Info
//
// Brief : 中文相关的结构。中文采用查表方法进行显示。{只要画出要使用的汉字即可}
typedef struct
{
U16 code; //GB2312 encode
//U16 index; //Index in table(编码位置代替此字段)
}ZHFont_MAP;

typedef struct
{
const U8 * pData; //字库数据
const ZHFont_MAP* pMap; //映射表
U8 XSize; //x轴大小
U8 BytesPerLine; //每行字节数
}ZHFONT_INFO;
</syntaxhighlight>GUI_FONT结构整合FONT_INFO或ZHFONT_INFO,字体的Y轴尺寸,及相关函数指针(具体实现在FontMethod.c 或FontZHMethod.c)。<syntaxhighlight lang="c" line="1">
typedef void FONT_DISPCHARDISTX(U16 c);
typedef int FONT_GETCHARDISTX(const GUI_FONT* pFont);
typedef int FONT_ISINFONT(const GUI_FONT* pFont, U16 c);

//******************************************************************************
// Name : GUI_FONT
//
// Brief : FONT INFO STRUCT
struct GUI_FONT{
FONT_DISPCHARDISTX* pfDispChar; //显示字符函数指针
FONT_GETCHARDISTX* pfGetCharDistX; //返回字体X尺寸函数指针
FONT_ISINFONT* pfIsInFont; //检查字符是否在字库中
U8 YSize; //y 轴尺寸
union
{
const FONT_INFO *pEn;
const ZHFONT_INFO *pZHGB2312;
} p;
};

</syntaxhighlight>在显示系统中也加入了图片数据显示。每个图片都通过GUI_BITMAP结构来构建。GUI_BITMAP结构如下。<syntaxhighlight lang="c" line="1">
//******************************************************************************
// Name : GUI_BITMAP
//
// Brief : BMP格式图片信息结构,
typedef struct {
U16 XSize; //图片X大小,单位相素
U16 YSize; //图片Y大小,单位相素
U16 BytesPerLine; //每行字节数。XSize * (BitsPerPixel / 8 )
U16 BitsPerPixel; //每个相素点几位bits
const U8 * pData; //指向图片数据
const GUI_PALETTE * pPal; //暂不支持
} GUI_BITMAP;

</syntaxhighlight>例如,一个图片大小为240x73,每个相素点采有16位颜色深度显示。则GUI_BITMAP构建如下。<syntaxhighlight lang="c" line="1">
const GUI_BITMAP bmTest = {
240, // xSize
73, // ySize
480, // BytesPerLine
16, // BitsPerPixel
(unsigned char *)bmpLogo, // Pointer to picture data
NULL // Pointer to palette
};
</syntaxhighlight>

== 显示设备抽象接口 ==
为支持不同显示设备,驱动中将具体的显示设备抽象为一些接口。开发者在添加额外的显示设备时,只要实现这些函数接口,并注册到系统中即可。(在驱动中默认支持谷雨的TFT_144(128x128)屏,TFT_130(240x240),对应的文件lcddrv_tft_144.c,lcddrv_tft_130.c)。

系统中将这些抽象的接口,实施成一个结构体LCDDRV_DEV_API,其内容如下。<syntaxhighlight lang="c" line="1">
//******************************************************************************
// fn : LCD_Init
//
// brief : Init the lcd mode
//
// param : none
//
// return : none
typedef void (*pfLCD_Init)(void);

//******************************************************************************
// fn : LCD_SetPixel
//
// brief : Set the index of given pixel
//
// param : x -> x axis position
// y-> y axis positin
// colorIndex -> rgb
//
// return : none
// 注意:
// 此函数没有作参数检查。调用函数必须确定坐标在LCD范围内。
typedef void (*pfLCD_SetPixel)(int x, int y, int colorIndex);

//******************************************************************************
// fn : LCD_FillRect
//
// brief : fill the Rect with Color
//
// param : x0 -> the start positin in x axis
// y0 -> the start positin in y axis
// x1 -> the end positin in x axis
// y1 -> the end positin in y axis
//
// ___________________
// | |
// | +(x0,y0) |
// | |
// | |
// | +(x1,y1) |
// |__________________|
//
// return : none
// 注意:
// 此函数没有作参数检查。调用函数必须确定坐标在LCD范围内。
typedef void (*pfLCD_FillRect)(int x0, int y0 ,int x1, int y1,int colorIndex);

//******************************************************************************
// fn : LCD_DrawHLine
//
// breif : Draw a horizontal line
//
// param : x0 -> the start position of horizontal
// y -> the vertical position
// x1 -> the end position of horizotal
//
// return : none
// 注意:
// 此函数没有作参数检查。调用函数必须确定坐标在LCD范围内。
typedef void (*pfLCD_DrawHLine)(int x0, int y, int x1,int colorIndex);

//******************************************************************************
// fn : LCD_DrawVLine
//
// breif : Draw a vertical line
//
// param : x -> the horizontal position
// y0 -> the start position of vertical
// y1 -> the end position of vertical
//
// return : none
// 注意:
// 此函数没有作参数检查。调用函数必须确定坐标在LCD范围内。
typedef void (*pfLCD_DrawVLine)(int x, int y0, int y1,int colorIndex);

//******************************************************************************
// fn : LCD_DrawBitmap
//
// breif : Draw a bitmap
//
// param : x0 -> the start position of x Axis
// y0 -> the start position of y Axis
// xSize -> the size of row
// ySize -> the size of column
// BitsPerPixel -> the NUM bits of perPixel
// BytesPerLine -> the NUM Bytes of a line
// pData ->
//
// return : none
// 注意:
// 此函数没有作参数检查。调用函数必须确定坐标在LCD范围内。
typedef void (*pfLCD_DrawBitmap)(int x0, int y0,
int xSize, int ySize,
int BitsPerPixel,
int BytesPerLine,
const U8 *pData,
int diff,
U32* pTrans);


#define LCD_XSIZE_ID 0x01
#define LCD_YSIZE_ID 0x02
#define LCD_COLOR_MODE_ID 0x03

typedef int (*pfLCD_Info)(int id);

//******************************************************************************
// 定义LCD屏通用驱动接口函数
//
typedef struct
{
pfLCD_Init pfLcdInit; //init func
pfLCD_SetPixel pfLcdSetPixel; //Draw dot
pfLCD_FillRect pfLcdFillRect; //fill a rectangle
pfLCD_DrawHLine pfLcdDrawHLine; //draw a horizontal line
pfLCD_DrawVLine pfLcdDrawVLine; //draw a vertical line
pfLCD_DrawBitmap pfLcdDrawBitMap; //draw a bitmap
pfLCD_Info pfLcdInfo; //get the param.Ex xsize
}LCDDRV_DEV_API;
</syntaxhighlight>LCDDRV_DEV_API结构中成员变量都是函数指针,具体注释见上述函数指针声明。开发者在添加显示设备时,只要将实现的LCDDRV_DEV_API结构注册到lcd.c中,并通过LCDDRV_API宏定义进行引用即可。

lcd.c 在驱动中,主要起到在用户接口与显示设备驱动之间桥梁,即用户接口函数通过lcd.c与显示设备驱动进行交互。同时lcd.c中还负责参数检查。

== 硬件通信抽象接口 ==
考虑到显示设备通信方式的不同,在驱动中,将与显示设备通信方式抽象为一个接口,即HalLcdHwTable。<syntaxhighlight lang="c" line="1">
/* 打开关闭LCD 背光 */
typedef void (*hal_lcd_bl)(U8);

/* 设置通信模式:即低电平是LCD命令(选择寄存器),高电平LCD数据(设置寄存器中的值)*/
typedef void (*hal_lcd_mode)(U8);

/* spi通信片选,低电平有效 */
typedef void (*hal_lcd_cs)(U8);

/* spi发送一个数据 */
typedef U8 (*hal_spi_write)(U8);

/* spi 发送指定个数据 */
typedef U8 (*hal_spi_writeMore)(U8*,U16);

typedef struct
{
hal_lcd_bl pfLcdBl;
hal_lcd_mode pfLcdMode;
hal_lcd_cs pfLcdCs; //如果cs由spi控制,此处为NULL
hal_spi_write pfLcdSent;
hal_spi_writeMore pfLcdSentMore;
}HalLcdHwTable;
</syntaxhighlight>开发者根据平台的要求,实现HalLcdHwTable结构。hal_lcd_bl函数指数控制显示屏的背光;hal_lcd_mode函数指针控制通信数据属性,即是命令还是数据;hal_lcd_cs函数指针控制着显示屏片选;hal_spi_write函数指数用于数据的发送。

== 任意字体生成 ==
为满足不同尺寸显示屏的显示需求,开发者可以根据自己实际需求,生成自己想要的尺寸字体。在这里用到了两个小工具,一个是'''PCtoLCD2002完美版-(字符模式)''',用于生成字符或汉字取模。一个是'''FontMap''',将字模生成X的宏。

这里以英文12x24大小字体的大写字母A为例。
# 双击打开PCtoLCD2002
# 输入字符A
# 将字体宽度与高度改成24
# 点击设置按钮,将格式设成C51,每行显示数改成24x2 = 48。如下图所示。[[文件:PctoLCD.png|无|缩略图|484x484像素]]
# 点击生成字模,此时下方将会显示A字符字模数据。
# 双击运行FontMap,将5步骤生成字模数据复制到输入框中,同时在cfg框中,将BytesPerLine改成2。参数根据实际字体大小进行调整,多于8的陪数就要加1。如本例12,此参数就填写2(12/8 + 12%8 ? 1 : 0).[[文件:Map font1.png|无|缩略图|720x720像素]]
# 点击StartMAP按钮,就会生成X与_的组成A的样子,如上图所示。
# 完成所有字库创建之后,在字库文体的中创建FONT_INFO结构,GUI_FONT结构来表述字体。
# 最后一步最为重要。创建GUI_FONT* GUI_pEnFont指针变量,且指向上述创建的GUI_FONT变量,由驱动使用。例如下面示例代码。<syntaxhighlight lang="c" line="1">
const FONT_INFO FontInfo12x24 = {
GUI_FontData[0],
32, /* FirstChar */
127, /* LastChar */
12, /* XSize */
2 /* BytesPerLine */
};

const GUI_FONT GUI_Font12x24 = { FONT_FUNC, 24, {&FontInfo12x24}};


//外部使用
const GUI_FONT* GUI_pEnFont = &GUI_Font12x24;
</syntaxhighlight>

== 增加显示屏 ==
显示屏操作,已经抽象LCDDRV_DEV_API接口。开发者只要实现这些函数接口,并在lcd.c文件中进行声明即可。同时通信部分实现HalLcdHwTable硬件接口即可。

在LCDDRV_DEV_API接口中,对显示屏进行初始化设置,画点,画线,填充矩形,显示一个图片等操作。最后将这些函数放到LCDDRV_DEV_API变量中。以谷雨显示屏GYU_TFT_130(240x240)型为例,实现LCDDRV_DEV_API。<syntaxhighlight lang="c" line="1">
//******************************************************************************
// fn : LCDDRV_TFT130_Init
//
// brief : Init the lcd mode
//
// param : none
//
// return : none
extern void LCDDRV_TFT130_Init(void)
{
//open the backlight
HalLcdHwFunc.pfLcdBl(LCD_BL_ON);

_SetReg(0x36); //memery access control
_SetData(0x00);

_SetReg(0x3A); //interface pixel formate
_SetDataMore((U8*)PIXEL_FORMATE_INTERFACE , 1);

_SetReg(0xB2); //porch setting
_SetDataMore((U8*)PORCTRL_SETTING , 3);

_SetReg(0xB7); //gate control
_SetDataMore((U8*)GATE_CTL , 1);

_SetReg(0xBB); //VCOM setting
_SetDataMore((U8*)VCOM_SETTING , 1);

_SetReg(0xC0); //LCM control
_SetDataMore((U8*)LCM_CTL , 1);

_SetReg(0xC2); //VDV VRH enable control setting
_SetDataMore((U8*)VDV_VRH_EN_SETTING , 1);

_SetReg(0xC3); //VRH setting
_SetDataMore((U8*)VRH_SET, 1);

_SetReg(0xC4); //VDV setting
_SetDataMore((U8*)VDV_SET, 1);

_SetReg(0xC6); //frame rate control
_SetDataMore((U8*)FRAME_RATE_CTL, 1);

_SetReg(0xD0); //pwr control
_SetDataMore((U8*)PWR_CTL, 2);

_SetReg(0xE0); //gamma 1
_SetDataMore((U8*)GAMMA_CONTROL1, 14);

_SetReg(0xE1); //gamma 2
_SetDataMore((U8*)GAMMA_CONTROL2, 14);

_SetReg(0x21); //display inversion on

_SetReg(0x11); //exit on sleep

_SetReg(0x29); //Display on

}
//******************************************************************************
// fn : LCDDRV_TFT130_SetPixel
//
// brief : Set the index of given pixel
//
// param : x -> x axis position
// y-> y axis positin
// colorIndex -> rgb
//
// return : none
// 注意
// 此函数没有作参数检查,调用者必须确定坐标在范围内
extern void LCDDRV_TFT130_SetPixel(int x, int y, int colorIndex)
{
U16 color = _Color2Index(colorIndex);

LCDDRV_TFT_SetXY(x,y);

_SetColorIndices(color);
}

//******************************************************************************
// fn : LCDDRV_TFT130_FillRect
//
// brief : fill the Rect with Color
//
// param : x0 -> the start positin in x axis
// y0 -> the start positin in y axis
// x1 -> the end positin in x axis
// y1 -> the end positin in y axis
//
// ___________________
// | |
// | +(x0,y0) |
// | |
// | |
// | +(x1,y1) |
// |__________________|
//
// return : none
// 注意
// 此函数没有作参数检查,调用者必须确定坐标在范围内
extern void LCDDRV_TFT130_FillRect(int x0, int y0 ,int x1, int y1,int colorIndex)
{
U16 devColor = _Rev16(_Color2Index(colorIndex));

U16 xDelta = 0, yDelta = 0, bytesPerline;

xDelta = (x1 > x0 ? x1 - x0 : x0 - x1) + 1 ;
yDelta = (y1 - y0 ? y1 - y0 : y0 - y0) + 1 ;

bytesPerline = xDelta << 1;

for(U16 i = 0 ; i < xDelta ; i++)
{
gLcdBuf[i] = devColor;
}

_SetLcdRect(x0,y0,x1,y1);

for(U16 i = 0 ; i < yDelta ; i++)
{
_SetDataMore((U8*)&gLcdBuf,bytesPerline);
}

}

//******************************************************************************
// fn : LCDDRV_TFT130_DrawHLine
//
// breif : Draw a horizontal line
//
// param : x0 -> the start position of horizontal
// y -> the vertical position
// x1 -> the end position of horizotal
//
// return : none
// 注意
// 此函数没有作参数检查,调用者必须确定坐标在范围内
extern void LCDDRV_TFT130_DrawHLine(int x0, int y, int x1,int colorIndex)
{
U16 devColor = _Rev16(_Color2Index(colorIndex));

U16 xDelta = 0, bytesPerline = 0;

xDelta = (x1 > x0 ? x1 - x0 : x0 - x1) + 1;
bytesPerline = xDelta << 1;

for(U16 i = 0 ; i < xDelta ; i++)
{
gLcdBuf[i] = devColor;
}

_SetLcdRect(x0,y,x1,y);


_SetDataMore((U8*)&gLcdBuf,bytesPerline);

}
//******************************************************************************
// fn : LCDDRV_TFT130_DrawVLine
//
// breif : Draw a vertical line
//
// param : x -> the horizontal position
// y0 -> the start position of vertical
// y1 -> the end position of vertical
//
// return : none
// 注意
// 此函数没有作参数检查,调用者必须确定坐标在范围内
extern void LCDDRV_TFT130_DrawVLine(int x, int y0, int y1 ,int colorIndex)
{
U16 devColor = _Rev16(_Color2Index(colorIndex));

U16 yDelta = 0, bytesPerline = 0;

yDelta = y1 - y0 ? y1 - y0 : y0 - y0;
bytesPerline = 2;

_SetLcdRect(x,y0,x,y1);

for(U16 i = 0 ; i < yDelta ; i++)
{
_SetDataMore((U8*)&devColor,bytesPerline);
}
}
//******************************************************************************
// fn : LCDDRV_TFT130_DrawBitmap
//
// breif : Draw a bitmap
//
// param : x0 -> the start position of x Axis
// y0 -> the start position of y Axis
// xSize -> the size of row
// ySize -> the size of column
// BitsPerPixel -> the NUM bits of perPixel
// BytesPerLine -> the NUM Bytes of a line
// pData ->
//
// return : none
// 注意
// 此函数没有作参数检查,调用者必须确定坐标在范围内
extern void LCDDRV_TFT130_DrawBitmap(int x0, int y0,
int xSize, int ySize,
int BitsPerPixel,
int BytesPerLine,
const U8 *pData,
int Diff,
U32* pTrans)
{
int i = 0;
switch(BitsPerPixel)
{
case 1:
for(i = 0 ; i < ySize ; i++)
{
_DrawBitLine1BPP(x0,i + y0, pData, Diff, xSize, pTrans);
pData += BytesPerLine;
}

break;
case 2:
break;
case 4:
break;
case 8:
break;
case 16:
for(i = 0; i < ySize ; i++)
{
_DrawBitLine16BPP( x0, i + y0, (const U16 *)pData, xSize);
pData += BytesPerLine;
}
break;

}
}

//******************************************************************************
// fn : LCDDRV_TFT130_GetInfo
//
// brief : get the lcd related parameter
//
// param : id -> the id of param
//
// return : info
extern int LCDDRV_TFT130_GetInfo(int id)
{
switch(id)
{
case LCD_XSIZE_ID :
return LCD_XSIZE;
case LCD_YSIZE_ID:
return LCD_YSIZE;
case LCD_COLOR_MODE_ID:
return LCD_COLOR_MODE;
}
return 0;
}
... ...
//******************************************************************************
// Name : LCDDRV_TFT144_Api
//
// brief : lcd abstract
const LCDDRV_DEV_API LCDDRV_TFT130_Api =
{
.pfLcdInit = LCDDRV_TFT130_Init,
.pfLcdSetPixel = LCDDRV_TFT130_SetPixel,
.pfLcdFillRect = LCDDRV_TFT130_FillRect,
.pfLcdDrawHLine = LCDDRV_TFT130_DrawHLine,
.pfLcdDrawVLine = LCDDRV_TFT130_DrawVLine,
.pfLcdDrawBitMap = LCDDRV_TFT130_DrawBitmap,
.pfLcdInfo = LCDDRV_TFT130_GetInfo
};
</syntaxhighlight>同时在lcd.c中进行声明。<syntaxhighlight lang="c" line="1">
//******************************************************************************
// Lcd drivers list
//
extern const LCDDRV_DEV_API LCDDRV_TFT144_Api;
extern const LCDDRV_DEV_API LCDDRV_TFT130_Api;



#ifdef LCD_TFT_144

#define LCDDRV_API (&LCDDRV_TFT144_Api)

#elif LCD_TFT_130

#define LCDDRV_API (&LCDDRV_TFT130_Api)

#else

#error "Please,select a lcd driver!"

#endif
</syntaxhighlight>在显示屏硬件通信接口方面HalLcdHwTable的实现,将是开发者根据自己实际屏幕通信接口要求进行修改。这里以谷雨GYU_TFT_130屏幕为便。它采用二线SPI通信方式,有背光控制,片选控制,数据模式控制。最终实现如下。<syntaxhighlight lang="c" line="1">
//******************************************************************************
//定义LCD硬件操作接口函数表
//
HalLcdHwTable HalLcdHwFunc =
{
.pfLcdBl = HAL_LcdBl,
.pfLcdMode = HAL_LcdMode,
.pfLcdCs = HAL_LcdCs,
.pfLcdSent = Hal_LcdSpiSent,
.pfLcdSentMore = Hal_LcdSpiSentMore
};
</syntaxhighlight>
2,367
个编辑

本PDF由谷雨文档中心自动生成,点击下方链接阅读最新内容。

取自“http://doc.iotxx.com/特殊:移动版差异/727

导航菜单