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

Interface for WipperSnapper PWM. More...

#include <ws_pwm.h>

Public Member Functions

 ws_pwm ()
 Constructor for non-ESP32 platforms.
 
 ws_pwm (ws_ledc *ledcManager)
 Constructor for ESP32 platforms. More...
 
 ~ws_pwm ()
 Destructor.
 
bool attach (uint8_t pin, double freq, uint8_t resolution)
 Attaches a PWM pin. More...
 
void detach (uint8_t pin)
 Detaches a PWM pin. More...
 
void writeDutyCycle (uint8_t pin, int dutyCycle)
 Writes a duty cycle to a pin with a fixed freq of 5kHz. More...
 
void writeTone (uint8_t pin, uint32_t freq)
 Writes a frequency to a pin with a fixed duty cycle. More...
 
void noTone (uint8_t pin)
 Stops a square wave generated by writeTone(). More...
 

Detailed Description

Interface for WipperSnapper PWM.

Constructor & Destructor Documentation

◆ ws_pwm()

ws_pwm::ws_pwm ( ws_ledc ledcManager)

Constructor for ESP32 platforms.

Parameters
ledcManagerPointer to LEDC driver.

Member Function Documentation

◆ attach()

bool ws_pwm::attach ( uint8_t  pin,
double  freq,
uint8_t  resolution 
)

Attaches a PWM pin.

Parameters
pinGPIO pin.
freqPWM frequency, in Hz.
resolutionPWM resolution, in bytes.
Returns
True if PWM pin is successfully attached to a timer, otherwise False.

◆ detach()

void ws_pwm::detach ( uint8_t  pin)

Detaches a PWM pin.

Parameters
pinDesired GPIO pin.

◆ writeDutyCycle()

void ws_pwm::writeDutyCycle ( uint8_t  pin,
int  dutyCycle 
)

Writes a duty cycle to a pin with a fixed freq of 5kHz.

Parameters
pinGPIO pin to write to.
dutyCycleDesired duty cycle to write to a pin.

◆ writeTone()

void ws_pwm::writeTone ( uint8_t  pin,
uint32_t  freq 
)

Writes a frequency to a pin with a fixed duty cycle.

Parameters
pinGPIO pin to write to.
freqDesired frequency to write to a pin, in Hz.

◆ noTone()

void ws_pwm::noTone ( uint8_t  pin)

Stops a square wave generated by writeTone().

Parameters
pinGPIO pin to stop generating the tone on.

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