Adafruit Library
Public Member Functions | List of all members
ws_ledc_servo Class Reference

High-level driver for servos for ESP32/ESP32-Sx/ESP32-Cx. This driver implements a subset of the functions within the Arduino servo library, (https://github.com/arduino-libraries/Servo/blob/master/src/Servo.h). More...

#include <ws_ledc_servo.h>

Public Member Functions

 ws_ledc_servo ()
 Constructor.
 
 ~ws_ledc_servo ()
 Destructor.
 
void setLEDCDriver (ws_ledc *ledcManager)
 Sets a LEDC driver for use with servo objects. More...
 
uint8_t attach (int pin, int minPulseWidth, int maxPulseWidth, int servoFreq)
 Attaches a servo object to a pin. More...
 
bool attached ()
 Returns if the servo is attached to a ledc timer. More...
 
void detach ()
 Detaches the servo (ledc timer) and de-allocates a servo object.
 
void writeMicroseconds (int value)
 Writes the pulse width to the connected servo pin. More...
 

Detailed Description

High-level driver for servos for ESP32/ESP32-Sx/ESP32-Cx. This driver implements a subset of the functions within the Arduino servo library, (https://github.com/arduino-libraries/Servo/blob/master/src/Servo.h).

Member Function Documentation

◆ setLEDCDriver()

void ws_ledc_servo::setLEDCDriver ( ws_ledc ledcManager)

Sets a LEDC driver for use with servo objects.

Parameters
ledcManagerPointer to LEDC driver.

◆ attach()

uint8_t ws_ledc_servo::attach ( int  pin,
int  minPulseWidth,
int  maxPulseWidth,
int  servoFreq 
)

Attaches a servo object to a pin.

Parameters
pinDesired GPIO pin.
minPulseWidthMinimum pulsewidth, in uS.
maxPulseWidthMaximum pulsewidth, in uS.
servoFreqDesired servo frequency, in Hz.
Returns
Channel number if a servo is successfully attached to a pin, otherwise 255.

◆ attached()

bool ws_ledc_servo::attached ( )

Returns if the servo is attached to a ledc timer.

Returns
True if the servo is attached to a timer, False otherwise.

◆ writeMicroseconds()

void ws_ledc_servo::writeMicroseconds ( int  value)

Writes the pulse width to the connected servo pin.

Parameters
valueDesired pulse width, in microseconds.

The documentation for this class was generated from the following files: