From 9c295a8ca34889ed8f39c0222cf7e741e52b3c1c Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Fri, 10 Jan 2025 12:07:42 -0600 Subject: [PATCH] feat(led): Update to allow configuration of the led sleep mode --- components/led/include/led.hpp | 9 +++++++++ components/led/src/led.cpp | 1 + 2 files changed, 10 insertions(+) diff --git a/components/led/include/led.hpp b/components/led/include/led.hpp index 81278b910..c712ce806 100644 --- a/components/led/include/led.hpp +++ b/components/led/include/led.hpp @@ -37,6 +37,15 @@ 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. */ + 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. */ }; /** diff --git a/components/led/src/led.cpp b/components/led/src/led.cpp index 5a72a4396..1fdfb9322 100644 --- a/components/led/src/led.cpp +++ b/components/led/src/led.cpp @@ -41,6 +41,7 @@ Led::Led(const Config &config) noexcept channel_conf.duty = actual_duty; channel_conf.gpio_num = conf.gpio; channel_conf.speed_mode = conf.speed_mode; + channel_conf.sleep_mode = conf.sleep_mode; channel_conf.hpoint = 0; channel_conf.timer_sel = conf.timer; channel_conf.flags.output_invert = conf.output_invert;