feat: added print int and float values

This commit is contained in:
aZholtikov committed 2026-05-16 11:05:53 +03:00
1 parent 765a962466
commit ed64557662
4 files changed
+227 -18

No files matched your search

+60 -7
View File
@@ -22,6 +22,20 @@ extern "C"
{
#endif
/**
* @brief Enumeration of TM1637 adresses.
*/
typedef enum
{
ZH_TM1637_C0H = 0x00,
ZH_TM1637_C1H,
ZH_TM1637_C2H,
ZH_TM1637_C3H,
ZH_TM1637_C4H,
ZH_TM1637_C5H,
ZH_TM1637_MAX
} zh_tm1637_address_t;
/**
* @brief Structure for initial initialization of TM1637 led drive.
*/
@@ -36,11 +50,12 @@ extern "C"
*/
typedef struct
{
bool is_initialized; /*!< Led drive initialization flag. */
int8_t brightness; /*!< Led drive brightness. */
rmt_sync_manager_handle_t synchro; /*!< Unique RMT TX device sync manager handle. */
rmt_channel_handle_t tx_channel[2]; /*!< Unique RMT TX device handles. */
rmt_encoder_handle_t copy_encoder; /*!< Unique copy encoder handle. */
bool is_initialized; /*!< Led drive initialization flag. */
int8_t brightness; /*!< Led drive brightness. */
zh_tm1637_address_t digit_positions[6]; /*!< The physical relationship of the arrangement of digits on the display in relation to addresses. */
rmt_sync_manager_handle_t synchro; /*!< Unique RMT TX device sync manager handle. */
rmt_channel_handle_t tx_channel[2]; /*!< Unique RMT TX device handles. */
rmt_encoder_handle_t copy_encoder; /*!< Unique copy encoder handle. */
} zh_tm1637_handle_t;
/**
@@ -85,7 +100,7 @@ extern "C"
*
* @return ESP_OK if success or an error code otherwise.
*/
esp_err_t zh_tm1637_print(zh_tm1637_handle_t *handle, uint8_t address, uint8_t symbol);
esp_err_t zh_tm1637_print(zh_tm1637_handle_t *handle, zh_tm1637_address_t address, uint8_t symbol);
/**
* @brief Set brightness of the LED.
@@ -109,7 +124,7 @@ extern "C"
*/
void zh_tm1637_reset_stats(void);
/**
/**
* @brief Clear the LEDs.
*
* @param[in] handle Pointer to unique TM1637 handle.
@@ -118,6 +133,44 @@ extern "C"
*/
esp_err_t zh_tm1637_clear(zh_tm1637_handle_t *handle);
/**
* @brief Sets physical relationship of the arrangement of digits on the display in relation to addresses.
*
* @param[in] handle Pointer to unique TM1637 handle.
* @param[in] digit_0 Address of digit 0.
* @param[in] digit_1 Address of digit 1.
* @param[in] digit_2 Address of digit 2.
* @param[in] digit_3 Address of digit 3.
* @param[in] digit_4 Address of digit 4.
* @param[in] digit_5 Address of digit 5.
*
* @return ESP_OK if success or an error code otherwise.
*/
esp_err_t zh_tm1637_set(zh_tm1637_handle_t *handle, zh_tm1637_address_t digit_0, zh_tm1637_address_t digit_1, zh_tm1637_address_t digit_2, zh_tm1637_address_t digit_3, zh_tm1637_address_t digit_4, zh_tm1637_address_t digit_5);
/**
* @brief Prints an int value to the LED.
*
* @param[in] handle Pointer to unique TM1637 handle.
* @param[in] position Start position for print.
* @param[in] value Int value.
*
* @return ESP_OK if success or an error code otherwise.
*/
esp_err_t zh_tm1637_print_int(zh_tm1637_handle_t *handle, uint8_t position, int value);
/**
* @brief Prints a float value to the LED.
*
* @param[in] handle Pointer to unique TM1637 handle.
* @param[in] position Start position for print.
* @param[in] value Float value.
* @param[in] precision The number of decimal places to display.
*
* @return ESP_OK if success or an error code otherwise.
*/
esp_err_t zh_tm1637_print_float(zh_tm1637_handle_t *handle, uint8_t position, float value, uint8_t precision);
#ifdef __cplusplus
}
#endif