LTlib LaurTec Library  4.0.0 Beta
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
LCD_44780.h File Reference
#include <ctype.h>
#include "LTlib.h"

Go to the source code of this file.

Macros

#define LCD_D0   PORTDbits.RD4
 
#define LCD_D1   PORTDbits.RD5
 
#define LCD_D2   PORTDbits.RD6
 
#define LCD_D3   PORTDbits.RD7
 
#define LCD_RS   PORTDbits.RD2
 
#define LCD_E   PORTDbits.RD3
 
#define LCD_RW   PORTDbits.RD1
 
#define LCD_LED   PORTCbits.RC1
 
#define LCD_D0_TRIS   TRISDbits.TRISD4
 
#define LCD_D1_TRIS   TRISDbits.TRISD5
 
#define LCD_D2_TRIS   TRISDbits.TRISD6
 
#define LCD_D3_TRIS   TRISDbits.TRISD7
 
#define LCD_RS_TRIS   TRISDbits.TRISD2
 
#define LCD_E_TRIS   TRISDbits.TRISD3
 
#define LCD_RW_TRIS   TRISDbits.TRISD1
 
#define LCD_LED_TRIS   TRISCbits.TRISC1
 
#define LEFT   0
 
#define RIGHT   1
 
#define LCD_LEFT   0
 
#define LCD_RIGHT   1
 
#define TURN_ON_LED_LCD   1
 
#define TURN_OFF_LED_LCD   0
 
#define LCD_TURN_ON_LED   1
 
#define LCD_TURN_OFF_LED   0
 
#define LCD_TURN_ON_LED   1
 
#define LCD_TURN_OFF_LED   0
 
#define TURN_ON_CURSOR   1
 
#define TURN_OFF_CURSOR   0
 
#define LCD_TURN_ON_CURSOR   1
 
#define LCD_TURN_OFF_CURSOR   0
 
#define BLINKING_ON   1
 
#define BLINKING_OFF   0
 
#define LCD_BLINKING_ON   1
 
#define LCD_BLINKING_OFF   0
 
#define ZERO_CLEANING_ON   0x01
 
#define ZERO_CLEANING_OFF   0x00
 
#define LCD_ZERO_CLEANING_ON   0x01
 
#define LCD_ZERO_CLEANING_OFF   0x00
 
#define enable_pulse_LCD   LCD_enable_pulse
 
#define send_command_LCD   LCD_send_command
 
#define home_LCD   LCD_home
 
#define shift_LCD   LCD_shift
 
#define shift_cursor_LCD   LCD_shift_cursor
 
#define goto_line_LCD   LCD_goto_line
 
#define goto_xy_LCD   LCD_goto_xy
 
#define write_char_LCD   LCD_write_char
 
#define write_message_LCD   LCD_write_message
 
#define write_string_LCD   LCD_write_string
 
#define write_integer_LCD   LCD_write_integer
 
#define clear_LCD   LCD_clear
 
#define cursor_LCD   LCD_cursor
 
#define backlight_LCD   LCD_backlight
 
#define initialize_LCD   LCD_initialize
 

Functions

void LCD_enable_pulse (void)
 
void LCD_send_command (unsigned char bit_3, unsigned char bit_2, unsigned char bit_1, unsigned char bit_0)
 
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 LCD_goto_line (unsigned char line)
 
void LCD_goto_xy (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, unsigned char zero_cleaning)
 
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 349 of file LCD_44780.h.

#define BLINKING_OFF   0

Definition at line 151 of file LCD_44780.h.

#define BLINKING_ON   1

Definition at line 150 of file LCD_44780.h.

#define clear_LCD   LCD_clear

Definition at line 320 of file LCD_44780.h.

#define cursor_LCD   LCD_cursor

Definition at line 335 of file LCD_44780.h.

#define enable_pulse_LCD   LCD_enable_pulse

Definition at line 170 of file LCD_44780.h.

#define goto_line_LCD   LCD_goto_line

Definition at line 236 of file LCD_44780.h.

#define goto_xy_LCD   LCD_goto_xy

Definition at line 250 of file LCD_44780.h.

#define home_LCD   LCD_home

Definition at line 196 of file LCD_44780.h.

#define initialize_LCD   LCD_initialize

Definition at line 362 of file LCD_44780.h.

#define LCD_BLINKING_OFF   0

Definition at line 153 of file LCD_44780.h.

#define LCD_BLINKING_ON   1

Definition at line 152 of file LCD_44780.h.

#define LCD_D0   PORTDbits.RD4

Definition at line 105 of file LCD_44780.h.

#define LCD_D0_TRIS   TRISDbits.TRISD4

Definition at line 115 of file LCD_44780.h.

#define LCD_D1   PORTDbits.RD5

Definition at line 106 of file LCD_44780.h.

#define LCD_D1_TRIS   TRISDbits.TRISD5

Definition at line 116 of file LCD_44780.h.

#define LCD_D2   PORTDbits.RD6

Definition at line 107 of file LCD_44780.h.

#define LCD_D2_TRIS   TRISDbits.TRISD6

Definition at line 117 of file LCD_44780.h.

#define LCD_D3   PORTDbits.RD7

Definition at line 108 of file LCD_44780.h.

#define LCD_D3_TRIS   TRISDbits.TRISD7

Definition at line 118 of file LCD_44780.h.

#define LCD_E   PORTDbits.RD3

Definition at line 110 of file LCD_44780.h.

#define LCD_E_TRIS   TRISDbits.TRISD3

Definition at line 120 of file LCD_44780.h.

#define LCD_LED   PORTCbits.RC1

Definition at line 112 of file LCD_44780.h.

#define LCD_LED_TRIS   TRISCbits.TRISC1

Definition at line 122 of file LCD_44780.h.

#define LCD_LEFT   0

Definition at line 133 of file LCD_44780.h.

#define LCD_RIGHT   1

Definition at line 134 of file LCD_44780.h.

#define LCD_RS   PORTDbits.RD2

Definition at line 109 of file LCD_44780.h.

#define LCD_RS_TRIS   TRISDbits.TRISD2

Definition at line 119 of file LCD_44780.h.

#define LCD_RW   PORTDbits.RD1

Definition at line 111 of file LCD_44780.h.

#define LCD_RW_TRIS   TRISDbits.TRISD1

Definition at line 121 of file LCD_44780.h.

#define LCD_TURN_OFF_CURSOR   0

Definition at line 148 of file LCD_44780.h.

#define LCD_TURN_OFF_LED   0

Definition at line 142 of file LCD_44780.h.

#define LCD_TURN_OFF_LED   0

Definition at line 142 of file LCD_44780.h.

#define LCD_TURN_ON_CURSOR   1

Definition at line 147 of file LCD_44780.h.

#define LCD_TURN_ON_LED   1

Definition at line 141 of file LCD_44780.h.

#define LCD_TURN_ON_LED   1

Definition at line 141 of file LCD_44780.h.

#define LCD_ZERO_CLEANING_OFF   0x00

Definition at line 158 of file LCD_44780.h.

#define LCD_ZERO_CLEANING_ON   0x01

Definition at line 157 of file LCD_44780.h.

#define LEFT   0

Definition at line 131 of file LCD_44780.h.

#define RIGHT   1

Definition at line 132 of file LCD_44780.h.

#define send_command_LCD   LCD_send_command

Definition at line 188 of file LCD_44780.h.

#define shift_cursor_LCD   LCD_shift_cursor

Definition at line 225 of file LCD_44780.h.

#define shift_LCD   LCD_shift

Definition at line 210 of file LCD_44780.h.

#define TURN_OFF_CURSOR   0

Definition at line 146 of file LCD_44780.h.

#define TURN_OFF_LED_LCD   0

Definition at line 137 of file LCD_44780.h.

#define TURN_ON_CURSOR   1

Definition at line 145 of file LCD_44780.h.

#define TURN_ON_LED_LCD   1

Definition at line 136 of file LCD_44780.h.

#define write_char_LCD   LCD_write_char

Definition at line 261 of file LCD_44780.h.

#define write_integer_LCD   LCD_write_integer

Definition at line 312 of file LCD_44780.h.

#define write_message_LCD   LCD_write_message

Definition at line 281 of file LCD_44780.h.

#define write_string_LCD   LCD_write_string

Definition at line 293 of file LCD_44780.h.

#define ZERO_CLEANING_OFF   0x00

Definition at line 156 of file LCD_44780.h.

#define ZERO_CLEANING_ON   0x01

Definition at line 155 of file LCD_44780.h.

Function Documentation

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_I2C library.

Definition at line 274 of file LCD_44780.c.

void LCD_clear ( void  )

This Function cleans the LCD display.

Definition at line 256 of file LCD_44780.c.

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_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 265 of file LCD_44780.c.

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 48 of file LCD_44780.c.

void LCD_goto_line ( unsigned char  line)

This function locates the LCD cursor on the selected line.

Parameters
lineSpecify the number of the line [1,2,3,4]
Warning
It might not work with all the LCD Displays. Tested on 20x4 16x2 LCD displays.

Definition at line 110 of file LCD_44780.c.

References LCD_send_command().

void LCD_goto_xy ( 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.

Definition at line 135 of file LCD_44780.c.

References LCD_goto_line(), LCD_shift_cursor(), and RIGHT.

void LCD_home ( void  )

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

Definition at line 73 of file LCD_44780.c.

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 282 of file LCD_44780.c.

void LCD_send_command ( unsigned char  bit_3,
unsigned char  bit_2,
unsigned char  bit_1,
unsigned char  bit_0 
)

This function generates the Enable pulse.

Parameters
bit_0bit 0 of the data bus (4 bit modality)
bit_1bit 1 of the data bus (4 bit modality)
bit_2bit 2 of the data bus (4 bit modality)
bit_3bit 3 of the data bus (4 bit modality)
Warning
This function is a Private one. It should not be used by the user.

Definition at line 60 of file LCD_44780.c.

References LCD_D0, LCD_D1, LCD_D2, LCD_D3, and LCD_enable_pulse().

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_I2C library.

Definition at line 83 of file LCD_44780.c.

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 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 97 of file LCD_44780.c.

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 144 of file LCD_44780.c.

void LCD_write_integer ( int  value,
unsigned char  number_of_digits,
unsigned char  zero_cleaning 
)

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
zero_cleaningIt specifies whether the left zero must be removed [LCD_ZERO_CLEANING_ON, LCD_ZERO_CLEANING_OFF].
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.
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 LCD_write_string () function.

Definition at line 173 of file LCD_44780.c.

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 flash use LCD_write_message ().

Definition at line 193 of file LCD_44780.c.