LCD 1602 Driver with ESP32 I2C 1.1
This is a complete driver for LCD 1602 using I2C with the ESP32
Loading...
Searching...
No Matches

External functions for LCD 1602 API. More...

Functions

LCD_WRITE_STATUS lcd_1602_send_string (i2c_master_dev_handle_t handle, char *str)
 Writes out data to the LCD.
uint8_t lcd_1602_init (i2c_master_dev_handle_t handle)
 initializes the LCD 1602 correctly according to the datasheet.

Detailed Description

External functions for LCD 1602 API.

Function Documentation

◆ lcd_1602_init()

uint8_t lcd_1602_init ( i2c_master_dev_handle_t handle)

initializes the LCD 1602 correctly according to the datasheet.

Parameters
handleThe device handle use to writing on the i2c bus
Returns
0 for success or 1 for fail.

Definition at line 141 of file lcd_1602.c.

141 {
142/*
143This function sets up the standard mode of the LCD and follows
144a specific start up sequence described by the manufacturer.
145*/
146 // Manufacturer specific order
147 vTaskDelay(pdMS_TO_TICKS(15));
148 write_nibble(handle, (0x03 << 4), 0);
149 vTaskDelay(pdMS_TO_TICKS(5));
150 write_nibble(handle, (0x03 << 4), 0);
151 vTaskDelay(pdMS_TO_TICKS(2));
152 write_nibble(handle, (0x03 << 4), 0);
153 vTaskDelay(pdMS_TO_TICKS(2));
154 write_nibble(handle, (0x02 << 4), 0);
155 // End of manufacturer specific order
156
159 clear_screen(handle);
161
162 return 0;
163}
#define LCD_1602_FUNCTION_SET(dl, r, f)
Macro for configuring the lcd screens function. Use together with:
#define LCD_1602_CONFIG_INPUT_SET(dir, mov)
Macro for setting the correct movement of the cursor. Use together with:
#define LCD_1602_CONFIG_DISPLAY_SWITCH(disp, curs, blink)
Macro for configuring the display settings. Use together with;.
#define LCD_1602_2_ROWS
#define LCD_1602_N_BLINK_DISPLAY
#define LCD_1602_DISPLAY_ON
#define LCD_1602_CURSOR_OFF
#define LCD_1602_INCREMENT_MODE
#define LCD_1602_FONT_5X10
#define LCD_1602_CURSOR_N_MOVE
#define LCD_1602_DATA_LEN_4_BIT

◆ lcd_1602_send_string()

LCD_WRITE_STATUS lcd_1602_send_string ( i2c_master_dev_handle_t handle,
char * str )

Writes out data to the LCD.

Parameters
handleThe device handle used to writing on the i2c bus
strThe string to be written to the LCD
Returns
LCD_WRITE_FINISHED for successful. LCD_WRITE_INTERRUPTED if string is too long for screen.

Definition at line 111 of file lcd_1602.c.

111 {
112 clear_screen(handle);
113
114 uint8_t char_len = 0;
115 uint8_t row = 0;
116
117 while(*str != '\0') {
118 if(*str == '\n' || char_len >= 16) {
119 if(row < LCD_1602_MAX_ROWS) {
120 lcd_goto(handle, 0,1);
121 row++;
122 char_len = 0;
123 str++;
124 continue;
125 }
126 else return LCD_WRITE_INTERRUPTED;
127 }
128
129 if(*str == '\0') {
130 return LCD_WRITE_FINISHED;
131 }
132
133 send_char(handle, *str);
134 char_len++;
135 str++;
136 }
137
138 return LCD_WRITE_FINISHED;
139}
#define LCD_1602_MAX_ROWS
Definition lcd_1602.h:51
@ LCD_WRITE_INTERRUPTED
Definition lcd_1602.h:61
@ LCD_WRITE_FINISHED
Definition lcd_1602.h:59