High-level interface for the ESP32/ESP32-Sx/ESP32-Cx LED Control (LEDC) peripheral. Instead of specifying a timer or channel, this class automatically allocates a channel and associates it with a pin. Underlying esp32-hal-ledc performs timer management and handles the low-level LEDC peripheral API calls.
More...
#include <ws_ledc.h>
|
|
| ws_ledc () |
| | Ctor.
|
| |
|
| ~ws_ledc () |
| | Dtor.
|
| |
| bool | attachPin (uint8_t pin, uint32_t freq, uint8_t resolution) |
| | Sets up a LEDC pin with given frequency and resolution. More...
|
| |
| bool | detachPin (uint8_t pin) |
| | Detaches a pin from LEDC. More...
|
| |
| bool | setDuty (uint8_t pin, uint32_t duty) |
| | Sets the duty cycle of a LEDC pin. More...
|
| |
| bool | analogWrite (uint8_t pin, int value) |
| | Arduino AnalogWrite function, but for ESP32's LEDC. More...
|
| |
| uint32_t | tone (uint8_t pin, uint32_t freq) |
| | Writes a square wave with a fixed duty cycle and variable frequency to a pin. Used by piezo buzzers and speakers. More...
|
| |
High-level interface for the ESP32/ESP32-Sx/ESP32-Cx LED Control (LEDC) peripheral. Instead of specifying a timer or channel, this class automatically allocates a channel and associates it with a pin. Underlying esp32-hal-ledc performs timer management and handles the low-level LEDC peripheral API calls.
◆ attachPin()
| bool ws_ledc::attachPin |
( |
uint8_t |
pin, |
|
|
uint32_t |
freq, |
|
|
uint8_t |
resolution |
|
) |
| |
Sets up a LEDC pin with given frequency and resolution.
- Parameters
-
| pin | Desired GPIO pin number. |
| freq | Desired timer frequency, in Hz. |
| resolution | Desired timer resolution, in bits. |
- Returns
- True if configuration is successful. False is returned if error occurs and LEDC channel was not configured.
◆ detachPin()
| bool ws_ledc::detachPin |
( |
uint8_t |
pin | ) |
|
Detaches a pin from LEDC.
- Parameters
-
| pin | Desired GPIO pin number. |
- Returns
- True if successfully detached, False otherwise.
◆ setDuty()
| bool ws_ledc::setDuty |
( |
uint8_t |
pin, |
|
|
uint32_t |
duty |
|
) |
| |
Sets the duty cycle of a LEDC pin.
- Parameters
-
| pin | Desired GPIO pin to write to. |
| duty | Desired duty cycle. |
- Returns
- True if duty cycle was set, False otherwise.
◆ analogWrite()
| bool ws_ledc::analogWrite |
( |
uint8_t |
pin, |
|
|
int |
value |
|
) |
| |
Arduino AnalogWrite function, but for ESP32's LEDC.
- Parameters
-
| pin | The desired pin to write to. |
| value | The duty cycle. |
- Returns
- True if PWM value written to LEDC pin, False otherwise.
◆ tone()
| uint32_t ws_ledc::tone |
( |
uint8_t |
pin, |
|
|
uint32_t |
freq |
|
) |
| |
Writes a square wave with a fixed duty cycle and variable frequency to a pin. Used by piezo buzzers and speakers.
- Parameters
-
| pin | The desired pin to write to. |
| freq | The frequency of the tone, in Hz. |
- Returns
- The frequency of the LEDC pin. 0 if error occurs and LEDC pin was not configured.
The documentation for this class was generated from the following files: