diff --git a/include/zh_160x_i2c.h b/include/zh_160x_i2c.h index 9c28900..aa47136 100644 --- a/include/zh_160x_i2c.h +++ b/include/zh_160x_i2c.h @@ -96,6 +96,25 @@ extern "C" */ esp_err_t zh_160x_clear_row(zh_pcf8574_handle_t *handle, uint8_t row); + /** + * @brief Enable the cursor. + * + * @param[in] handle Pointer to unique PCF8574 handle. + * @param[in] blink Blink mode. + * + * @return ESP_OK if success or an error code otherwise. + */ + esp_err_t zh_160x_on_cursor(zh_pcf8574_handle_t *handle, bool blink); + + /** + * @brief Disable the cursor. + * + * @param[in] handle Pointer to unique PCF8574 handle. + * + * @return ESP_OK if success or an error code otherwise. + */ + esp_err_t zh_160x_off_cursor(zh_pcf8574_handle_t *handle); + #ifdef __cplusplus } #endif \ No newline at end of file diff --git a/version.txt b/version.txt index 0c89fc9..99eba4d 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -4.0.0 \ No newline at end of file +4.1.0 \ No newline at end of file diff --git a/zh_160x_i2c.c b/zh_160x_i2c.c index 1f16150..1028194 100644 --- a/zh_160x_i2c.c +++ b/zh_160x_i2c.c @@ -139,6 +139,28 @@ esp_err_t zh_160x_clear_row(zh_pcf8574_handle_t *handle, uint8_t row) return ESP_OK; } +esp_err_t zh_160x_on_cursor(zh_pcf8574_handle_t *handle, bool blink) +{ + ZH_LOGI("160X enable cursor started."); + ZH_ERROR_CHECK(handle != NULL, ESP_ERR_INVALID_ARG, NULL, "160X enable cursor failed. Invalid argument."); + ZH_ERROR_CHECK(handle->is_initialized == true, ESP_ERR_INVALID_STATE, NULL, "160X enable cursor failed. PCF8574 not initialized."); + esp_err_t err = _zh_160x_send_command(handle, (blink == true) ? 0x0f : 0x0e); + ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "160X enable cursor failed. PCF8574 error."); + ZH_LOGI("160X enable cursor completed successfully."); + return ESP_OK; +} + +esp_err_t zh_160x_off_cursor(zh_pcf8574_handle_t *handle) +{ + ZH_LOGI("160X disable cursor started."); + ZH_ERROR_CHECK(handle != NULL, ESP_ERR_INVALID_ARG, NULL, "160X disable cursor failed. Invalid argument."); + ZH_ERROR_CHECK(handle->is_initialized == true, ESP_ERR_INVALID_STATE, NULL, "160X disable cursor failed. PCF8574 not initialized."); + esp_err_t err = _zh_160x_send_command(handle, 0x0c); + ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "160X disable cursor failed. PCF8574 error."); + ZH_LOGI("160X disable cursor completed successfully."); + return ESP_OK; +} + static esp_err_t _zh_160x_lcd_init(zh_pcf8574_handle_t *handle) { vTaskDelay(20 / portTICK_PERIOD_MS);