doc: updated readme
This commit is contained in:
1 parent
0a9a177289
commit
eb6518f207
1 file changed
+16
-5
@@ -12,7 +12,7 @@
|
||||
|
||||
## 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
|
||||
cd ../your_project/components
|
||||
@@ -25,7 +25,9 @@ In the application, add the component:
|
||||
#include "zh_tachometer.h"
|
||||
```
|
||||
|
||||
## Example
|
||||
## Examples
|
||||
|
||||
### Basic Example
|
||||
|
||||
```c
|
||||
#include "zh_tachometer.h"
|
||||
@@ -39,13 +41,22 @@ void app_main(void)
|
||||
config.a_gpio_number = GPIO_NUM_26;
|
||||
config.b_gpio_number = GPIO_NUM_27;
|
||||
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 (;;)
|
||||
{
|
||||
uint16_t value = 0;
|
||||
zh_tachometer_get(&tachometer_handle, &value);
|
||||
printf("Tachometer value is %d rpm.\n", value);
|
||||
ret = zh_tachometer_get(&tachometer_handle, &value);
|
||||
if (ret == ESP_OK)
|
||||
{
|
||||
printf("Tachometer value is %u rpm.\n", value);
|
||||
}
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
}
|
||||
zh_tachometer_deinit(&tachometer_handle);
|
||||
}
|
||||
```
|
||||
Reference in new issue
Block a user