6 Commits
v4.1.0 ... main

Author SHA1 Message Date
a5c9d5a376 refactor: refactored by pvs-studio 2026-01-28 20:07:48 +03:00
c32649e826 doc: updated example 2026-01-26 18:02:09 +03:00
fd2ee05992 style: typo 2026-01-26 17:59:21 +03:00
3a87d221bb doc: updated example 2026-01-26 17:50:10 +03:00
2bc4f2f480 doc: updated readme 2026-01-26 17:45:14 +03:00
63bfc0d572 doc: updated readme 2026-01-26 16:04:32 +03:00
3 changed files with 22 additions and 10 deletions

View File

@@ -12,6 +12,17 @@
1. Support of 16 LCD 160X on one bus.
## Attention
For correct operation, please enable the following settings in the menuconfig:
```text
CONFIG_FREERTOS_HZ=1000
CONFIG_GPIO_CTRL_FUNC_IN_IRAM
CONFIG_I2C_ISR_IRAM_SAFE
CONFIG_I2C_MASTER_ISR_HANDLER_IN_IRAM
```
## Connection
| 1602(4)A | PCF8574 |
@@ -54,8 +65,6 @@ One LCD on bus:
#define I2C_PORT (I2C_NUM_MAX - 1)
i2c_master_bus_handle_t i2c_bus_handle = NULL;
zh_pcf8574_handle_t lcd_160x_handle = {0};
void app_main(void)
@@ -71,6 +80,7 @@ void app_main(void)
.glitch_ignore_cnt = 7,
.flags.enable_internal_pullup = true,
};
i2c_master_bus_handle_t i2c_bus_handle = NULL;
i2c_new_master_bus(&i2c_bus_config, &i2c_bus_handle);
zh_pcf8574_init_config_t config = ZH_PCF8574_INIT_CONFIG_DEFAULT();
config.i2c_handle = i2c_bus_handle;
@@ -79,11 +89,13 @@ void app_main(void)
zh_160x_init(&lcd_160x_handle, ZH_LCD_16X2);
for (;;)
{
zh_160x_on_cursor(&lcd_160x_handle, true);
zh_160x_set_cursor(&lcd_160x_handle, 0, 0);
zh_160x_print_char(&lcd_160x_handle, "LCD 160X");
zh_160x_set_cursor(&lcd_160x_handle, 1, 0);
zh_160x_print_char(&lcd_160x_handle, "Hello World!");
vTaskDelay(5000 / portTICK_PERIOD_MS);
zh_160x_off_cursor(&lcd_160x_handle);
zh_160x_set_cursor(&lcd_160x_handle, 0, 0);
zh_160x_print_char(&lcd_160x_handle, "Progress: ");
for (uint8_t i = 0; i <= 100; ++i)

View File

@@ -7,7 +7,7 @@
#include "zh_pcf8574.h"
#define ZH_LCD_16X2 1 /*!< LCD size 16x2. */
#define ZH_LCD_16X4 0 /*!< LCD size 16x3. */
#define ZH_LCD_16X4 0 /*!< LCD size 16x4. */
#ifdef __cplusplus
extern "C"

View File

@@ -18,7 +18,7 @@ static esp_err_t _zh_160x_send_command(zh_pcf8574_handle_t *handle, uint8_t comm
static esp_err_t _zh_160x_send_data(zh_pcf8574_handle_t *handle, uint8_t data);
static esp_err_t _zh_160x_pulse(zh_pcf8574_handle_t *handle);
esp_err_t zh_160x_init(zh_pcf8574_handle_t *handle, bool size)
esp_err_t zh_160x_init(zh_pcf8574_handle_t *handle, bool size) // -V2008
{
ZH_LOGI("160X initialization started.");
ZH_ERROR_CHECK(handle != NULL, ESP_ERR_INVALID_ARG, NULL, "160X initialization failed. Invalid argument.");
@@ -43,7 +43,7 @@ esp_err_t zh_160x_lcd_clear(zh_pcf8574_handle_t *handle)
return ESP_OK;
}
esp_err_t zh_160x_set_cursor(zh_pcf8574_handle_t *handle, uint8_t row, uint8_t col)
esp_err_t zh_160x_set_cursor(zh_pcf8574_handle_t *handle, uint8_t row, uint8_t col) // -V2008
{
ZH_LOGI("160X set cursor started.");
ZH_ERROR_CHECK(handle != NULL && row < ((*(uint8_t *)handle->system == ZH_LCD_16X2) ? 2 : 4) && col < 16, ESP_ERR_INVALID_ARG, NULL, "160X set cursor failed. Invalid argument.");
@@ -96,7 +96,7 @@ esp_err_t zh_160x_print_float(zh_pcf8574_handle_t *handle, float num, uint8_t pr
return ESP_OK;
}
esp_err_t zh_160x_print_progress_bar(zh_pcf8574_handle_t *handle, uint8_t row, uint8_t progress)
esp_err_t zh_160x_print_progress_bar(zh_pcf8574_handle_t *handle, uint8_t row, uint8_t progress) // -V2008
{
ZH_LOGI("160X print progress bar started.");
ZH_ERROR_CHECK(handle != NULL && row < ((*(uint8_t *)handle->system == ZH_LCD_16X2) ? 2 : 4) && progress <= 100, ESP_ERR_INVALID_ARG, NULL, "160X print progress bar failed. Invalid argument.");
@@ -121,7 +121,7 @@ esp_err_t zh_160x_print_progress_bar(zh_pcf8574_handle_t *handle, uint8_t row, u
return ESP_OK;
}
esp_err_t zh_160x_clear_row(zh_pcf8574_handle_t *handle, uint8_t row)
esp_err_t zh_160x_clear_row(zh_pcf8574_handle_t *handle, uint8_t row) // -V2008
{
ZH_LOGI("160X clear row started.");
ZH_ERROR_CHECK(handle != NULL && row < ((*(uint8_t *)handle->system == ZH_LCD_16X2) ? 2 : 4), ESP_ERR_INVALID_ARG, NULL, "160X clear row failed. Invalid argument.");
@@ -161,7 +161,7 @@ esp_err_t zh_160x_off_cursor(zh_pcf8574_handle_t *handle)
return ESP_OK;
}
static esp_err_t _zh_160x_lcd_init(zh_pcf8574_handle_t *handle)
static esp_err_t _zh_160x_lcd_init(zh_pcf8574_handle_t *handle) // -V2008
{
vTaskDelay(20 / portTICK_PERIOD_MS);
esp_err_t err = zh_pcf8574_write(handle, 0x30);
@@ -223,10 +223,10 @@ static esp_err_t _zh_160x_send_data(zh_pcf8574_handle_t *handle, uint8_t data)
static esp_err_t _zh_160x_pulse(zh_pcf8574_handle_t *handle)
{
esp_err_t err = zh_pcf8574_write_gpio(handle, 2, true);
esp_err_t err = zh_pcf8574_write_gpio(handle, ZH_PCF8574_GPIO_NUM_P2, ZH_PCF8574_GPIO_HIGH);
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCF8574 error.");
vTaskDelay(1 / portTICK_PERIOD_MS);
err = zh_pcf8574_write_gpio(handle, 2, false);
err = zh_pcf8574_write_gpio(handle, ZH_PCF8574_GPIO_NUM_P2, ZH_PCF8574_GPIO_LOW);
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCF8574 error.");
vTaskDelay(1 / portTICK_PERIOD_MS);
return ESP_OK;