fix!: incorrect work address auto increment mode on 6 digits display
This commit is contained in:
1 parent
9b769ece74
commit
ff3f404bb5
4 files changed
+19
-37
No files matched your search
@@ -74,30 +74,13 @@ void app_main(void)
|
|||||||
config.dio_gpio = GPIO_NUM_26;
|
config.dio_gpio = GPIO_NUM_26;
|
||||||
zh_tm1637_init(&config, &tm1637_handle);
|
zh_tm1637_init(&config, &tm1637_handle);
|
||||||
zh_tm1637_set_brightness(&tm1637_handle, 7); // Set brightness.
|
zh_tm1637_set_brightness(&tm1637_handle, 7); // Set brightness.
|
||||||
uint8_t clear_symbols[4] = {0x00};
|
for (uint8_t i = 0; i < 6; ++i) // Clear LCD.
|
||||||
zh_tm1637_print(&tm1637_handle, 0, clear_symbols, sizeof(clear_symbols)); // Clear LCD.
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
||||||
for (;;)
|
|
||||||
{
|
{
|
||||||
uint8_t symbol = 0x3F;
|
zh_tm1637_print(&tm1637_handle, i, 0x00);
|
||||||
zh_tm1637_print(&tm1637_handle, 0, &symbol, sizeof(symbol)); // 0 on 0 position.
|
};
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
zh_tm1637_print(&tm1637_handle, 1, &symbol, sizeof(symbol)); // 0 on 1 position.
|
zh_tm1637_print(&tm1637_handle, 0, 0x4F); // 3 on C0H address.
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
zh_tm1637_print(&tm1637_handle, 0, clear_symbols, sizeof(clear_symbols)); // Clear LCD.
|
zh_tm1637_print(&tm1637_handle, 4, 0x87); // 7. on C4H address.
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
||||||
uint8_t symbols[] = {0x40, 0x06, 0x5B, 0x4F};
|
|
||||||
zh_tm1637_print(&tm1637_handle, 0, symbols, sizeof(symbols)); // -123 start from 0 position.
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
||||||
zh_tm1637_print(&tm1637_handle, 0, clear_symbols, sizeof(clear_symbols)); // Clear LCD.
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
||||||
zh_tm1637_print(&tm1637_handle, 1, symbols, sizeof(symbols)); // -123 start from 1 position.
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
||||||
zh_tm1637_print(&tm1637_handle, 0, clear_symbols, sizeof(clear_symbols)); // Clear LCD.
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
||||||
const zh_tm1637_stats_t *stats = zh_tm1637_get_stats();
|
|
||||||
printf("Number of RMT driver error: %ld.\n", stats->rmt_driver_error);
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
+4
-5
@@ -77,16 +77,15 @@ extern "C"
|
|||||||
esp_err_t zh_tm1637_deinit(zh_tm1637_handle_t *handle);
|
esp_err_t zh_tm1637_deinit(zh_tm1637_handle_t *handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints an symbols to the LED.
|
* @brief Prints a symbol to the LED.
|
||||||
*
|
*
|
||||||
* @param[in] handle Pointer to unique TM1637 handle.
|
* @param[in] handle Pointer to unique TM1637 handle.
|
||||||
* @param[in] position Initial print position (0-5).
|
* @param[in] address Display address (0-5).
|
||||||
* @param[in] symbols Pointer to symbols to be displayed.
|
* @param[in] symbols Symbol to be displayed.
|
||||||
* @param[in] size The symbols quantity to be displayed.
|
|
||||||
*
|
*
|
||||||
* @return ESP_OK if success or an error code otherwise.
|
* @return ESP_OK if success or an error code otherwise.
|
||||||
*/
|
*/
|
||||||
esp_err_t zh_tm1637_print(zh_tm1637_handle_t *handle, uint8_t position, uint8_t *symbols, uint8_t size);
|
esp_err_t zh_tm1637_print(zh_tm1637_handle_t *handle, uint8_t address, uint8_t symbol);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set brightness of the LED.
|
* @brief Set brightness of the LED.
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
1.0.0
|
2.0.0
|
||||||
+7
-7
@@ -50,17 +50,17 @@ esp_err_t zh_tm1637_deinit(zh_tm1637_handle_t *handle) // -V2008
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t zh_tm1637_print(zh_tm1637_handle_t *handle, uint8_t position, uint8_t *symbols, uint8_t size) // -V2008
|
esp_err_t zh_tm1637_print(zh_tm1637_handle_t *handle, uint8_t address, uint8_t symbol) // -V2008
|
||||||
{
|
{
|
||||||
ZH_LOGI("Led drive printing started.");
|
ZH_LOGI("Led drive printing started.");
|
||||||
ZH_ERROR_CHECK(handle != NULL && symbols != NULL && position <= 5 && size > 0, ESP_ERR_INVALID_ARG, NULL, "Led drive printing failed. Invalid argument.");
|
ZH_ERROR_CHECK(handle != NULL && address <= 5, ESP_ERR_INVALID_ARG, NULL, "Led drive printing failed. Invalid argument.");
|
||||||
ZH_ERROR_CHECK(handle->is_initialized == true, ESP_FAIL, NULL, "Led drive printing failed. Led drive not initialized.");
|
ZH_ERROR_CHECK(handle->is_initialized == true, ESP_FAIL, NULL, "Led drive printing failed. Led drive not initialized.");
|
||||||
uint8_t set_data_command = 0x40;
|
uint8_t set_data_command = 0x44;
|
||||||
ZH_ERROR_CHECK(_zh_tm1637_send_data(handle, &set_data_command, 1) == ESP_OK, ESP_FAIL, NULL, "Led drive printing failed. RMT driver error.");
|
ZH_ERROR_CHECK(_zh_tm1637_send_data(handle, &set_data_command, 1) == ESP_OK, ESP_FAIL, NULL, "Led drive printing failed. RMT driver error.");
|
||||||
uint8_t print_symbols_command[size + 1];
|
uint8_t print_symbols_command[2];
|
||||||
print_symbols_command[0] = position | 0xC0;
|
print_symbols_command[0] = address | 0xC0;
|
||||||
memcpy(&print_symbols_command[1], symbols, size);
|
memcpy(&print_symbols_command[1], &symbol, 1);
|
||||||
ZH_ERROR_CHECK(_zh_tm1637_send_data(handle, print_symbols_command, size + 1) == ESP_OK, ESP_FAIL, NULL, "Led drive printing failed. RMT driver error.");
|
ZH_ERROR_CHECK(_zh_tm1637_send_data(handle, print_symbols_command, 2) == ESP_OK, ESP_FAIL, NULL, "Led drive printing failed. RMT driver error.");
|
||||||
uint8_t control_display_command = (handle->brightness == -1) ? 0x80 : handle->brightness | 0x88;
|
uint8_t control_display_command = (handle->brightness == -1) ? 0x80 : handle->brightness | 0x88;
|
||||||
ZH_ERROR_CHECK(_zh_tm1637_send_data(handle, &control_display_command, 1) == ESP_OK, ESP_FAIL, NULL, "Led drive printing failed. RMT driver error.");
|
ZH_ERROR_CHECK(_zh_tm1637_send_data(handle, &control_display_command, 1) == ESP_OK, ESP_FAIL, NULL, "Led drive printing failed. RMT driver error.");
|
||||||
ZH_LOGI("Led drive printing completed successfully.");
|
ZH_LOGI("Led drive printing completed successfully.");
|
||||||
|
|||||||
Reference in new issue
Block a user