⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcdb.h

📁 西安明朗公司开发板ML-F020ICB的全部测试代码
💻 H
字号:
/************************************************************************************
*  Copyright (c), 2004-2007,西安铭朗电子科技有限责任公司
*            All rights reserved.
*
* Http:  www.mlarm.com
* Email: mlarm@mlarm.com
*
* File name: LCDB.h
* Project  : ML-F020ICB
* Processor: C8051F020
* Compiler : Keil C51 Compiler
* 
* Author:  李林利
* Version: 1.20
* Date:    2007.6.1
* Email:   GavinLi@126.com
* 
* Description: 本文件是以SED1335为控制器的LCD显示驱动程序头文件,现支持的液晶为240x160,320x240;
*
* Others: LCD(320x240为例)显示屏坐标定义图:
*                   |O(0,0)
*                 --|----------------------------------------------------------> y 列坐标         
*                   |                                                 |320
*                   |                  铭朗科技                       | 
*				    |                                                 |
*					|                 ML-F020ICB                      |     
*					|                                                 |
*					|                                                 |   
*					|                                                 |
*					|               LCD320x240 显示屏                 |
*					|                                                 |   
*					|                                                 |
*					|                                                 |
*					|                                                 |
*				240	|-------------------------------------------------|(240,320)
*					|
*				   \|/
*                   | x 行坐标
*
* Function List:
*   1. void LCDB_WritePara(unsigned char *p, unsigned char len)
*   2. void LCDB_ClearScreen(void)
*	3. void LCDB_Init(unsigned char lcd_type)
*   4. unsigned char LCDB_SetGraphMaps(unsigned char id)
*	5. void LCDB_DrawPixel(unsigned int x, y, bit mode)
*   6. void LCDB_DrawLine(unsigned int x1, y1, x2, y2, bit mode)
*	7. void LCDB_DrawRectangle(unsigned int x1, y1, x2, y2, bit mode)
*	8. void LCDB_DrawFillRectangle(unsigned int x1, y1, x2, y2, bit mode)
*	9. void LCDB_DrawCircle(unsigned int x, y, r, bit mode)
*	10. void LCDB_DrawByte(unsigned int x, y, unsigned char val)
*	11. void LCDB_ShowHZxy(unsigned char x, y, unsigned char line, col, unsigned char *p);
*
* History:
*   1. Author:       李林利  
*	   Version: 	 1.10
*	   Date:         2007.3.12
*      Modification: none
*
*   2. Author:       李林利   
*	   Version: 	 1.00
*      Date:         2004.11.24
*      Modification: 建立文件
*
*************************************************************************************/
/*************************************************************************************
* 					LCD显示驱动程序函数使用说明
*
*	1. 第1步,必须调用函数LCDA_Init(),按函数说明进行设置,本函数只允许调用1次;
*	2. 第2步,如果客户需要其它设置或修改设置可应用LCDB_WriteCmdPara()函数进行设置,
*      命令参照SED1335数据手册;
*   3. 第3步,调用LCDB_SetGraphMaps(),设定图形显示区;
*	4. 第4步,可调用其它画图或显示汉字的函数;参照坐标定义图可帮助客户理解函数参数;
*	5. 其它细节详见具体函数说明;
*
*************************************************************************************/
/************************************************************************************
// 常量及全局变量定义
*************************************************************************************/
/*
//LCD240160常量定义	
#define  LCD240160				6
#define  LCD240160_X			240
#define  LCD240160_Y			160
#define  LCD240160_LINE_CHAR	30
#define  LCD240160_COLUMN_CHAR	20

//LCD320240常量定义	
#define  LCD320240				7
#define  LCD320240_X			320
#define  LCD320240_Y			240
#define  LCD320240_LINE_CHAR	40
#define  LCD320240_COLUMN_CHAR	30
*/

//define LCD code 
#define CMD_SYSSET 0x40 
#define CMD_SCROLL 0x44 
#define CMD_SLEEP 0x53 
#define CMD_DISPON 0x59 
#define CMD_DISPOFF 0x58 
#define CMD_OVLAY 0x5b 
#define CMD_HDOTSCR 0x5a 
#define CMD_CSRFORM 0x5d 
#define CMD_CGRAMADR 0x5c 
#define CMD_CSRRGT 0x4c 
#define CMD_CSRLFT 0x4d 
#define CMD_CSRUP 0x4e 
#define CMD_CSRDOWN 0x4f 
#define CMD_CSRW 0x46 
#define CMD_CSRR 0x47 
#define CMD_MWRITE 0x42 
#define CMD_MREAD 0x43 
#define CMD_AP 30 

/*************************************************************************************/
//
// 						SED1335为控制器的LCD显示驱动程序函数外部引用声明
//
/*************************************************************************************/

/***********************************************************************************
* Function: LCDB_WriteCmdPara;
*
* Description: 向LCD命令口写入命令,接下来向LCD数据口写参数;
*              
* Input:  cmd,LCD控制命令, *para,参数指针; len,参数长度;
*
* Output: none;
*
* Return: none;
*
* Note:   none;
************************************************************************************/
void LCDB_WriteCmdPara(unsigned char cmd, unsigned char *para, unsigned char len);

