doc: updated readme

This commit is contained in:
aZholtikov committed 2026-11-03 12:17:00 +03:00
1 parent 7f92fb6cd4
commit 66c6b13041
1 file changed
+25 -5
+25 -5
View File
@@ -10,9 +10,13 @@
6. PCNT glitch filter for noise rejection (1000ns). 6. PCNT glitch filter for noise rejection (1000ns).
7. Multiple inclinometer instances support. 7. Multiple inclinometer instances support.
## Attention
1. The maximum value of encoder_pulses is 8191, limited by the PCNT counter range of +/-32767.
## 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 +29,9 @@ In the application, add the component:
#include "zh_inclinometer.h" #include "zh_inclinometer.h"
``` ```
## Example ## Examples
### Basic Example
```c ```c
#include "zh_inclinometer.h" #include "zh_inclinometer.h"
@@ -39,13 +45,27 @@ 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_inclinometer_init(&config, &inclinometer_handle); esp_err_t ret = zh_inclinometer_init(&config, &inclinometer_handle);
if (ret != ESP_OK)
{
printf("Inclinometer initialization error: %s\n", esp_err_to_name(ret));
return;
}
ret = zh_inclinometer_reset(&inclinometer_handle);
if (ret == ESP_OK)
{
printf("Inclinometer position reset to zero.\n");
}
for (;;) for (;;)
{ {
float angle = 0; float angle = 0;
zh_inclinometer_get(&inclinometer_handle, &angle); ret = zh_inclinometer_get(&inclinometer_handle, &angle);
printf("Inclinometer position is %0.2f degrees.\n", angle); if (ret == ESP_OK)
{
printf("Inclinometer position is %0.2f degrees.\n", angle);
}
vTaskDelay(100 / portTICK_PERIOD_MS); vTaskDelay(100 / portTICK_PERIOD_MS);
} }
zh_inclinometer_deinit(&inclinometer_handle);
} }
``` ```