Skip to content

Commit da19abf

Browse files
authored
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
1 parent 4ee42c8 commit da19abf

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

components/led/include/led.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ class Led : public BaseComponent {
3737
ledc_mode_t speed_mode{
3838
LEDC_LOW_SPEED_MODE}; /**< The LEDC speed mode you want for this LED channel. */
3939
bool output_invert{false}; /**< Whether to invert the GPIO output for this LED channel. */
40+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0) || defined(_DOXYGEN_)
41+
ledc_sleep_mode_t sleep_mode{
42+
LEDC_SLEEP_MODE_KEEP_ALIVE}; /**< The LEDC sleep mode you want for this
43+
LED channel. Default is
44+
LEDC_SLEEP_MODE_KEEP_ALIVE which will
45+
keep the LEDC output when the system
46+
enters light sleep. Note that this is
47+
only useful if the LED's clock_config is
48+
set to a clock source which supports
49+
light sleep. */
50+
#endif
4051
};
4152

4253
/**

components/led/src/led.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ Led::Led(const Config &config) noexcept
4141
channel_conf.duty = actual_duty;
4242
channel_conf.gpio_num = conf.gpio;
4343
channel_conf.speed_mode = conf.speed_mode;
44+
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
45+
channel_conf.sleep_mode = conf.sleep_mode;
46+
#endif
4447
channel_conf.hpoint = 0;
4548
channel_conf.timer_sel = conf.timer;
4649
channel_conf.flags.output_invert = conf.output_invert;

0 commit comments

Comments
 (0)