Skip to content

Commit

Permalink
feat(led): Update to allow configuration of the led sleep mode (#359)
Browse files Browse the repository at this point in the history
* feat(led): Update to allow configuration of the led sleep mode

* guard the led sleep mode around esp-idf 5.4 or greater
  • Loading branch information
finger563 authored Jan 10, 2025
1 parent 4ee42c8 commit da19abf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions components/led/include/led.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ class Led : public BaseComponent {
ledc_mode_t speed_mode{
LEDC_LOW_SPEED_MODE}; /**< The LEDC speed mode you want for this LED channel. */
bool output_invert{false}; /**< Whether to invert the GPIO output for this LED channel. */
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) || defined(_DOXYGEN_)
ledc_sleep_mode_t sleep_mode{
LEDC_SLEEP_MODE_KEEP_ALIVE}; /**< The LEDC sleep mode you want for this
LED channel. Default is
LEDC_SLEEP_MODE_KEEP_ALIVE which will
keep the LEDC output when the system
enters light sleep. Note that this is
only useful if the LED's clock_config is
set to a clock source which supports
light sleep. */
#endif
};

/**
Expand Down
3 changes: 3 additions & 0 deletions components/led/src/led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ Led::Led(const Config &config) noexcept
channel_conf.duty = actual_duty;
channel_conf.gpio_num = conf.gpio;
channel_conf.speed_mode = conf.speed_mode;
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
channel_conf.sleep_mode = conf.sleep_mode;
#endif
channel_conf.hpoint = 0;
channel_conf.timer_sel = conf.timer;
channel_conf.flags.output_invert = conf.output_invert;
Expand Down

0 comments on commit da19abf

Please sign in to comment.