|
idfxx 1.0.0
Modern C++23 components for ESP-IDF
|
Type-safe PWM controller for ESP32. More...
Modules | |
| Timer Constants | |
| Predefined timer identifiers. | |
Namespaces | |
| namespace | idfxx |
| namespace | idfxx::pwm |
Classes | |
| class | idfxx::pwm::timer |
| A lightweight identifier for a hardware PWM timer. More... | |
| struct | idfxx::pwm::output_config |
| Output configuration parameters. More... | |
| class | idfxx::pwm::output |
| An active PWM output binding a timer, channel, and GPIO pin. More... | |
Enumerations | |
| enum class | idfxx::pwm::speed_mode : int { idfxx::pwm::speed_mode::low_speed = 0 } |
| PWM speed mode selection. More... | |
| enum class | idfxx::pwm::channel : int { idfxx::pwm::channel::ch_0 = 0 , idfxx::pwm::channel::ch_1 , idfxx::pwm::channel::ch_2 , idfxx::pwm::channel::ch_3 , idfxx::pwm::channel::ch_4 , idfxx::pwm::channel::ch_5 } |
| PWM channel slot identifiers. More... | |
| enum class | idfxx::pwm::clk_source : int { idfxx::pwm::clk_source::auto_select = 0 } |
| PWM timer clock source. More... | |
| enum class | idfxx::pwm::fade_mode : int { idfxx::pwm::fade_mode::no_wait = 0 , idfxx::pwm::fade_mode::wait_done } |
| Fade operation blocking mode. More... | |
| enum class | idfxx::pwm::sleep_mode : int { idfxx::pwm::sleep_mode::no_alive_no_pd = 0 , idfxx::pwm::sleep_mode::no_alive_allow_pd , idfxx::pwm::sleep_mode::keep_alive } |
| Channel behavior during light sleep. More... | |
Type-safe PWM controller for ESP32.
Provides PWM output management with lightweight timer identifiers and RAII-managed output bindings. Timers are fixed hardware resources configured via methods; outputs bind a timer, channel, and GPIO pin into an active PWM signal with automatic cleanup on destruction.
Depends on Core Utilities for error handling, GPIO Component for pin identifiers, and Hardware Support Component for interrupt allocation types.
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
| std::optional< timer > idfxx::pwm::get_timer | ( | enum channel | ch, |
| enum speed_mode | mode = speed_mode::low_speed |
||
| ) |
Returns the timer associated with an active channel, if any.
| ch | Channel to check. |
| mode | Speed mode group (defaults to low_speed). |
| bool idfxx::pwm::is_active | ( | enum channel | ch, |
| enum speed_mode | mode = speed_mode::low_speed |
||
| ) |
Returns true if the specified channel currently has an active output.
| ch | Channel to check. |
| mode | Speed mode group (defaults to low_speed). |
Starts PWM output on a GPIO pin.
Configures the specified channel to output PWM on the given GPIO pin using the provided timer's frequency and resolution.
| gpio | GPIO pin for the output. |
| tmr | Configured timer to use. Must have been configured via timer::configure(). |
| ch | Channel slot to use. |
| std::system_error | on failure. |
Definition at line 1176 of file pwm.hpp.
References idfxx::pwm::output::try_start, and idfxx::unwrap().
|
inline |
Starts PWM output on a GPIO pin with custom configuration.
| std::system_error | on failure. |
Definition at line 1179 of file pwm.hpp.
References idfxx::pwm::output::try_start, and idfxx::unwrap().
|
inline |
Starts PWM output with automatic timer and channel allocation.
Finds a timer already configured with matching parameters, or allocates and configures a new one. Then finds a free channel and starts PWM output. Only low-speed mode timers and channels are considered.
| gpio | GPIO pin for the output. |
| cfg | Timer configuration (frequency, resolution, clock source). |
| std::system_error | on failure. |
Definition at line 1182 of file pwm.hpp.
References idfxx::pwm::output::try_start, and idfxx::unwrap().
|
inline |
Starts PWM output with automatic allocation and custom output configuration.
| std::system_error | on failure. |
Definition at line 1185 of file pwm.hpp.
References idfxx::pwm::output::try_start, and idfxx::unwrap().
|
inline |
Stops PWM output on a channel and sets it to an idle level.
| std::system_error | on failure. |
Definition at line 1188 of file pwm.hpp.
References idfxx::pwm::output::try_stop(), and idfxx::unwrap().
Starts PWM output on a GPIO pin.
Configures the specified channel to output PWM on the given GPIO pin using the provided timer's frequency and resolution.
| gpio | GPIO pin for the output. |
| tmr | Configured timer to use. Must have been configured via timer::configure(). |
| ch | Channel slot to use. |
| invalid_state | Timer not configured. |
| invalid_arg | GPIO not connected or invalid channel. |
| result< output > idfxx::pwm::try_start | ( | idfxx::gpio | gpio, |
| const timer & | tmr, | ||
| enum channel | ch, | ||
| const output_config & | cfg | ||
| ) |
Starts PWM output on a GPIO pin with custom configuration.
| gpio | GPIO pin for the output. |
| tmr | Configured timer to use. Must have been configured via timer::configure(). |
| ch | Channel slot to use. |
| cfg | Output configuration. |
| invalid_state | Timer not configured. |
| invalid_arg | GPIO not connected or invalid channel. |
| result< output > idfxx::pwm::try_start | ( | idfxx::gpio | gpio, |
| const timer::config & | cfg | ||
| ) |
Starts PWM output with automatic timer and channel allocation.
Finds a timer already configured with matching parameters, or allocates and configures a new one. Then finds a free channel and starts PWM output. Only low-speed mode timers and channels are considered.
| gpio | GPIO pin for the output. |
| cfg | Timer configuration (frequency, resolution, clock source). |
| not_found | No free timer or channel available. |
| invalid_arg | GPIO not connected or invalid configuration. |
| result< output > idfxx::pwm::try_start | ( | idfxx::gpio | gpio, |
| const timer::config & | cfg, | ||
| const output_config & | out_cfg | ||
| ) |
Starts PWM output with automatic allocation and custom output configuration.
| gpio | GPIO pin for the output. |
| cfg | Timer configuration (frequency, resolution, clock source). |
| out_cfg | Output configuration (initial duty, hpoint, inversion, sleep mode). |
| not_found | No free timer or channel available. |
| invalid_arg | GPIO not connected or invalid configuration. |
| result< void > idfxx::pwm::try_stop | ( | enum channel | ch, |
| enum speed_mode | mode = speed_mode::low_speed, |
||
| idfxx::gpio::level | idle_level = idfxx::gpio::level::low |
||
| ) |
Stops PWM output on a channel and sets it to an idle level.
Stops the channel regardless of whether an output object owns it. Any existing output for this channel will become inactive.
| ch | Channel to stop. |
| mode | Speed mode group (defaults to low_speed). |
| idle_level | Output level after stopping. |