-
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 and add copied files in your project configuration to make them possible to include in 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
- Define specyfic LCD_TYPE
-
Declare the LCD GPIO driver interface in your application on the GPIO driver side. This interface should contain the following implementation defined in lcd_hd44780_GPIO_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 implementations for different microcontrollers. Additional details of the implementation in the project can be also found in ready-to-compile examples.
- Add or remove specific features from the build by setting their 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
-
Copy LCD library src files (or files from src folder) to your project and add copied files in your project configuration, so they can be included in 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
- Define specyfic LCD_TYPE
-
Specify which procedures from to library you would like to compile and use in your project.
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
-
If setting USE_DEF_CHAR_FUNCTION ON define special characters and character banks in lcd_hd44780_def_char.h
For more details about defining custom char please refer to How to define custom characters and custom character banks. -
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.