📄 lcd.inc
字号:
#ifndef LCD_HEADER
# define LCD_HEADER
//
// Hitachi LCD Control routines for industry standard LCD controllers.
//
// The following equates need to be changed to match your hardware. This
// code assumes an 4 bit interface. The data port is the low nibble of the
// selected output port. The control bits can be any three bits of any port.
//
// The following equates need to be changed to match your hardware.
//
#define LCD_DATA_OUT PORTB
#define LCD_DATA_DDR DDRB
#define LCD_DATA_IN PINB
//
// Set this to either low nibble (0x0F) or high nibble (0xF0) of the
// port you are using.
//
#define LCD_LOW_NIBBLE 0x0F
#define LCD_HI_NIBBLE 0xF0
#define LCD_DATA_BITS LCD_LOW_NIBBLE
#define LCD_CTL PORTB
#define LCD_CTL_DDR DDRB
#define LCD_RS PB7
#define LCD_RW PB6
#define LCD_E PB5
//
// Initialize ports...
//
#define LCD_CTL_DDR_INIT 1<<LCD_RS | 1<<LCD_RW | 1<<LCD_E
//
//
// Instructions/bits. NB Busy Flag (BF) is a bit, not a mask.
//
#define LCD_CLEAR (1<<0)
#define LCD_HOME (1<<1)
#define LCD_ENTRY (1<<2)
#define LCD_ID (1<<1) // Decrement/Increment Cursor
#define LCD_S (1<<0) // Display No Shift/Shift
#define LCD_DISPLAY (1<<3)
#define LCD_D (1<<2) // Display off/on
#define LCD_C (1<<1) // Cursor off/On
#define LCD_B (1<<0) // Cursor No Blink/Blink
#define LCD_SHIFT (1<<4)
#define LCD_CL (1<<3) // Shift Cursor/Display
#define LCD_RL (1<<2) // Shift Left/Right
#define LCD_FUNC (1<<5)
#define LCD_DL (1<<4) // 4/8 bit interface
#define LCD_N (1<<3) // 1/2 line display
#define LCD_F (1<<2) // 5x7/5/10 dot charactor
#define LCD_SET_CGRAM (1<<6)
#define LCD_SET_DDRAM (1<<7)
//
// Reading an instruction gives you the current address counter and
// the busy flag.
//
#if (LCD_DATA_BITS==0x0F)
# define LCD_BF 3 // Busy flag (MSB)
#else
# define LCD_BF 7
#endif
//
//your LCD display type here
//
// Set LCD to 4 bit i/f, two lines
//
#define LCD_FUNCTION_SET LCD_FUNC | LCD_N
//
// Turn display on, with cursor and make cursor blinking
//
#define LCD_DISPLAY_SET (LCD_DISPLAY | LCD_D | LCD_C | LCD_B)
//
// Misc commands that are useful
//
#define LCD_Next_Line (LCD_SET_DDRAM | 0x40) // Start of second line
#define LCD_LINE1 0x00 // Addresses for 4x20 display
#define LCD_LINE2 0x40
#define LCD_LINE3 0x14
#define LCD_LINE4 0x54
#endif // LCDIO_HEADER
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -