doc: updated readme

This commit is contained in:
aZholtikov committed 2026-11-03 19:18:42 +03:00
1 parent 0a9a177289
commit eb6518f207
1 file changed
+16 -5
+16 -5
View File
@@ -12,7 +12,7 @@
## Using ## Using
In an existing project, run the following command to install the components: In an existing project, run the following command to install the component:
```bash ```bash
cd ../your_project/components cd ../your_project/components
@@ -25,7 +25,9 @@ In the application, add the component:
#include "zh_tachometer.h" #include "zh_tachometer.h"
``` ```
## Example ## Examples
### Basic Example
```c ```c
#include "zh_tachometer.h" #include "zh_tachometer.h"
@@ -39,13 +41,22 @@ void app_main(void)
config.a_gpio_number = GPIO_NUM_26; config.a_gpio_number = GPIO_NUM_26;
config.b_gpio_number = GPIO_NUM_27; config.b_gpio_number = GPIO_NUM_27;
config.encoder_pulses = 3600; config.encoder_pulses = 3600;
zh_tachometer_init(&config, &tachometer_handle); esp_err_t ret = zh_tachometer_init(&config, &tachometer_handle);
if (ret != ESP_OK)
{
printf("Tachometer initialization error\n");
return;
}
for (;;) for (;;)
{ {
uint16_t value = 0; uint16_t value = 0;
zh_tachometer_get(&tachometer_handle, &value); ret = zh_tachometer_get(&tachometer_handle, &value);
printf("Tachometer value is %d rpm.\n", value); if (ret == ESP_OK)
{
printf("Tachometer value is %u rpm.\n", value);
}
vTaskDelay(100 / portTICK_PERIOD_MS); vTaskDelay(100 / portTICK_PERIOD_MS);
} }
zh_tachometer_deinit(&tachometer_handle);
} }
``` ```