📄 xlcd.h
字号:
/********************************************************************/
/* Header for XLCD module library functions for */
/* P-tec PCOG1602B LCD controller */
/********************************************************************/
#if defined(__dsPIC30F__)
#include <p30fxxxx.h>
#elif defined(__dsPIC33F__)
#include <p33Fxxxx.h>
#elif defined(__PIC24H__)
#include <p24Hxxxx.h>
#endif
#if defined(_RD10)
#ifndef _XLCD_H
#define _XLCD_H
/* Comment out the following line if 4-bit interface is being used */
#define EIGHT_BIT_INTERFACE
/* #defines of the data pins and the corresponding tris pins */
/* The READ_PIN_X #defines must match the corresponding DATA_PIN_X defines */
#define DATA_PIN_7 LATDbits.LATD7
#define DATA_PIN_6 LATDbits.LATD6
#define DATA_PIN_5 LATDbits.LATD5
#define DATA_PIN_4 LATDbits.LATD4
#define READ_PIN_7 PORTDbits.RD7
#define READ_PIN_6 PORTDbits.RD6
#define READ_PIN_5 PORTDbits.RD5
#define READ_PIN_4 PORTDbits.RD4
#ifdef EIGHT_BIT_INTERFACE
#define DATA_PIN_3 LATDbits.LATD3
#define DATA_PIN_2 LATDbits.LATD2
#define DATA_PIN_1 LATDbits.LATD1
#define DATA_PIN_0 LATDbits.LATD0
#define READ_PIN_3 PORTDbits.RD3
#define READ_PIN_2 PORTDbits.RD2
#define READ_PIN_1 PORTDbits.RD1
#define READ_PIN_0 PORTDbits.RD0
#endif
#define TRIS_DATA_PIN_7 TRISDbits.TRISD7
#define TRIS_DATA_PIN_6 TRISDbits.TRISD6
#define TRIS_DATA_PIN_5 TRISDbits.TRISD5
#define TRIS_DATA_PIN_4 TRISDbits.TRISD4
#ifdef EIGHT_BIT_INTERFACE
#define TRIS_DATA_PIN_3 TRISDbits.TRISD3
#define TRIS_DATA_PIN_2 TRISDbits.TRISD2
#define TRIS_DATA_PIN_1 TRISDbits.TRISD1
#define TRIS_DATA_PIN_0 TRISDbits.TRISD0
#endif
#if defined(_RD8) && defined(_RD9) && defined(_RD10)
/* #defines of the control pins and the corresponding tris pins for 30F */
#define E_PIN LATDbits.LATD8 /* PORT for E */
#define RW_PIN LATDbits.LATD9 /* PORT for RW */
#define RS_PIN LATDbits.LATD10 /* PORT for RS */
#define TRIS_E TRISDbits.TRISD8 /* TRIS for E */
#define TRIS_RW TRISDbits.TRISD9 /* TRIS for RW */
#define TRIS_RS TRISDbits.TRISD10 /* TRIS for RS */
#endif
/* Display ON/OFF Control defines */
#define DON 0x0F /* Display on */
#define DOFF 0x0b /* Display off */
#define CURSOR_ON 0x0f /* Cursor on */
#define CURSOR_OFF 0x0d /* Cursor off */
#define BLINK_ON 0x0f /* Cursor Blink */
#define BLINK_OFF 0x0e /* Cursor No Blink */
/* Some Command Type defines */
#define CLEAR_XLCD 0x01 /* Clears the LCD */
#define RETURN_CURSOR_HOME 0x02 /* Returns the cursor to the HOME position */
/* Entry Mode Options */
#define INCR_MODE 0x07 /* Increment mode */
#define DECR_MODE 0x05 /* Decrement Mode */
#define ENTIRE_SHIFT_OFF 0x06 /* Shift Entire Display */
#define ENTIRE_SHIFT_ON 0x07 /* Dont Shift Entire Display */
/* Cursor or Display Shift defines */
#define SHIFT_CUR_LEFT 0x13 /* Cursor shifts to the left */
#define SHIFT_CUR_RIGHT 0x17 /* Cursor shifts to the right */
#define SHIFT_DISP_LEFT 0x1b /* Display shifts to the left */
#define SHIFT_DISP_RIGHT 0x1f /* Display shifts to the right */
/* Function Set defines */
#define FOUR_BIT 0x2f /* 4-bit Interface */
#define EIGHT_BIT 0x3f /* 8-bit Interface */
/* defines for no of lines */
#define SINGLE_LINE 0x37 /* Single line display */
#define TWO_LINE 0x3F /* Two line display */
/* defines for segment data transfer direction */
#define SEG1_50_SEG51_100 0x39 /* SEG1->SEG50 ,SEG51->SEG100 */
#define SEG1_50_SEG100_51 0x3d /* SEG1->SEG50 ,SEG100->SEG51 */
#define SEG100_51_SEG50_1 0x3b /* SEG100->SEG51,SEG50->SEG1 */
#define SEG100_51_SEG1_50 0x3f /* SEG100->SEG51,SEG1->SEG50 */
/* defines for COM data transfer direction */
#define COM1_COM16 0x3e /* Data transfer direction is COM1 to COM16 */
#define COM16_COM1 0x3f /* Data transfer direction is COM16 to COM1 */
/* Function prototypes */
/* OpenXLCD
* Configures I/O pins for external LCD
*/
void OpenXLCD(char) __attribute__ ((section (".libperi")));
/* SetCGRamAddr
* Sets the character generator address
*/
void SetCGRamAddr(char) __attribute__ ((section (".libperi")));
/* SetDDRamAddr
* Sets the display data address
*/
void SetDDRamAddr(char) __attribute__ ((section (".libperi")));
/* BusyXLCD
* Returns the busy status of the LCD
*/
char BusyXLCD(void) __attribute__ ((section (".libperi")));
/* ReadAddrXLCD
* Reads the current address
*/
char ReadAddrXLCD(void) __attribute__ ((section (".libperi")));
/* ReadDataXLCD
* Reads a byte of data
*/
char ReadDataXLCD(void) __attribute__ ((section (".libperi")));
/* WriteCmdXLCD
* Writes a command to the LCD
*/
void WriteCmdXLCD(char) __attribute__ ((section (".libperi")));
/* WriteDataXLCD
* Writes a data byte to the LCD
*/
void WriteDataXLCD(char) __attribute__ ((section (".libperi")));
/* putsXLCD
* Writes a string of characters to the LCD
*/
void putsXLCD(char *) __attribute__ ((section (".libperi")));
#define putrsXLCD putsXLCD
#define getcXLCD ReadDataXLCD
#define putcXLCD WriteDataXLCD
/* prototypes of three delay routines used in XLCD functions */
void DelayEPulseWidth() __attribute__ ((section (".libperi")));
void DelayPORXLCD() __attribute__ ((section (".libperi")));
void DelayXLCD() __attribute__ ((section (".libperi")));
void Delay600nsXLCD() __attribute__((section (".libperi")));
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -