PIC18 LaurTec Library  3.3.1
Open Source C Library for PIC18 Microcontrollers based on C18 - XC8 Compilers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
LCD_44780_I2C.h File Reference
#include <delay.h>
#include <i2c.h>
#include <ctype.h>

Go to the source code of this file.

Macros

#define LCD_D0   0b00000001
 
#define LCD_D1   0b00000010
 
#define LCD_D2   0b00000100
 
#define LCD_D3   0b00001000
 
#define LCD_E   0b00010000
 
#define LCD_RW   0b00100000
 
#define LCD_RS   0b01000000
 
#define LCD_LED   0b10000000
 
#define PCF8574_ADDRESS_H   0x70
 
#define PCF8574_ADDRESS_L   0x00
 
#define LEFT   0b00000000
 
#define RIGHT   0b00000100
 
#define LCD_LEFT   0b00000000
 
#define LCD_RIGHT   0b00000100
 
#define TURN_ON_CURSOR   0b00000010
 
#define TURN_OFF_CURSOR   0b00000000
 
#define LCD_TURN_ON_CURSOR   0b00000010
 
#define LCD_TURN_OFF_CURSOR   0b00000000
 
#define TURN_ON_LED_LCD   0b00000000
 
#define TURN_OFF_LED_LCD   0b10000000
 
#define LCD_TURN_ON_LED   0b00000000
 
#define LCD_TURN_OFF_LED   0b10000000
 
#define BLINKING_ON   0b00000001
 
#define BLINKING_OFF   0b00000000
 
#define LCD_BLINKING_ON   0b00000001
 
#define LCD_BLINKING_OFF   0b00000000
 
#define BUS_DATA_RATE_LCD   100
 
#define LCD_BUS_DATA_RATE   100
 
#define enable_pulse_LCD   LCD_enable_pulse
 
#define Epulse   enable_pulse_LCD
 
#define send_command_LCD   LCD_send_command
 
#define SendCommand   send_command_LCD
 
#define home_LCD   LCD_home
 
#define HomeLCD   home_LCD
 
#define shift_LCD   LCD_shift
 
#define ShiftLCD   shift_LCD
 
#define shift_cursor_LCD   LCD_shift_cursor
 
#define ShiftCursorLCD   shift_cursor_LCD
 
#define goto_line_LCD   LCD_goto_line
 
#define GotoLineLCD   goto_line_LCD
 
#define goto_xy_LCD   LCD_goto_xy
 
#define write_char_LCD   LCD_write_char
 
#define WriteCharLCD   write_char_LCD
 
#define write_message_LCD   LCD_write_message
 
#define WriteStringLCD   write_message_LCD
 
#define write_string_LCD   LCD_write_string
 
#define WriteVarLCD   write_string_LCD
 
#define write_integer_LCD   LCD_write_integer
 
#define WriteIntLCD   write_integer_LCD
 
#define clear_LCD   LCD_clear
 
#define ClearLCD   clear_LCD
 
#define cursor_LCD   LCD_cursor
 
#define CursorLCD   cursor_LCD
 
#define backlight_LCD   LCD_backlight
 
#define BacklightLCD   backlight_LCD
 
#define initialize_LCD   LCD_initialize
 
#define OpenLCD   initialize_LCD
 

Functions

void LCD_enable_pulse (void)
 
void LCD_send_command (unsigned char data)
 
void LCD_home (void)
 
void LCD_shift (unsigned char shift, unsigned char number_of_shift)
 
void LCD_shift_cursor (unsigned char shift, unsigned char number_of_shift)
 
void goto_line_LCD (unsigned char line)
 
void goto_xy_LCD (unsigned char x, unsigned char y)
 
void LCD_write_char (unsigned char value)
 
void LCD_write_message (const rom unsigned char *buffer)
 
void LCD_write_string (unsigned char *buffer)
 
void LCD_write_integer (int value, unsigned char number_of_digits)
 
void LCD_clear (void)
 
void LCD_cursor (unsigned char active, unsigned char blinking)
 
void LCD_backlight (unsigned char active)
 
void LCD_initialize (unsigned char quartz_frequency)
 

Macro Definition Documentation

#define backlight_LCD   LCD_backlight

Definition at line 335 of file LCD_44780_I2C.h.

#define BacklightLCD   backlight_LCD

Definition at line 336 of file LCD_44780_I2C.h.

#define BLINKING_OFF   0b00000000

Definition at line 132 of file LCD_44780_I2C.h.

#define BLINKING_ON   0b00000001

Definition at line 131 of file LCD_44780_I2C.h.

#define BUS_DATA_RATE_LCD   100

Definition at line 136 of file LCD_44780_I2C.h.

#define clear_LCD   LCD_clear

Definition at line 304 of file LCD_44780_I2C.h.

#define ClearLCD   clear_LCD

Definition at line 305 of file LCD_44780_I2C.h.

#define cursor_LCD   LCD_cursor

Definition at line 320 of file LCD_44780_I2C.h.

#define CursorLCD   cursor_LCD

Definition at line 321 of file LCD_44780_I2C.h.

#define enable_pulse_LCD   LCD_enable_pulse

Definition at line 150 of file LCD_44780_I2C.h.

#define Epulse   enable_pulse_LCD

Definition at line 151 of file LCD_44780_I2C.h.

#define goto_line_LCD   LCD_goto_line

Definition at line 215 of file LCD_44780_I2C.h.

#define goto_xy_LCD   LCD_goto_xy

Definition at line 230 of file LCD_44780_I2C.h.

#define GotoLineLCD   goto_line_LCD

Definition at line 216 of file LCD_44780_I2C.h.

#define home_LCD   LCD_home

Definition at line 172 of file LCD_44780_I2C.h.

#define HomeLCD   home_LCD

Definition at line 173 of file LCD_44780_I2C.h.

#define initialize_LCD   LCD_initialize

Definition at line 349 of file LCD_44780_I2C.h.

#define LCD_BLINKING_OFF   0b00000000

Definition at line 134 of file LCD_44780_I2C.h.

#define LCD_BLINKING_ON   0b00000001

Definition at line 133 of file LCD_44780_I2C.h.

#define LCD_BUS_DATA_RATE   100

Definition at line 137 of file LCD_44780_I2C.h.

#define LCD_D0   0b00000001

Definition at line 90 of file LCD_44780_I2C.h.

#define LCD_D1   0b00000010

Definition at line 91 of file LCD_44780_I2C.h.

#define LCD_D2   0b00000100

Definition at line 92 of file LCD_44780_I2C.h.

#define LCD_D3   0b00001000

Definition at line 93 of file LCD_44780_I2C.h.

#define LCD_E   0b00010000

Definition at line 94 of file LCD_44780_I2C.h.

#define LCD_LED   0b10000000

Definition at line 97 of file LCD_44780_I2C.h.

#define LCD_LEFT   0b00000000

Definition at line 118 of file LCD_44780_I2C.h.

#define LCD_RIGHT   0b00000100

Definition at line 119 of file LCD_44780_I2C.h.

#define LCD_RS   0b01000000

Definition at line 96 of file LCD_44780_I2C.h.

#define LCD_RW   0b00100000

Definition at line 95 of file LCD_44780_I2C.h.

#define LCD_TURN_OFF_CURSOR   0b00000000

Definition at line 124 of file LCD_44780_I2C.h.

#define LCD_TURN_OFF_LED   0b10000000

Definition at line 129 of file LCD_44780_I2C.h.

#define LCD_TURN_ON_CURSOR   0b00000010

Definition at line 123 of file LCD_44780_I2C.h.

#define LCD_TURN_ON_LED   0b00000000

Definition at line 128 of file LCD_44780_I2C.h.

#define LEFT   0b00000000

Definition at line 116 of file LCD_44780_I2C.h.

#define OpenLCD   initialize_LCD

Definition at line 350 of file LCD_44780_I2C.h.

#define PCF8574_ADDRESS_H   0x70

Definition at line 109 of file LCD_44780_I2C.h.

#define PCF8574_ADDRESS_L   0x00

Definition at line 111 of file LCD_44780_I2C.h.

#define RIGHT   0b00000100

Definition at line 117 of file LCD_44780_I2C.h.

#define send_command_LCD   LCD_send_command

Definition at line 163 of file LCD_44780_I2C.h.

#define SendCommand   send_command_LCD

Definition at line 164 of file LCD_44780_I2C.h.

#define shift_cursor_LCD   LCD_shift_cursor

Definition at line 203 of file LCD_44780_I2C.h.

#define shift_LCD   LCD_shift

Definition at line 187 of file LCD_44780_I2C.h.

#define ShiftCursorLCD   shift_cursor_LCD

Definition at line 204 of file LCD_44780_I2C.h.

#define ShiftLCD   shift_LCD

Definition at line 188 of file LCD_44780_I2C.h.

#define TURN_OFF_CURSOR   0b00000000

Definition at line 122 of file LCD_44780_I2C.h.

#define TURN_OFF_LED_LCD   0b10000000

Definition at line 127 of file LCD_44780_I2C.h.

