📄 lcd.h
字号:
//*****************************************************************
//
// File Name : 'lcd.h'
// Title : Character LCD driver for HD44780 displays (mem-mapped)
// Author : Pascal Stang
// Date : 11/22/2000
// Version : 0.1
// Target MCU : ATmega103
// Editor Tabs : 3
//
//*****************************************************************
#ifndef LCD_H
#define LCD_H
#include "global.h"
/* change these definitions to adapt setting */
#define LCD_LINES 4 /* visible lines */
#define LCD_LINE_LENGTH 20 /* internal line length */
/* you shouldn't need to change anything below this line */
#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_CTRL 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_10DOTS 2 /* DB2: 5x10 font (0->5x7 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_IO_DATA 0x0001 // A0 goes to RS
#define LCD_IO_FUNCTION 0x0000
#define LCD_IO_READ 0x0002 // A1 goes to R/-W
#define LCD_IO_WRITE 0x0000
#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) | LCD_FDEF_1 | LCD_FDEF_2)
#define LCD_MODE_DEFAULT ((1<<LCD_ENTRY_MODE) | (1<<LCD_ENTRY_INC))
#define LCD_DATA_PORT PORTA
#define LCD_E_PORT PORTD
#define LCD_E_PIN PD5
#define lcd_e_high() sbi(LCD_E_PORT, LCD_E_PIN); asm volatile ("nop"); asm volatile ("nop");
#define lcd_e_low() cbi(LCD_E_PORT, LCD_E_PIN);
/* prototypes */
void lcdBusyWait(void);
void lcdControlWrite(u08 data);
u08 lcdControlRead(void);
void lcdDataWrite(u08 data);
u08 lcdDataRead(void);
void lcdInit(void);
void lcdHome(void);
void lcdGotoXY(u08 row, u08 col);
void lcdPrintStr(char str[]);
void lcdPrintfU4(u08 Data);
void lcdPrintfu08(u08 Data);
void lcdPrintfu16(u16 Data);
void lcdPrintfu32(u32 Data);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -