#ifndef __XLCD_H #define __XLCD_H #include #define _XTAL_FREQ 4000000 // frekvencija na kojoj radi interni oscilator. Neophodno definisati zbog delay() funkcija /* Interface type 8-bit or 4-bit * For 8-bit operation uncomment the #define BIT8 */ //#define BIT8 /* When in 4-bit interface define if the data is in the upper * or lower nibble. For lower nibble, comment the #define UPPER */ #define UPPER /* DATA_PORT defines the port to which the LCD data lines are connected */ #define DATA_PORT LATB #define TRIS_DATA_PORT TRISB /* * Uncomment this line if non-blocking functions are desired. * If following line is commented, caller must make sure that * XLCD is free ( !XLCDIsBusy() )before calling any get/put commands. */ #define XLCD_IS_BLOCKING /* * Comment following line if there is no read back capability * for this LCD. */ //#define XLCD_READ_BACK /* * Uncomment following line if you want to read data from LCD */ //#define XLCD_ENABLE_LCD_READS /* * Set your LCD type. */ #define XCLD_TYPE (FOUR_BIT & LINES_5X8) /* * This is how LCD will be setup on Init. */ #define XLCD_DISPLAY_SETUP (CURSOR_OFF & BLINK_OFF) //#define XLCD_DISPLAY_SETUP (CURSOR_ON | BLINK_ON) /* * Uncomment following line if LCD data is to be read back. */ //#define XLCD_ENABLE_LCD_READS /* CTRL_PORT defines the port where the control lines are connected. * These are just samples, change to match your application. */ //#define RW_PIN RE0 /* PORT for RW */ //#define TRIS_RW TRISE0 /* TRIS for RW */ #define RS_PIN RA1 /* PORT for RS */ #define TRIS_RS TRISA1 /* TRIS for RS */ #define E_PIN RA3 /* PORT for E */ #define TRIS_E TRISA3 /* TRIS for E */ /* Display ON/OFF Control defines */ #define DON 0b00001111 /* Display on */ #define DOFF 0b00001011 /* Display off */ //#define CURSOR_ON 0b00001111 /* Cursor on */ #define CURSOR_ON 0b00001110 /* Cursor on */ //#define CURSOR_OFF 0b00001101 /* Cursor off */ #define CURSOR_OFF 0b00001100 /* Cursor off */ //#define BLINK_ON 0b00001111 /* Cursor Blink */ #define BLINK_ON 0b00001101 /* Cursor Blink */ //#define BLINK_OFF 0b00001110 /* Cursor No Blink */ #define BLINK_OFF 0b00001100 /* Cursor No Blink */ /* Cursor or Display Shift defines */ #define SHIFT_CUR_LEFT 0b00010011 /* Cursor shifts to the left */ #define SHIFT_CUR_RIGHT 0b00010111 /* Cursor shifts to the right */ #define SHIFT_DISP_LEFT 0b00011011 /* Display shifts to the left */ #define SHIFT_DISP_RIGHT 0b00011111 /* Display shifts to the right */ #define DISP_CLEAR 0b00000001 /* Function Set defines */ #define FOUR_BIT 0b00101111 /* 4-bit Interface */ #define EIGHT_BIT 0b00111111 /* 8-bit Interface */ #define LINE_5X7 0b00110011 /* 5x7 characters, single line */ #define LINE_5X10 0b00110111 /* 5x10 characters */ #define LINES_5X7 0b00111111 /* 5x7 characters, multiple line */ #define LINES_5X8 0b00111000 /* 5x8 characters, multiple line */ void XLCDInit(void); void XLCDPut(char data); void XLCDPutString(char *string); void XLCDPutROMString(const char *string); char XLCDIsBusy(void); void XLCDCommand(unsigned char cmd); unsigned char XLCDGetAddr(void); char XLCDGet(void); void XLCDGoto(unsigned char row, unsigned char col); #define XLCDClear() XLCDCommand(DISP_CLEAR) #define XLCDCursorRight() XLCDCommand(SHIFT_CUR_RIGHT) #define XLCDCursorLeft() XLCDCommand(SHIFT_CUR_LEFT) #define XLCDShiftLeft() XLCDCommand(SHIFT_DISP_LEFT) #define XLCDShiftRight() XLCDCommand(SHIFT_DISP_RIGHT) #define XLCDCursorOn() XLCDCommand(CURSOR_ON) #define XLCDBlinkOn() XLCDCommand(BLINK_ON) #define XLCDCursorOff() XLCDCommand(CURSOR_OFF) #define XLCDBlinkOff() XLCDCommand(BLINK_OFF) #define XLCDCGRAMAddr(addr) XLCDCommand(addr | 0b01000000) #define XLCDDDRAMAddr(addr) XLCDCommand(addr | 0b10000000) /* User defines these routines/macros according to the oscillator frequency */ #endif