LED Peripheral
Blink or fade a LED connected to a GPIO with configurable On and Off times.
Application Examples
Implementation of this API is demonstrated in couple of examples:
API Reference
Header File
Functions
-
esp_periph_handle_t periph_led_init(periph_led_cfg_t *config)
Create the LED peripheral handle for esp_peripherals.
备注
The handle was created by this function automatically destroy when
esp_periph_destroy
is called- 参数
config – The configuration
- 返回
The esp peripheral handle
-
esp_err_t periph_led_blink(esp_periph_handle_t periph, int gpio_num, int time_on_ms, int time_off_ms, bool fade, int loop, periph_led_idle_level_t level)
Bink LED Peripheral, this function will automatically configure the gpio_num to control the LED, with
time_on_ms
as the time (in milliseconds) switch from OFF to ON (or ON if fade is disabled), andtime_off_ms
as the time (in milliseconds) switch from ON to OFF (or OFF if fade is disabled). When switching from ON -> OFF and vice versa, the loop decreases once, and will turn off the effect when the loop is 0. With a loop value less than 0, the LED effect will loop endlessly. PERIPH_LED_BLINK_FINISH events will be sent at each end of loop.- 参数
periph – [in] The LED periph
gpio_num – [in] The gpio number
time_on_ms – [in] The time on milliseconds
time_off_ms – [in] The time off milliseconds
fade – [in] Fading enabled
loop – [in] Loop
level – [in] idle level
- 返回
ESP_OK
ESP_FAIL
-
esp_err_t periph_led_stop(esp_periph_handle_t periph, int gpio_num)
Stop Blink the LED.
- 参数
periph – [in] The periph
gpio_num – [in] The gpio number
- 返回
ESP_OK
ESP_FAIL
Structures
-
struct periph_led_cfg_t
The LED peripheral configuration.
Public Members
-
ledc_mode_t led_speed_mode
LEDC speed speed_mode, high-speed mode or low-speed mode
-
ledc_timer_bit_t led_duty_resolution
LEDC channel duty resolution
-
ledc_timer_t led_timer_num
Select the timer source of channel (0 - 3)
-
uint32_t led_freq_hz
LEDC timer frequency (Hz)
-
int gpio_num
Optional, < 0 invalid gpio number
-
ledc_mode_t led_speed_mode