74 lines
2.0 KiB
C
74 lines
2.0 KiB
C
#pragma once
|
|
|
|
// #include "stdio.h"
|
|
// #include "avr_err.h"
|
|
// #include "avr_port.h"
|
|
// #include "stdbool.h"
|
|
// #include "avr/interrupt.h"
|
|
// #include "util/delay.h"
|
|
#include "esp_log.h"
|
|
#include "driver/gpio.h"
|
|
|
|
#define ZH_AC_DIMMER_INIT_CONFIG_DEFAULT() \
|
|
{ \
|
|
.zero_cross_gpio = GPIO_NUM_MAX, \
|
|
.triac_gpio = GPIO_NUM_MAX, \
|
|
.triac_time = 1}
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
typedef struct // Structure for initial initialization of AC dimmer.
|
|
{
|
|
uint8_t zero_cross_gpio; // Zero cross GPIO.
|
|
uint8_t triac_gpio; // Triac GPIO.
|
|
uint8_t triac_time; // Triac turn-on time (in microseconds). Depends on the type of triac. Tested on BTA16-600.
|
|
} zh_ac_dimmer_init_config_t;
|
|
|
|
/**
|
|
* @brief Initialize AC dimmer.
|
|
*
|
|
* @param[in] config Pointer to AC dimmer initialized configuration structure. Can point to a temporary variable.
|
|
*
|
|
* @note Before initialize the AC dimmer recommend initialize zh_ac_dimmer_init_config_t structure with default values.
|
|
*
|
|
* @code zh_ac_dimmer_init_config_t config = ZH_AC_DIMMER_INIT_CONFIG_DEFAULT @endcode
|
|
*
|
|
* @return ESP_OK if success or an error code otherwise.
|
|
*/
|
|
esp_err_t zh_ac_dimmer_init(const zh_ac_dimmer_init_config_t *config);
|
|
|
|
/**
|
|
* @brief Start AC dimmer.
|
|
*
|
|
* @return ESP_OK if success or an error code otherwise.
|
|
*/
|
|
esp_err_t zh_ac_dimmer_start(void);
|
|
|
|
/**
|
|
* @brief Stop AC dimmer.
|
|
*
|
|
* @return ESP_OK if success or an error code otherwise.
|
|
*/
|
|
esp_err_t zh_ac_dimmer_stop(void);
|
|
|
|
/**
|
|
* @brief Set AC dimmer dimming value.
|
|
*
|
|
* @param[in] value Dimming value (0 to 100).
|
|
*
|
|
* @return ESP_OK if success or an error code otherwise.
|
|
*/
|
|
esp_err_t zh_ac_dimmer_set(uint8_t value);
|
|
|
|
// /**
|
|
// * @brief AC dimmer ISR handler.
|
|
// */
|
|
// void zh_ac_dimmer_isr_handler(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif |