-
Notifications
You must be signed in to change notification settings - Fork 1
4. How to use in own Project
-
Copy/place LCD library src files into your project folders and add copied files in your project configuration to make them possible to include in your project.
- If you are NOT using AVR microcontroller you don't need to copy lcd_hd44780_avr_specific.c and lcd_hd44780_avr_specific.h file
- If you are using an AVR microcontroller you need to copy and add files listed above to your project and define fla "AVR" in the project configuration.
- if you don't want to specify custom characters you don't need to copy and add lcd_hd44780_def_char.h to your project.
-
In lcd_hd44780.config.h
- Define specyfic LCD_TYPE
LCD_TYPE -> set one of the predefined types:
2004 -> 4 lines 20 characters per line
1604 -> 4 lines 16 characters per line
1602 -> 2 lines 16 characters per line
- Define usage of RW Pin
USE_RW_PIN -> Defines HW connection between LCD and uC
ON - when RW pin is connected
OFF - when RW pin is not connected
- Define HW setup for LCD_BCKL_PIN
LCD_BCKL_PIN_EN_STATE -> Defines active state for enabling LCD backlight
HIGH - A high state on the output pin is required to enable the LCD backlight
LOW - A low state on the output pin is required to enable the LCD backlight
- Define usage of LCD buffering functionality LCD_BUFFERING
LCD_BUFFERING -> Defines whether you would like to use LCD buffer or only use functions to print directly on LCD screen
ON - when buffering of LCD is planned to be used in the project
OFF - when buffering of LCD is NOT planned to be used in the project
Code example:
/************************************ LCD HARDWARE SETTINGS ***************************************** * LCD_TYPE -> Set one of the predefined types: * 2004 -> 4 lines 20 characters per line * 1604 -> 4 lines 16 characters per line * 1602 -> 2 lines 16 characters per line * USE_RW_PIN -> Defines HW connection between LCD and uC * ON - when the RW pin is connected * OFF - when the RW pin is not connected * LCD_BCKL_PIN_EN_STATE -> Defines active state for enabling LCD backlight * HIGH - a high state on the output pin is required to enable the LCD backlight * LOW - a low state on the output pin is required to enable the LCD backlight * LCD_BUFFERING -> Defines whether you would like to use LCD buffer or print directly on LCD screen * ON - when buffering of LCD is planned to be used in the project * OFF - when buffering of LCD is NOT planned to be used in the project ******************************************************************************************************/ #define LCD_TYPE 1602 #define USE_RW_PIN OFF #define LCD_BCKL_PIN_EN_STATE HIGH #define LCD_BUFFERING ON
- Define specyfic LCD_TYPE
-
Add or remove specific features from the build by setting specific feature switch to ON or OFF.
When running without user-defined characters, set USE_DEF_CHAR_FUNCTION to OFF./******************************** LCD LIBRARY COMPILATION SETTINGS ************************ * Setting USE_(procedure name) to: * ON - add specific procedure to compilation * OFF - exclude specific procedure from compilation ********************************************************************************************/ #define USE_DEF_CHAR_FUNCTION OFF #define USE_LCD_INT ON #define USE_LCD_HEX ON #define USE_LCD_BIN ON #define USE_LCD_CURSOR_HOME ON #define USE_LCD_CURSOR_ON ON #define USE_LCD_CURSOR_OFF ON #define USE_LCD_BLINKING_CURSOR_ON ON #if LCD_BUFFERING == ON #define USE_LCD_BUF_INT ON #define USE_LCD_BUF_HEX ON #define USE_LCD_BUF_BIN ON #endif
-
Declare the LCD IO driver interface in your application on the GPIO driver side. This interface should contain the following implementation defined in lcd_hd44780_interface.h
/************LCD_IO_driver_interface implementation START**************/ struct LCD_IO_driver_interface_struct { LCD_interface_func_p init_LCD_pins; LCD_interface_func_p set_data_pins_as_outputs; LCD_interface_func_p set_data_pins_as_inputs; set_LCD_data_port_func_p write_data; get_LCD_data_port_func_p read_data; delay_us_func_p delay_us; LCD_interface_func_p set_LCD_E; LCD_interface_func_p reset_LCD_E; LCD_interface_func_p set_LCD_RS; LCD_interface_func_p reset_LCD_RS; LCD_interface_func_p set_LCD_RW; LCD_interface_func_p reset_LCD_RW; LCD_interface_func_p set_LCD_BCKL; LCD_interface_func_p reset_LCD_BCKL; }; const struct LCD_IO_driver_interface_struct *LCD_IO_driver_interface_get(void) { return &LCD_IO_driver; }
It's a basic interface that connects the library with your HW driver layer in the application without making any dependencies between them.
In .examples/lcd_driver_intrface_example_implementations folder you can find a template with empty definitions of all required interface elements as well as a few files with examples of implementation for different microcontrollers. Additional details of the implementation in the project can be also found in ready-to-compile examples.
-
Copy/place LCD library src files into your project folders and add copied files in your project configuration to make them possible to include in your project.
- If you are NOT using AVR microcontroller you don't need to copy lcd_hd44780_avr_specific.c and lcd_hd44780_avr_specific.h file
- If you are using an AVR microcontroller you need to copy and add files listed above to your project and define fla "AVR" in the project configuration.
-
In lcd_hd44780.config.h
- Define specyfic LCD_TYPE
LCD_TYPE -> set one of the predefined types:
2004 -> 4 lines 20 characters per line
1604 -> 4 lines 16 characters per line
1602 -> 2 lines 16 characters per line
- Define usage of RW Pin
USE_RW_PIN -> Defines HW connection between LCD and uC
ON - when RW pin is connected
OFF - when RW pin is not connected
- Define HW setup for LCD_BCKL_PIN
LCD_BCKL_PIN_EN_STATE -> Defines active state for enabling LCD backlight
HIGH - A high state on the output pin is required to enable the LCD backlight
LOW - A low state on the output pin is required to enable the LCD backlight
- Define usage of LCD buffering functionality LCD_BUFFERING
LCD_BUFFERING -> Defines whether you would like to use LCD buffer or only use functions to print directly on LCD screen
ON - when buffering of LCD is planned to be used in the project
OFF - when buffering of LCD is NOT planned to be used in the project
Code example:
/************************************ LCD HARDWARE SETTINGS ***************************************** * LCD_TYPE -> Set one of the predefined types: * 2004 -> 4 lines 20 characters per line * 1604 -> 4 lines 16 characters per line * 1602 -> 2 lines 16 characters per line * USE_RW_PIN -> Defines HW connection between LCD and uC * ON - when the RW pin is connected * OFF - when the RW pin is not connected * LCD_BCKL_PIN_EN_STATE -> Defines active state for enabling LCD backlight * HIGH - a high state on the output pin is required to enable the LCD backlight * LOW - a low state on the output pin is required to enable the LCD backlight * LCD_BUFFERING -> Defines whether you would like to use LCD buffer or print directly on LCD screen * ON - when buffering of LCD is planned to be used in the project * OFF - when buffering of LCD is NOT planned to be used in the project ******************************************************************************************************/ #define LCD_TYPE 1602 #define USE_RW_PIN OFF #define LCD_BCKL_PIN_EN_STATE HIGH #define LCD_BUFFERING ON
- Define specyfic LCD_TYPE
-
Add or remove specific features from the build by setting specific feature switch to ON or OFF.
When running with user-defined characters, set USE_DEF_CHAR_FUNCTION to ON.To do this, Edit defines in section:
/******************************** LCD LIBRARY COMPILATION SETTINGS ************************ * Setting USE_(procedure name) to: * ON - add specific procedure to compilation * OFF - exclude specific procedure from compilation ********************************************************************************************/ #define USE_DEF_CHAR_FUNCTION ON #define USE_LCD_INT ON #define USE_LCD_HEX ON #define USE_LCD_BIN ON #define USE_LCD_CURSOR_HOME ON #define USE_LCD_CURSOR_ON ON #define USE_LCD_CURSOR_OFF ON #define USE_LCD_BLINKING_CURSOR_ON ON #if LCD_BUFFERING == ON #define USE_LCD_BUF_INT ON #define USE_LCD_BUF_HEX ON #define USE_LCD_BUF_BIN ON #endif
-
Define special characters and character banks in lcd_hd44780_def_char.h
For more details about defining custom char please refer to Custom characters defining and usage. -
Declare the LCD IO driver interface in your application on the GPIO driver side. This interface should contain the following implementation defined in lcd_hd44780_interface.h
/************LCD_IO_driver_interface implementation START**************/ struct LCD_IO_driver_interface_struct { LCD_interface_func_p init_LCD_pins; LCD_interface_func_p set_data_pins_as_outputs; LCD_interface_func_p set_data_pins_as_inputs; set_LCD_data_port_func_p write_data; get_LCD_data_port_func_p read_data; delay_us_func_p delay_us; LCD_interface_func_p set_LCD_E; LCD_interface_func_p reset_LCD_E; LCD_interface_func_p set_LCD_RS; LCD_interface_func_p reset_LCD_RS; LCD_interface_func_p set_LCD_RW; LCD_interface_func_p reset_LCD_RW; LCD_interface_func_p set_LCD_BCKL; LCD_interface_func_p reset_LCD_BCKL; }; const struct LCD_IO_driver_interface_struct *LCD_IO_driver_interface_get(void) { return &LCD_IO_driver; }
It's a basic interface that connects the library with your HW driver layer in the application without making any dependencies between them.
In .examples/lcd_driver_intrface_example_implementations folder you can find a template with empty definitions of all required interface elements as well as a few files with examples of implementation for different microcontrollers. Additional details of the implementation in the project can be also found in ready-to-compile examples.