ESP32 LEDC Output

Example Usage

// Basic
App.make_ledc_output(33);
// Custom Frequency
App.make_ledc_output(33, 2000.0);

See Application::make_ledc_output().

API Reference

LEDCOutputComponent

class LEDCOutputComponent : public output::FloatOutput, public Component

ESP32 LEDC output component.

Public Functions

LEDCOutputComponent(uint8_t pin, float frequency = 1000.0f, uint8_t bit_depth = 12)

Construct a LEDCOutputComponent. The channel will be set using the next_ledc_channel global variable.

void set_pin(uint8_t pin)

Manually set the pin used for this output.

void set_channel(uint8_t channel)

Manually set the ledc_channel used for this component.

void set_bit_depth(uint8_t bit_depth)

Manually set the bit depth. Defaults to 12.

void set_frequency(float frequency)

Manually set frequency the LEDC timer should operate on.

Two adjacent LEDC channels will usually receive the same timer and so can only have the same frequency.

Parameters
  • frequency: The frequency in Hz.

void setup()

Setup LEDC.

void dump_config()
float get_setup_priority() const

HARDWARE setup priority.

void write_state(float adjusted_value)

Override FloatOutput’s write_state.

float get_frequency() const
uint8_t get_bit_depth() const
uint8_t get_channel() const
uint8_t get_pin() const

Protected Attributes

uint8_t pin_
uint8_t channel_
uint8_t bit_depth_
float frequency_
uint8_t output::next_ledc_channel = 0