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.
- Note
The handle was created by this function automatically destroy when
esp_periph_destroy
is called- Return
The esp peripheral handle
- Parameters
config
: The configuration
-
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.- Return
ESP_OK
ESP_FAIL
- Parameters
[in] periph
: The LED periph[in] gpio_num
: The gpio number[in] time_on_ms
: The time on milliseconds[in] time_off_ms
: The time off milliseconds[in] fade
: Fading enabled[in] loop
: Loop[in] level
: idle level
-
esp_err_t
periph_led_stop
(esp_periph_handle_t periph, int gpio_num)¶ Stop Blink the LED.
- Return
ESP_OK
ESP_FAIL
- Parameters
[in] periph
: The periph[in] gpio_num
: The gpio number
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