This commit is contained in:
2025-08-12 12:25:03 +03:00
parent 9c6ca62eca
commit 821bdb189d
4 changed files with 360 additions and 1 deletions

101
include/zh_avr_160x_i2c.h Normal file
View File

@@ -0,0 +1,101 @@
#pragma once
#include "zh_avr_pcf8574.h"
#include "util/delay.h"
#include "stdio.h"
#define ZH_LCD_16X2 1
#define ZH_LCD_16X4 0
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @brief Initializes the LCD 160X.
*
* @param[in] handle Pointer to unique PCF8574 handle.
* @param[in] size LCD size (ZH_LCD_16X2 or ZH_LCD_16X4).
*
* @return AVR_OK if success or an error code otherwise.
*/
avr_err_t zh_avr_160x_init(zh_avr_pcf8574_handle_t *handle, bool size);
/**
* @brief Clears the LCD screen.
*
* @param[in] handle Pointer to unique PCF8574 handle.
*
* @return AVR_OK if success or an error code otherwise.
*/
avr_err_t zh_avr_160x_lcd_clear(zh_avr_pcf8574_handle_t *handle);
/**
* @brief Sets the cursor to a specific position on the LCD.
*
* @param[in] handle Pointer to unique PCF8574 handle.
* @param[in] row The row number.
* @param[in] col The column number (015).
*
* @return AVR_OK if success or an error code otherwise.
*/
avr_err_t zh_avr_160x_set_cursor(zh_avr_pcf8574_handle_t *handle, uint8_t row, uint8_t col);
/**
* @brief Prints a string to the LCD.
*
* @param[in] handle Pointer to unique PCF8574 handle.
* @param[in] str Pointer to the string to be displayed.
*
* @return AVR_OK if success or an error code otherwise.
*/
avr_err_t zh_avr_160x_print_char(zh_avr_pcf8574_handle_t *handle, const char *str);
/**
* @brief Prints an integer to the LCD.
*
* @param[in] handle Pointer to unique PCF8574 handle.
* @param[in] num The integer to be displayed.
*
* @return AVR_OK if success or an error code otherwise..
*/
avr_err_t zh_avr_160x_print_int(zh_avr_pcf8574_handle_t *handle, int num);
/**
* @brief Prints a floating-point number to the LCD.
*
* @param[in] handle Pointer to unique PCF8574 handle.
* @param[in] num The floating-point number to be displayed.
* @param[in] precision The number of decimal places to display.
*
* @return AVR_OK if success or an error code otherwise.
*/
avr_err_t zh_avr_160x_print_float(zh_avr_pcf8574_handle_t *handle, float num, uint8_t precision);
/**
* @brief Displays a progress bar on a specific row of the LCD.
*
* @param[in] handle Pointer to unique PCF8574 handle.
* @param[in] row The row number.
* @param[in] progress The progress percentage (0100).
*
* @return AVR_OK if success or an error code otherwise.
*/
avr_err_t zh_avr_160x_print_progress_bar(zh_avr_pcf8574_handle_t *handle, uint8_t row, uint8_t progress);
/**
* @brief Clears a specific row on the LCD.
*
* @param[in] handle Pointer to unique PCF8574 handle.
* @param[in] row The row number.
*
* @return AVR_OK if success or an error code otherwise.
*/
avr_err_t zh_avr_160x_clear_row(zh_avr_pcf8574_handle_t *handle, uint8_t row);
extern void zh_avr_pcf8574_event_handler(zh_avr_pcf8574_event_on_isr_t *event);
#ifdef __cplusplus
}
#endif