doc: updated readme

This commit is contained in:
aZholtikov committed 2026-08-31 12:36:19 +03:00
1 parent f02dc77b28
commit 5dfc8b9033
3 files changed
+45 -799

No files matched your search

+45 -11
View File
@@ -1,13 +1,5 @@
# ESP32 ESP-IDF component for AC dimmer for 115V/400Hz
## Wiki
[EN](WIKI_EN.md) | [RU](WIKI_RU.md)
## Tested on
1. [ESP32 ESP-IDF v6.0.0](https://docs.espressif.com/projects/esp-idf/en/v6.0/esp32/index.html)
## SAST Tools
[PVS-Studio](https://pvs-studio.com/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source) — static analyzer for C, C++, C#, and Java code.
@@ -19,11 +11,22 @@
3. IRAM-safe ISR and callback functions for reliable operation.
4. Thread-safe start/stop/set/get API.
## Note
Enable the following settings in menuconfig:
```text
GPIO_CTRL_FUNC_IN_IRAM
CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM
CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
CONFIG_GPTIMER_ISR_CACHE_SAFE
```
## Using
In an existing project, run the following command to install the component:
```text
```bash
cd ../your_project/components
git clone https://github.com/aZholtikov/zh_ac_dimmer
```
@@ -34,6 +37,37 @@ In the application, add the component:
#include "zh_ac_dimmer.h"
```
## Examples
## Example
See Wiki [EN](WIKI_EN.md#usage-examples) | [RU](WIKI_RU.md#примеры-использования)
```c
#include "zh_ac_dimmer.h"
zh_ac_dimmer_handle_t *ac_dimmer_handle = NULL;
void app_main(void)
{
esp_log_level_set("zh_ac_dimmer", ESP_LOG_ERROR);
zh_ac_dimmer_init_config_t config = ZH_AC_DIMMER_INIT_CONFIG_DEFAULT();
config.zero_cross_gpio = GPIO_NUM_16;
config.triac_gpio = GPIO_NUM_17;
zh_ac_dimmer_init(&config, &ac_dimmer_handle);
zh_ac_dimmer_start(&ac_dimmer_handle);
uint8_t value = 0;
for (uint8_t i = 0; i <= 100; ++i)
{
zh_ac_dimmer_set(&ac_dimmer_handle, i);
zh_ac_dimmer_get(&ac_dimmer_handle, &value);
printf("Dimmer value: %d.\n", value);
vTaskDelay(100 / portTICK_PERIOD_MS);
}
for (uint8_t i = 100; i > 0; --i)
{
zh_ac_dimmer_set(&ac_dimmer_handle, i);
zh_ac_dimmer_get(&ac_dimmer_handle, &value);
printf("Dimmer value: %d.\n", value);
vTaskDelay(100 / portTICK_PERIOD_MS);
}
zh_ac_dimmer_stop(&ac_dimmer_handle);
zh_ac_dimmer_deinit(&ac_dimmer_handle);
}
```