#define TURN_ON_CURSOR   0b00000010

Definition at line 121 of file LCD_44780_I2C.h.

#define TURN_ON_LED_LCD   0b00000000

Definition at line 126 of file LCD_44780_I2C.h.

#define write_char_LCD   LCD_write_char

Definition at line 241 of file LCD_44780_I2C.h.

#define write_integer_LCD   LCD_write_integer

Definition at line 295 of file LCD_44780_I2C.h.

#define write_message_LCD   LCD_write_message

Definition at line 263 of file LCD_44780_I2C.h.

#define write_string_LCD   LCD_write_string

Definition at line 277 of file LCD_44780_I2C.h.

#define WriteCharLCD   write_char_LCD

Definition at line 242 of file LCD_44780_I2C.h.

#define WriteIntLCD   write_integer_LCD

Definition at line 296 of file LCD_44780_I2C.h.

#define WriteStringLCD   write_message_LCD

Definition at line 264 of file LCD_44780_I2C.h.

#define WriteVarLCD   write_string_LCD

Definition at line 278 of file LCD_44780_I2C.h.

Function Documentation

void goto_line_LCD ( unsigned char  line)

This function locates the LCD cursor on the selected line. Tested on 20x4 16x2 LCD displays.

Parameters
lineSpecify the number of the line [1,2,3,4]
Warning
It might not work with all the LCD Displays.
void goto_xy_LCD ( unsigned char  x,
unsigned char  y 
)

This function locates the LCD cursor to an arbitrary X Y location. Y represents the line number from top.

Parameters
xIt Specifies horizontal position
yIt Specifies vertical position (line number)
Warning
It might not work with all the LCD Displays. Tested on 20x4 16x2 LCD displays.
void LCD_backlight ( unsigned char  active)

This function controls the backligth LED.

Parameters
activeActivate the LED backlight [LCD_TURN_ON_LED, LCD_TURN_OFF_LED]
blinkingLet the cursor blink [LCD_BLINKING_ON, LCD_BLINKING_OFF]
Note
You must use the constant LCD_TURN_ON_LED, LCD_TURN_OFF_LED to ensure the compatibility with LCD_44780 library.

This function controls the backligth LED.

Parameters
activeActivate the LED backlight [LCD_TURN_ON_LED, LCD_TURN_OFF_LED]
blinkingLet the cursor blink [LCD_BLINKING_ON, LCD_BLINKING_OFF]
Note
You must use the constant LCD_TURN_ON_LED, LCD_TURN_OFF_LED to ensure the compatibility with LCD_44780_I2C library.

Definition at line 275 of file LCD_44780.c.

References data_buffer, LCD_LED, LCD_TURN_ON_LED, PCF8574_address, and write_data_PCF8574.

void LCD_clear ( void  )

This Function cleans the LCD display.

Definition at line 257 of file LCD_44780.c.

References LCD_send_command().

void LCD_cursor ( unsigned char  active,
unsigned char  blinking 
)

This function controls the cursor option (blinking, active)

Parameters
activeActivate the cursor, showing it or not [LCD_TURN_ON_CURSOR, LCD_TURN_OFF_CURSOR]
blinkingLet the cursor blink [LCD_BLINK_ON, LCD_BLINK_OFF]
Note
You must use the constant LCD_TURN_ON_CURSOR, LCD_TURN_OFF_CURSOR, LCD_BLINKING_ON, LCD_BLINKING_OFF to ensure the compatibility with LCD_44780 library.

This function controls the cursor option (blinking, active)

Parameters
activeActivate the cursor, showing it or not [LCD_TURN_ON_CURSOR, LCD_TURN_OFF_CURSOR]
blinkingLet the cursor blink [LCD_BLINKING_ON, LCD_BLINKING_OFF]
Note
You must use the constant LCD_TURN_ON_CURSOR, LCD_TURN_OFF_CURSOR, LCD_BLINKING_ON, LCD_BLINKING_OFF to ensure the compatibility with LCD_44780_I2C library.

Definition at line 266 of file LCD_44780.c.

References LCD_send_command().

void LCD_enable_pulse ( void  )

This function generates the Enable pulse.

Warning
This function is a Private one. It should not be used by the user.

Definition at line 49 of file LCD_44780.c.

References data_buffer, delay_ms(), LCD_E, PCF8574_address, and write_data_PCF8574.

void LCD_home ( void  )

This function locates the cursor at home location. First line first character.

Definition at line 74 of file LCD_44780.c.

References LCD_send_command().

void LCD_initialize ( unsigned char  quartz_frequency)

This function initializes the LCD to work in 4 bit modality.

Parameters
quartz_frequencyQuartz freq. expressed in MHz used to run the CPU.
Note
You must properly set the microcontroller pins using the TRISx registers The library requires the delay library to be included.

Definition at line 283 of file LCD_44780.c.

References delay_ms(), delay_set_quartz(), LCD_clear(), LCD_cursor(), LCD_E, LCD_RS, LCD_RW, and LCD_send_command().

void LCD_send_command ( unsigned char  data)

This function generates the Enable pulse.

Parameters
dataData to be sent [0..255]
Warning
This function is a Private one. It should not be used by the user.

Definition at line 67 of file LCD_44780_I2C.c.

References data_buffer, LCD_enable_pulse(), PCF8574_address, and write_data_PCF8574.

void LCD_shift ( unsigned char  shift,
unsigned char  number_of_shift 
)

This function shifts the LCD screen on the left or right.

Parameters
shiftSpecify where the shift should be [LCD_LEFT, LCD_RIGHT].
number_of_shiftSpecify the number of times the shift is executed.
Note
Use the constants LEFT, RIGHT to specify the direction to ensure the compatibility with LCD_44780 library.

This function shifts the LCD screen on the left or right.

Parameters
shiftSpecify where the shift should be [LCD_LEFT, LCD_RIGHT].
number_of_shiftSpecify the number of times the shift is executed.
Note
Use the constants LEFT, RIGHT to specify the direction to ensure the compatibility with LCD_44780_I2C library.

Definition at line 84 of file LCD_44780.c.

References LCD_send_command().

void LCD_shift_cursor ( unsigned char  shift,
unsigned char  number_of_shift 
)

This function shifts the LCD cursor on the left or right. The position of the cursor is where the next writting will be performed.

Parameters
shiftSpecify where the shift should be [LCD_LEFT, LCD_RIGHT].
number_of_shiftSpecify the number of times the shift is executed.
Note
Use the constants LEFT, RIGHT to specify the direction to ensure the compatibility with LCD_44780 library.

This function shifts the LCD cursor on the left or right. The position of the cursor is where the next writing will be performed.

Parameters
shiftSpecify where the shift should be [LCD_LEFT, LCD_RIGHT].
number_of_shiftSpecify the number of times the shift is executed.
Note
Use the constants LEFT, RIGHT to specify the direction to ensure the compatibility with LCD_44780_I2C library.

Definition at line 98 of file LCD_44780.c.

References LCD_send_command().

void LCD_write_char ( unsigned char  value)

This function writes a char to the LCD display. (e.g LCD_write_char ('a'); )

Parameters
valueSpecify the character to be sent [0-128 ASCII code].
Note
The function accept ASCII integer or constants 'a'..'z'.

Definition at line 145 of file LCD_44780.c.

References data_buffer, LCD_RS, LCD_send_command(), PCF8574_address, and write_data_PCF8574.

void LCD_write_integer ( int  value,
unsigned char  number_of_digits 
)

This function writes an integer to the LCD display. The integer is converted to string.

Parameters
valueIt is integer that must be written to the LCD display.
numeber_of_digitsIt specifies the number of shown digit [0-5]. 0: Left Justified 1-5: Right Justified with n digit
Note
If you set a number of digit less than required the digit will be lost starting from the less significant digit. Minus is like a digit.

Definition at line 217 of file LCD_44780_I2C.c.

References LCD_write_string().

void LCD_write_message ( const rom unsigned char *  buffer)

This function writes a const string to the LCD display, e.g LCD_write_message ("Hello"); .

Parameters
bufferIs a const string written in rom (is not an array).
Note
The function accepts strings written in rom (constant), it does not accept array. To write arrays refers the write_string_LCD () function.

This function writes a const string to the LCD display, e.g LCD_write_message("Hello"); .

Parameters
bufferIs a const string written in rom (is not an array).
Note
The function accepts strings written in rom (constant), it does not accept array. To write arrays refers the LCD_write_string () function.

Definition at line 174 of file LCD_44780.c.

References LCD_write_char(), and LCD_write_message().

void LCD_write_string ( unsigned char *  buffer)

This function writes an array of char to the LCD display, terminated with /0 .

Parameters
bufferIt is an array of char terminated with /0 .
Note
The function accepts strings within an array. To use const array within rom use write_message_LCD ().

This function writes an array of char to the LCD display, terminated with /0 .

Parameters
bufferIt is an array of char terminated with /0 .
Note
The function accepts strings within an array. To use const array within flash use LCD_write_message ().

Definition at line 194 of file LCD_44780.c.

References LCD_write_char().