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

📄 lcdtest.h

📁 测试LCM模块AVR应用
💻 H
字号:
/*=======================================================
//--------------------------------------------------------------------------
//标 题: 20*4  AVR仿真驱动                                             
//文件名: main.c                                                         
//版 本: V1.00                                                            
//修改人: 梁香勇                            
//日 期: 2008.08.06                                                                                            
//声 明:                                                                   
//         
//        如用于商业用途请与作者联系.    E-mail:xuwenjun@21cn.com          
//        有问题请mailto :liangxiangyong0@163.com                   
//描 述:                                                                   
//      1、功能完整,直接使用                                               
//      2、模块独立性强,移植方便,外部仅init和move函数,修改显示和输入即可 
//      3、对减少内存占用、尽量减少屏幕操作进行适当优化                     
//      4、新方块生成高度随机,绝对无规律                                  
//      5、仿真环境为Keil+Proteus6.9,可以联机也可脱机运行                
20x4字符液晶主程序,编译软件(ICCAVR_6.31)
CPU内部晶振8M
数据线B0~B7接PORTB, E=D7 RW=D6 RS=D5
=========================================================*/
// ---------------------------- Constants Definition ---------------------------
#define LCD_CLS		0x01		// Clear LCD screen
#define LCD_HOME	0x02		// LCD Return home
#define LCD_ENTRY 	0x06		// LCD Entry Mode

#define LCD_C2L		0x10		// Move Cursor to the left
#define LCD_C2R		0x14		// Move Cursor to the right
#define LCD_D2L		0x18		// Move display to the left
#define LCD_D2R		0x1C		// Move display to the right

#define LCD_ON		0x0C		// Turn on LCD and Cursor
#define LCD_OFF		0x08		// Turn off LCD

#define LCD_1602_4BIT		0x28	// LCD mode as 4-bit 2-line 5*8-dot 1/16Duty
//#define LCD_1602_8BIT		0x38	// LCD mode as 8-bit 2-line 5*8-dot 1/16Duty
#define LCD_CGRAM_ADDR		0x40	// LCD CGRAM Start Address
#define LCD_CGMAX 	64				// Maximal CGRAM bytes

#define LCD_L1		0x80		// The start address of LCD Line 1
#define LCD_L2		0xC0		// The start address of LCD Line 2
#define LCD_L3		0x94		// The start address of LCD Line 3
#define LCD_L4		0xD4	// The start address of LCD Line 4

#define LCD_COL		20
#define LCD_ROW		4
#define LCD_CHAR	LCD_COL*LCD_ROW
uint8 CGRAM[LCD_CGMAX] =
{
	// Make eight patterns of 5*8 font
	0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,		// 1.Dsiplay All
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,		// 2.White Board
	0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,		// 3.Virtical 1
	0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,		// 4.Virtical 2
	0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,		// 5.Horizon 1
	0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,		// 6.Horizon 2	
	0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,		// 7.Stars
	0xFF,0x11,0x11,0x11,0x11,0x11,0x11,0xFF,		// 8.Rectangle
};
// -----------------------------------------------------------------------------
// ----------------------------- Function Prototypes ---------------------------
// Send a data or a command to LCD
//void SendByte(unsigned char DatCmd, uint8 dByte);
// Write a string to LCD
void SendStr(uint8 *ptString);
// Move Cursor or display
void Move(uint8 dir);
// Goto Y char of X Line
void Gotoxy(uint8 Row, uint8 Col);
// Tile LCD Screen with one data
void Tile(uint8 dByte);
// Clear LCD Screen
void Clear(void);
// Fill CGRAM with array CGRAM[]
void FillCGRAM(void);
// Show all patterns in CGRAM
void ShowCGRAM(void);
// Call built-in Charactors
void CallBuiltinChar(void);
// LCD initialization procedure
void test(void);
// -----------------------------------------------------------------------------

#include "code\test\lcdtest.c"

⌨️ 快捷键说明

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