feat!: added lcd 16x4 support
This commit is contained in:
		| @@ -6,40 +6,44 @@ | ||||
| #include "freertos/task.h" | ||||
| #include "driver/gpio.h" | ||||
| 
 | ||||
| #define ZH_LCD_16X2 1 | ||||
| #define ZH_LCD_16X4 0 | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" | ||||
| { | ||||
| #endif | ||||
| 
 | ||||
|     typedef struct // Structure for initial initialization of LCD 1602A.
 | ||||
|     typedef struct // Structure for initial initialization of LCD 160X.
 | ||||
|     { | ||||
|         uint8_t rs_gpio_number; // GPIO connected to RS of LCD 1602A.
 | ||||
|         uint8_t e_gpio_number;  // GPIO connected to E of LCD 1602A.
 | ||||
|         uint8_t d0_gpio_number; // GPIO connected to D0 of LCD 1602A. @note Required for 8 bit work mode only.
 | ||||
|         uint8_t d1_gpio_number; // GPIO connected to D1 of LCD 1602A. @note Required for 8 bit work mode only.
 | ||||
|         uint8_t d2_gpio_number; // GPIO connected to D2 of LCD 1602A. @note Required for 8 bit work mode only.
 | ||||
|         uint8_t d3_gpio_number; // GPIO connected to D3 of LCD 1602A. @note Required for 8 bit work mode only.
 | ||||
|         uint8_t d4_gpio_number; // GPIO connected to D4 of LCD 1602A.
 | ||||
|         uint8_t d5_gpio_number; // GPIO connected to D5 of LCD 1602A.
 | ||||
|         uint8_t d6_gpio_number; // GPIO connected to D6 of LCD 1602A.
 | ||||
|         uint8_t d7_gpio_number; // GPIO connected to D7 of LCD 1602A.
 | ||||
|     } zh_1602a_init_config_t; | ||||
|         bool lcd_size;              // LCD size (ZH_LCD_16X2 or ZH_LCD_16X4).
 | ||||
|         uint8_t rs_gpio_number; // GPIO connected to RS of LCD 160X.
 | ||||
|         uint8_t e_gpio_number;  // GPIO connected to E of LCD 160X.
 | ||||
|         uint8_t d0_gpio_number; // GPIO connected to D0 of LCD 160X. @note Required for 8 bit work mode only.
 | ||||
|         uint8_t d1_gpio_number; // GPIO connected to D1 of LCD 160X. @note Required for 8 bit work mode only.
 | ||||
|         uint8_t d2_gpio_number; // GPIO connected to D2 of LCD 160X. @note Required for 8 bit work mode only.
 | ||||
|         uint8_t d3_gpio_number; // GPIO connected to D3 of LCD 160X. @note Required for 8 bit work mode only.
 | ||||
|         uint8_t d4_gpio_number; // GPIO connected to D4 of LCD 160X.
 | ||||
|         uint8_t d5_gpio_number; // GPIO connected to D5 of LCD 160X.
 | ||||
|         uint8_t d6_gpio_number; // GPIO connected to D6 of LCD 160X.
 | ||||
|         uint8_t d7_gpio_number; // GPIO connected to D7 of LCD 160X.
 | ||||
|     } zh_160x_init_config_t; | ||||
| 
 | ||||
|     /**
 | ||||
|      * @brief Initializes the LCD 1602A. | ||||
|      * @brief Initializes the LCD 160X. | ||||
|      * | ||||
|      * @param[in] config Pointer to 1602A initialized configuration structure. Can point to a temporary variable. | ||||
|      * @param[in] config Pointer to 160X initialized configuration structure. Can point to a temporary variable. | ||||
|      * | ||||
|      * @return ESP_OK if success or an error code otherwise. | ||||
|      */ | ||||
|     esp_err_t zh_1602a_init(const zh_1602a_init_config_t *config); | ||||
|     esp_err_t zh_160x_init(const zh_160x_init_config_t *config); | ||||
| 
 | ||||
|     /**
 | ||||
|      * @brief Clears the LCD screen. | ||||
|      * | ||||
|      * @return ESP_OK if success or an error code otherwise. | ||||
|      */ | ||||
|     esp_err_t zh_1602a_lcd_clear(void); | ||||
|     esp_err_t zh_160x_lcd_clear(void); | ||||
| 
 | ||||
|     /**
 | ||||
|      * @brief Sets the cursor to a specific position on the LCD. | ||||
| @@ -49,7 +53,7 @@ extern "C" | ||||
|      * | ||||
|      * @return ESP_OK if success or an error code otherwise. | ||||
|      */ | ||||
|     esp_err_t zh_1602a_set_cursor(uint8_t row, uint8_t col); | ||||
|     esp_err_t zh_160x_set_cursor(uint8_t row, uint8_t col); | ||||
| 
 | ||||
|     /**
 | ||||
|      * @brief Prints a string to the LCD. | ||||
| @@ -58,7 +62,7 @@ extern "C" | ||||
|      * | ||||
|      * @return ESP_OK if success or an error code otherwise. | ||||
|      */ | ||||
|     esp_err_t zh_1602a_print_char(const char *str); | ||||
|     esp_err_t zh_160x_print_char(const char *str); | ||||
| 
 | ||||
|     /**
 | ||||
|      * @brief Prints an integer to the LCD. | ||||
| @@ -67,7 +71,7 @@ extern "C" | ||||
|      * | ||||
|      * @return ESP_OK if success or an error code otherwise.. | ||||
|      */ | ||||
|     esp_err_t zh_1602a_print_int(int num); | ||||
|     esp_err_t zh_160x_print_int(int num); | ||||
| 
 | ||||
|     /**
 | ||||
|      * @brief Prints a floating-point number to the LCD. | ||||
| @@ -77,7 +81,7 @@ extern "C" | ||||
|      * | ||||
|      * @return ESP_OK if success or an error code otherwise. | ||||
|      */ | ||||
|     esp_err_t zh_1602a_print_float(float num, uint8_t precision); | ||||
|     esp_err_t zh_160x_print_float(float num, uint8_t precision); | ||||
| 
 | ||||
|     /**
 | ||||
|      * @brief Displays a progress bar on a specific row of the LCD. | ||||
| @@ -87,7 +91,7 @@ extern "C" | ||||
|      * | ||||
|      * @return ESP_OK if success or an error code otherwise. | ||||
|      */ | ||||
|     esp_err_t zh_1602a_print_progress_bar(uint8_t row, uint8_t progress); | ||||
|     esp_err_t zh_160x_print_progress_bar(uint8_t row, uint8_t progress); | ||||
| 
 | ||||
|     /**
 | ||||
|      * @brief Clears a specific row on the LCD. | ||||
| @@ -96,7 +100,7 @@ extern "C" | ||||
|      * | ||||
|      * @return ESP_OK if success or an error code otherwise. | ||||
|      */ | ||||
|     esp_err_t zh_1602a_clear_row(uint8_t row); | ||||
|     esp_err_t zh_160x_clear_row(uint8_t row); | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| } | ||||
		Reference in New Issue
	
	Block a user