From da19abf4f071443140ea458f241289bce9ff01c0 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Fri, 10 Jan 2025 13:18:07 -0600 Subject: [PATCH] feat(led): Update to allow configuration of the led sleep mode (#359) * feat(led): Update to allow configuration of the led sleep mode * guard the led sleep mode around esp-idf 5.4 or greater --- components/led/include/led.hpp | 11 +++++++++++ components/led/src/led.cpp | 3 +++ 2 files changed, 14 insertions(+) diff --git a/components/led/include/led.hpp b/components/led/include/led.hpp index 81278b910..24c7d6e2e 100644 --- a/components/led/include/led.hpp +++ b/components/led/include/led.hpp @@ -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 }; /** diff --git a/components/led/src/led.cpp b/components/led/src/led.cpp index 5a72a4396..dde822134 100644 --- a/components/led/src/led.cpp +++ b/components/led/src/led.cpp @@ -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;