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

📄 lcd.h

📁 avr charactor lcd display source
💻 H
字号:
/*
Charactor LCD 20 x 2 line
*/

#ifndef __LCD_H__
#define __LCD_H__

#include "types.h"
#include "Constants.h"

//----------------------------------//
// By SSH
// charactor lcd port define
#define LCD_DATA_PORT		PORTA
#define LCD_DATA_DDR		DDRA

#define LCD_CON_PORT		PORTC
#define LCD_CON_DDR		DDRC

#define LCD_EN			PC7
#define LCD_RW			PC6
#define LCD_RS			PC5


#define LCD_CLR             0      /* DB0: clear display */
#define LCD_HOME            1      /* DB1: return to home position */
#define LCD_ENTRY_MODE      2      /* DB2: set entry mode */
#define LCD_ENTRY_INC       1      /* DB1: increment ? */
#define LCD_ENTRY_SHIFT     0      /* DB2: shift ? */
#define LCD_ON              3      /* DB3: turn lcd/cursor on */
#define LCD_ON_DISPLAY      2      /* DB2: turn display on */
#define LCD_ON_CURSOR       1      /* DB1: turn cursor on */
#define LCD_ON_BLINK        0      /* DB0: blinking cursor ? */
#define LCD_MOVE            4      /* DB4: move cursor/display */
#define LCD_MOVE_DISP       3      /* DB3: move display (0-> cursor) ? */
#define LCD_MOVE_RIGHT      2      /* DB2: move right (0-> left) ? */
#define LCD_FUNCTION        5      /* DB5: function set */
#define LCD_FUNCTION_8BIT   4      /* DB4: set 8BIT mode (0->4BIT mode) */
#define LCD_FUNCTION_2LINES 3      /* DB3: two lines (0->one line) */
#define LCD_FUNCTION_11DOTS 2      /* DB2: 5x10 font (0->5x11 font) */
#define LCD_CGRAM           6      /* DB6: set CG RAM address */
#define LCD_DDRAM           7      /* DB7: set DD RAM address */

#define LCD_BUSY            7      /* DB7: LCD is busy */


#define LCD_PORT_MASK 0xff
#define LCD_FDEF_1    (1<<LCD_FUNCTION_8BIT)

#define LCD_FDEF_2    (1<<LCD_FUNCTION_2LINES)

#define LCD_FUNCTION_DEFAULT ((1<<LCD_FUNCTION) | (1<<LCD_FUNCTION_8BIT) | (1<<LCD_FUNCTION_2LINES))

#define LCD_MODE_DEFAULT     ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC))

#ifdef NONE_DELAY_ON
#define lcd_en_high()	asm volatile ("nop"); \
											sbi(LCD_CON_PORT, LCD_EN); \
											asm volatile ("nop"); \
											asm volatile ("nop")

#define lcd_en_low()   					cbi(LCD_CON_PORT, LCD_EN); \
																asm volatile ("nop")

#define lcd_io_data()						asm volatile ("nop"); \
																sbi(LCD_CON_PORT, LCD_RS); \
																asm volatile ("nop")

#define lcd_io_instruction()   	cbi(LCD_CON_PORT, LCD_RS); \
											 					asm volatile ("nop")
											
#define lcd_io_read()						asm volatile ("nop"); \
																sbi(LCD_CON_PORT, LCD_RW); \
																asm volatile ("nop")

#define lcd_io_write()   				cbi(LCD_CON_PORT, LCD_RW); \
																asm volatile ("nop")
#else

#define lcd_en_high()				sbi(LCD_CON_PORT, LCD_EN)
#define lcd_en_low()   				cbi(LCD_CON_PORT, LCD_EN)
#define lcd_io_data()				sbi(LCD_CON_PORT, LCD_RS)
#define lcd_io_instruction()   		cbi(LCD_CON_PORT, LCD_RS)
#define lcd_io_read()				sbi(LCD_CON_PORT, LCD_RW)
#define lcd_io_write()   			cbi(LCD_CON_PORT, LCD_RW)
																
																

#endif


#define LCD_IO_DATA         1		//LCD_RS_HIGH		//0x0001	// A0 goes to RS
#define LCD_IO_INSTRUCTION  0		//LCD_RS_LOW		//0x0000

#define LCD_IO_READ				1		//LCD_RW_HIGH		//0x0002	// A1 goes to R/-W
#define LCD_IO_WRITE				0		//LCD_RW_LOW		//0x0000
																				
/* prototypes */
void lcd_init(u08 cursor, u08 fnc);
void lcd_command(u08 cmd);
void lcd_data(u08 cmd);
void lcd_gotoxy(u08 x, u08 y);
void lcd_clrscr(void);
void lcd_putchar(u08 data);
void lcd_puts(u08* str);
void lcd_puts_p(u08* p);
void lcd_reputs(u08* str);
void lcd_putstring(u08* str, u08 str_size);
//------------------------------------//
// ADD By Song 
void  lcdDelay(int del);

//-------------------------------------//
#ifdef ENABLE_LCD_HOME_COMMAND
void lcd_home(void);
#endif


#endif // __LCD_H__

⌨️ 快捷键说明

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