LTlib LaurTec Library  4.0.3
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
LCD_44780.h
Go to the documentation of this file.
1 /*******************************************************************************
2 
3 Author : Mauro Laurenti
4 Version : 1.7
5 
6 Created on Date : 04/09/2006
7 Last update : 15/12/2014
8 
9 CopyRight 2006-2014 all rights are reserved
10 
11 ********************************************************
12 SOFTWARE LICENSE AGREEMENT
13 ********************************************************
14 
15 The usage of the supplied software imply the acceptance of the following license.
16 
17 The software supplied herewith by Mauro Laurenti (the Author) is intended for
18 use solely and exclusively on Microchip PIC Microcontroller (registered mark).
19 The software is owned by the Author, and is protected under applicable
20 copyright laws. All rights are reserved.
21 Any use in violation of the foregoing restrictions may subject the
22 user to criminal sanctions under applicable laws, as well as to civil liability
23 for the breach of the terms and conditions of this license.
24 Commercial use is forbidden without a written acknowledgement with the Author.
25 Personal or educational use is allowed if the application containing the
26 following software doesn't aim to commercial use or monetary earning of any kind.
27 
28 THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
29 WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
30 TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
31 PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE AUTHOR SHALL NOT,
32 IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
33 CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
34 
35 
36 ********************************************************
37 PURPOSES
38 ********************************************************
39 
40 
41  This library contains all the functions that are handy for controlling
42  an LCD with a 44780 Hitachi controller.
43 
44  To use these functions for your purpose you must set up properly
45  the LCD constants and the pins of the PORT/s that you will use.
46  You can use any pin you want!
47 
48 *******************************************************************************/
49 
50 #ifndef LTLIB_LCD_44780_H
51 #define LTLIB_LCD_44780_H
52 
53 #ifdef __XC8
54  #include <xc.h>
55  #include <stdlib.h>
56 #endif
57 
58 #ifndef __XC8
59  #include <ctype.h>
60 #endif
61 
62 
63 //*****************************************
64 // Library Test
65 //*****************************************
66 #include "LTlib.h"
67 
68 #ifndef LTLIB_DELAY_H
69  #error The LCD_44780 Library requires the "delay" library to be included.
70 #endif
71 
72 
73 //**************************************************
74 // HW Initialization
75 // This section must be properly initialized according
76 // to the LCD connections
77 //**************************************************
78 
79 #ifdef _PIC18
80 
81  // LAT Register settings
82  #define LCD_D0 LATDbits.LATD4
83  #define LCD_D1 LATDbits.LATD5
84  #define LCD_D2 LATDbits.LATD6
85  #define LCD_D3 LATDbits.LATD7
86  #define LCD_RS LATDbits.LATD2
87  #define LCD_E LATDbits.LATD3
88  #define LCD_RW LATDbits.LATD1
89  #define LCD_LED LATCbits.LATC1
90 
91  // TRIS Register settings
92  #define LCD_D0_TRIS TRISDbits.RD4
93  #define LCD_D1_TRIS TRISDbits.RD5
94  #define LCD_D2_TRIS TRISDbits.RD6
95  #define LCD_D3_TRIS TRISDbits.RD7
96  #define LCD_RS_TRIS TRISDbits.RD2
97  #define LCD_E_TRIS TRISDbits.RD3
98  #define LCD_RW_TRIS TRISDbits.RD1
99  #define LCD_LED_TRIS TRISCbits.RC1
100 
101 #endif
102 
103 #ifndef _PIC18
104  // PORT Register settings
105  #define LCD_D0 PORTDbits.RD4
106  #define LCD_D1 PORTDbits.RD5
107  #define LCD_D2 PORTDbits.RD6
108  #define LCD_D3 PORTDbits.RD7
109  #define LCD_RS PORTDbits.RD2
110  #define LCD_E PORTDbits.RD3
111  #define LCD_RW PORTDbits.RD1
112  #define LCD_LED PORTCbits.RC1
113 
114 // TRIS Register settings
115  #define LCD_D0_TRIS TRISDbits.TRISD4
116  #define LCD_D1_TRIS TRISDbits.TRISD5
117  #define LCD_D2_TRIS TRISDbits.TRISD6
118  #define LCD_D3_TRIS TRISDbits.TRISD7
119  #define LCD_RS_TRIS TRISDbits.TRISD2
120  #define LCD_E_TRIS TRISDbits.TRISD3
121  #define LCD_RW_TRIS TRISDbits.TRISD1
122  #define LCD_LED_TRIS TRISCbits.TRISC1
123 #endif
124 
125 
126 
127 //**************************************************
128 // Constant Definitions
129 //**************************************************
130 
131 #define LEFT 0
132 #define RIGHT 1
133 #define LCD_LEFT 0
134 #define LCD_RIGHT 1
135 
136 #define TURN_ON_LED_LCD 1
137 #define TURN_OFF_LED_LCD 0
138 #define LCD_TURN_ON_LED 1
139 #define LCD_TURN_OFF_LED 0
140 
141 #define LCD_TURN_ON_LED 1
142 #define LCD_TURN_OFF_LED 0
143 
144 
145 #define TURN_ON_CURSOR 1
146 #define TURN_OFF_CURSOR 0
147 #define LCD_TURN_ON_CURSOR 1
148 #define LCD_TURN_OFF_CURSOR 0
149 
150 #define BLINKING_ON 1
151 #define BLINKING_OFF 0
152 #define LCD_BLINKING_ON 1
153 #define LCD_BLINKING_OFF 0
154 
155 #define ZERO_CLEANING_ON 0x01
156 #define ZERO_CLEANING_OFF 0x00
157 #define LCD_ZERO_CLEANING_ON 0x01
158 #define LCD_ZERO_CLEANING_OFF 0x00
159 
160 //**************************************************
161 
162 
169 void LCD_enable_pulse (void);
170 #define enable_pulse_LCD LCD_enable_pulse
171 
172 
187 void LCD_send_command (unsigned char bit_3, unsigned char bit_2, unsigned char bit_1, unsigned char bit_0);
188 #define send_command_LCD LCD_send_command
189 
190 
195 void LCD_home(void);
196 #define home_LCD LCD_home
197 
198 
209 void LCD_shift(unsigned char shift, unsigned char number_of_shift);
210 #define shift_LCD LCD_shift
211 
212 
224 void LCD_shift_cursor(unsigned char shift,unsigned char number_of_shift);
225 #define shift_cursor_LCD LCD_shift_cursor
226 
227 
235 void LCD_goto_line (unsigned char line);
236 #define goto_line_LCD LCD_goto_line
237 
238 
249 void LCD_goto_xy (unsigned char x, unsigned char y);
250 #define goto_xy_LCD LCD_goto_xy
251 
252 
260 void LCD_write_char (unsigned char value);
261 #define write_char_LCD LCD_write_char
262 
263 
273 #ifndef __XC8
274 void LCD_write_message(const rom unsigned char *buffer);
275 #endif
276 
277 #ifdef __XC8
278 void LCD_write_message(const unsigned char *buffer);
279 #endif
280 
281 #define write_message_LCD LCD_write_message
282 
283 
292 void LCD_write_string(unsigned char *buffer);
293 #define write_string_LCD LCD_write_string
294 
295 
311 void LCD_write_integer(int value, unsigned char number_of_digits, unsigned char zero_cleaning);
312 #define write_integer_LCD LCD_write_integer
313 
314 
319 void LCD_clear (void);
320 #define clear_LCD LCD_clear
321 
322 
334 void LCD_cursor(unsigned char active, unsigned char blinking);
335 #define cursor_LCD LCD_cursor
336 
337 
348 void LCD_backlight(unsigned char active);
349 #define backlight_LCD LCD_backlight
350 
351 
361 void LCD_initialize(unsigned char quartz_frequency);
362 #define initialize_LCD LCD_initialize
363 
364 #endif