wip:
This commit is contained in:
@@ -31,7 +31,7 @@ In the application, add the component:
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
esp_log_level_set("zh_ac_dimmer", ESP_LOG_NONE);
|
||||
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;
|
||||
|
||||
@@ -3,34 +3,25 @@
|
||||
static const char *TAG = "zh_ac_dimmer";
|
||||
|
||||
#define ZH_LOGI(msg, ...) ESP_LOGI(TAG, msg, ##__VA_ARGS__)
|
||||
#define ZH_LOGW(msg, ...) ESP_LOGW(TAG, msg, ##__VA_ARGS__)
|
||||
#define ZH_LOGE(msg, ...) ESP_LOGE(TAG, msg, ##__VA_ARGS__)
|
||||
#define ZH_LOGE_ERR(msg, err, ...) ESP_LOGE(TAG, "[%s:%d:%s] " msg, __FILE__, __LINE__, esp_err_to_name(err), ##__VA_ARGS__)
|
||||
#define ZH_LOGE(msg, err, ...) ESP_LOGE(TAG, "[%s:%d:%s] " msg, __FILE__, __LINE__, esp_err_to_name(err), ##__VA_ARGS__)
|
||||
|
||||
#define ZH_ERROR_CHECK(cond, err, msg, ...) \
|
||||
if (!(cond)) \
|
||||
{ \
|
||||
ZH_LOGE_ERR(msg, err); \
|
||||
ZH_LOGE(msg, err); \
|
||||
return err; \
|
||||
}
|
||||
|
||||
#define ZH_ERROR_CHECK_GOTO(cond, err, tag, msg, ...) \
|
||||
if (!(cond)) \
|
||||
{ \
|
||||
ZH_LOGE_ERR(msg, err); \
|
||||
goto tag; \
|
||||
}
|
||||
|
||||
static gptimer_handle_t _dimmer_timer = NULL;
|
||||
static gptimer_alarm_config_t _alarm_config = {0};
|
||||
|
||||
static zh_ac_dimmer_init_config_t _init_config = {0};
|
||||
static bool _is_dimmer_work = false;
|
||||
static uint64_t _prev_micros = 0;
|
||||
static uint32_t _current_frequency = 0;
|
||||
static uint32_t _prev_frequency = 0;
|
||||
static uint16_t _zero_cross_time = 0;
|
||||
static uint8_t _dimmer_value = 0;
|
||||
static bool _is_dimmer_work = false;
|
||||
static bool _is_initialized = false;
|
||||
|
||||
static esp_err_t _zh_ac_dimmer_validate_config(const zh_ac_dimmer_init_config_t *config);
|
||||
|
||||
Reference in New Issue
Block a user