Skip to content

Commit 601489c

Browse files
committed
Fix string and custom character display.
1 parent 10d27d1 commit 601489c

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

i2c-lcd1602.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ esp_err_t i2c_lcd1602_move_cursor_right(const i2c_lcd1602_info_t * i2c_lcd1602_i
531531
return err;
532532
}
533533

534-
esp_err_t i2c_lcd1602_define_char(const i2c_lcd1602_info_t * i2c_lcd1602_info, i2c_lcd1602_custom_index_t index, uint8_t pixelmap[])
534+
esp_err_t i2c_lcd1602_define_char(const i2c_lcd1602_info_t * i2c_lcd1602_info, i2c_lcd1602_custom_index_t index, const uint8_t pixelmap[])
535535
{
536536
esp_err_t err = ESP_FAIL;
537537
if (_is_init(i2c_lcd1602_info))
@@ -561,6 +561,8 @@ esp_err_t i2c_lcd1602_write_string(const i2c_lcd1602_info_t * i2c_lcd1602_info,
561561
esp_err_t err = ESP_FAIL;
562562
if (_is_init(i2c_lcd1602_info))
563563
{
564+
//ESP_LOGI(TAG, "i2c_lcd1602_write_string: %s", string);
565+
err = ESP_OK;
564566
for (int i = 0; err == ESP_OK && string[i]; ++i)
565567
{
566568
err = _write_data(i2c_lcd1602_info, string[i]);

include/i2c-lcd1602.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ typedef struct
5959
#define I2C_LCD1602_NUM_VISIBLE_COLUMNS 16 ///< Number of columns visible at any one time
6060

6161
// Special characters for ROM Code A00
62+
63+
// Use the second set (0bxxxx1xxx) to avoid placing the null character within a string
64+
#define I2C_LCD1602_CHARACTER_CUSTOM_0 0b00001000 ///< User-defined custom symbol in index 0
65+
#define I2C_LCD1602_CHARACTER_CUSTOM_1 0b00001001 ///< User-defined custom symbol in index 1
66+
#define I2C_LCD1602_CHARACTER_CUSTOM_2 0b00001010 ///< User-defined custom symbol in index 2
67+
#define I2C_LCD1602_CHARACTER_CUSTOM_3 0b00001011 ///< User-defined custom symbol in index 3
68+
#define I2C_LCD1602_CHARACTER_CUSTOM_4 0b00001100 ///< User-defined custom symbol in index 4
69+
#define I2C_LCD1602_CHARACTER_CUSTOM_5 0b00001101 ///< User-defined custom symbol in index 5
70+
#define I2C_LCD1602_CHARACTER_CUSTOM_6 0b00001110 ///< User-defined custom symbol in index 6
71+
#define I2C_LCD1602_CHARACTER_CUSTOM_7 0b00001111 ///< User-defined custom symbol in index 7
72+
6273
#define I2C_LCD1602_CHARACTER_ALPHA 0b11100000 ///< Lower-case alpha symbol
6374
#define I2C_LCD1602_CHARACTER_BETA 0b11100010 ///< Lower-case beta symbol
6475
#define I2C_LCD1602_CHARACTER_THETA 0b11110010 ///< Lower-case theta symbol
@@ -89,15 +100,6 @@ typedef enum
89100
I2C_LCD1602_INDEX_CUSTOM_7, ///< Index of eighth user-defined custom symbol
90101
} i2c_lcd1602_custom_index_t;
91102

92-
#define I2C_LCD1602_CHARACTER_CUSTOM_0 0b00000000 ///< User-defined custom symbol in index 0
93-
#define I2C_LCD1602_CHARACTER_CUSTOM_1 0b00000001 ///< User-defined custom symbol in index 1
94-
#define I2C_LCD1602_CHARACTER_CUSTOM_2 0b00000010 ///< User-defined custom symbol in index 2
95-
#define I2C_LCD1602_CHARACTER_CUSTOM_3 0b00000011 ///< User-defined custom symbol in index 3
96-
#define I2C_LCD1602_CHARACTER_CUSTOM_4 0b00000100 ///< User-defined custom symbol in index 4
97-
#define I2C_LCD1602_CHARACTER_CUSTOM_5 0b00000101 ///< User-defined custom symbol in index 5
98-
#define I2C_LCD1602_CHARACTER_CUSTOM_6 0b00000110 ///< User-defined custom symbol in index 6
99-
#define I2C_LCD1602_CHARACTER_CUSTOM_7 0b00000111 ///< User-defined custom symbol in index 7
100-
101103
/**
102104
* @brief Construct a new I2C-LCD1602 info instance.
103105
* New instance should be initialised before calling other functions.
@@ -274,7 +276,7 @@ esp_err_t i2c_lcd1602_move_cursor_right(const i2c_lcd1602_info_t * i2c_lcd1602_i
274276
* @param[in] pixelmap An 8-byte array defining the pixel map for the new character definition.
275277
* @return ESP_OK if successful, otherwise an error constant.
276278
*/
277-
esp_err_t i2c_lcd1602_define_char(const i2c_lcd1602_info_t * i2c_lcd1602_info, i2c_lcd1602_custom_index_t index, uint8_t pixelmap[]);
279+
esp_err_t i2c_lcd1602_define_char(const i2c_lcd1602_info_t * i2c_lcd1602_info, i2c_lcd1602_custom_index_t index, const uint8_t pixelmap[]);
278280

279281
/**
280282
* @brief Write a single character to the display at the current position of the cursor.

0 commit comments

Comments
 (0)