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

📄 780.h

📁 ATmega系列单片机驱动1602字符型液晶显示器
💻 H
字号:
// ---------------------------- Head file for 780.c ----------------------------

#ifndef __SPLC780D__
#define __SPLC780D__

//#include "macros.h"

// --------------------------- Interface Definition ----------------------------
#define LCD_CTRL		PORTB
#define LCD_CTRL_DDR	DDRB
#define LCD_RS	       	0
#define LCD_RW			1
#define LCD_E	       	2

#define BUZZER	       	3

#define SET_RS		sbi(LCD_CTRL, LCD_RS)
#define SET_RW 		sbi(LCD_CTRL, LCD_RW)
#define SET_E  		sbi(LCD_CTRL, LCD_E)
#define CLR_RS 		cbi(LCD_CTRL, LCD_RS)
#define CLR_RW 		cbi(LCD_CTRL, LCD_RW)
#define CLR_E  		cbi(LCD_CTRL, LCD_E)

#define SET_buzzer 		sbi(LCD_CTRL, BUZZER)
#define CLR_buzzer 		cbi(LCD_CTRL, BUZZER)

#define LCD_DO			PORTD
#define LCD_DI			PIND
#define LCD_DATA_DDR	DDRD

#define LCD_8BIT
//#define LCD_4BIT
#define LCD_FUNCTION		0x38	// LCD mode as 8-bit 2-line 5*8-dot 1/16Duty
//#define LCD_FUNCTION		0x28	// LCD mode as 4-bit 2-line 5*8-dot 1/16Duty
// -----------------------------------------------------------------------------

// ---------------------- Constant Definition ----------------------------------
#define iDat	1
#define iCmd	0

#define LCD_CLS		0x01		// Clear LCD screen
#define LCD_HOME	0x02		// LCD Return home
#define LCD_ENTRY 	0x06		// Set 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_CGRAM_ADDR	0x40	// Start address of LCD CGRAM
#define LCD_CGMAX 	64			// Max CGRAM bytes

#define LCD_COL 	20
#define LCD_ROW 	2
#define LCD_CHAR	LCD_COL*LCD_ROW

#define LCD_L1		0x80
#define LCD_L2		0xC0
//#define LCD_L3		0x90
//#define LCD_L4		0xD0

const uint8 CGRAM[LCD_CGMAX] =
{
	// Make eight patterns of 8*5 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 -----------------------------
// PORT initial
//void port_ini(void);
//Busy check
void CheckBusy(void);
// Write Data or Command to LCD
void SendByte(uint8 DatCmd, uint8 dByte);
// Write a string to LCD
void SendStr(uint8 *ptString);
// Move Cursor or display
void Move(uint8 dir);
// Goto specific location
void Gotoxy(uint8 Row, uint8 Col);
// Clear LCD Screen
void Clear(void);
// Wait some time and clear screen
void wait_and_clear(void);
// Fill CGRAM with array CGRAM[]
void FillCGRAM(void);
// Show all patterns in CGRAM
void ShowCGRAM(void);
// Call IC's built-in Charactors
void CallBultinChar(void);
// LCD initialization procedure
void LCD_Initial(void);
// -----------------------------------------------------------------------------
#include "inc/780.c"
#endif

⌨️ 快捷键说明

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