/***********************************************************************************
* Function: LCDB_ClearScreen;
*
* Description: LCD清屏函数;
*              
* Input:  none;
*
* Output: none;
*
* Return: none;
*
* Note:   本函数只清除所设定的当前显示区即当前屏幕显示;
************************************************************************************/
void LCDB_ClearScreen(void);

/***********************************************************************************
* Function: LCDA_Init;
*
* Description: LCD初始化函数;
*              
* Input:  x, LCD行数; y, LCD列数; 例如:320x240 的LCD, line=240,column=320;
*
* Output: none;
*
* Return: none;
*
* Note:   本函数完成的设置:1.光标形状(0xa7):8x8; 2显示方式: 三屏图形显示,
*         以"或"方式合成;3.设置显示开关: 图形显示/光标显示(闪烁);
*         4.显示存储器清零; 5. 设置图形显示区(编号):0; 
************************************************************************************/
void LCDB_Init(unsigned int x, unsigned int y);

/***********************************************************************************
* Function: LCDB_SetGraphMaps;
*
* Description: 设置图形显示区;此函数可更换不同的图形显示;
*              
* Input:  id, 图形显示区编号, 范围:0~2;
*
* Output: none;
*
* Return: TRUE,设置正确; FALSE,设置失败;
*
* Note:   none;
************************************************************************************/
unsigned char LCDB_SetGraphMaps(unsigned char id);

/***********************************************************************************
* Function: LCDB_DrawPixel;
*
* Description: 画点(x,y);
*              
* Input:  x, LCD行坐标; y, LCD列坐标; bit类型标识mode,1:画点,0:擦除点;
*
* Output: none;
*
* Return: none;
*
* Note:   none;
************************************************************************************/
void LCDB_DrawPixel(unsigned int x, y, bit mode);

/***********************************************************************************
* Function: LCDB_DrawLine;
*
* Description: (x1,y1)--(x2,y2)处划线;
*              
* Input:  x1,x2, LCD行坐标; y1,y2, LCD列坐标; bit类型标识mode,1:画直线:擦除直线;
*
* Output: none;
*
* Return: none;
*
* Note:   none;
************************************************************************************/
void LCDB_DrawLine(unsigned int x1, y1, x2, y2, bit mode);

/***********************************************************************************
* Function: LCDB_DrawRectangle;
*
* Description: 以(x1,y1)和(x2,y2)为对角点画矩形;
*              
* Input:  x1,x2, LCD行坐标; y1,y2, LCD列坐标; bit类型标识mode,1:画矩形,0:擦除矩形;
*
* Output: none;
*
* Return: none;
*
* Note:   none;
************************************************************************************/
void  LCDB_DrawRectangle(unsigned int x1, y1, x2, y2, bit mode);

/***********************************************************************************
* Function: LCDB_DrawFillRectangle;
*
* Description: 以(x1,y1)和(x2,y2)为对角点画矩形实体;
*              
* Input:  x1,x2, LCD行坐标; y1,y2, LCD列坐标; bit类型标识mode,1:画矩形实体,0:擦除矩形实体;
*
* Output: none;
*
* Return: none;
*
* Note:   none;
************************************************************************************/
void  LCDB_DrawFillRectangle(unsigned int x1, y1, x2, y2, bit mode);

/***********************************************************************************
* Function: LCDB_DrawCircle;
*
* Description: 以(x,y)为圆心, r为半径画圆;
*              
* Input:  x, LCD行坐标; y, LCD列坐标; bit类型标识mode,1:画圆,0:擦除圆;
*
* Output: none;
*
* Return: none;
*
* Note:   none;
************************************************************************************/
void  LCDB_DrawCircle(unsigned int x, y, r, bit mode);

/***********************************************************************************
* Function: LCDB_DrawByte;
*
* Description: 向LCD(x,y)点开始写一个字节数据;
*              
* Input:  x, LCD行坐标; y, LCD列坐标; value,写入字节数据;
*
* Output: none;
*
* Return: none;
*
* Note:   应尽量使y(LCD列坐标)是8的整数倍,可使显示速度加快;
************************************************************************************/
void  LCDB_DrawByte(unsigned int x, y, unsigned char val);

/***********************************************************************************
* Function: LCDB_ShowHZxy;
*
* Description: 从LCD(x,y)点开始显示(line*col)的字符;
*              
* Input:  x, LCD行坐标; y, LCD列坐标; line,字符占用行数; col,字符占用列数;
*         *p,字符数据指针;
*
* Output: none;
*
* Return: none;
*
* Note:   应尽量使y(LCD列坐标)是8的整数倍,可使显示速度加快; 本函数也可作为自定义图形显示;
************************************************************************************/
void LCDB_ShowHZxy(unsigned int x, y, unsigned int line, col, unsigned char *p);

/***********************************************************************************

/***********************************************************************************/
// 文件结束
/***********************************************************************************/














⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -