Adafruit Library
ws_pwm.h
1 
17 #ifndef WS_PWM
18 #define WS_PWM
19 
20 #include "Wippersnapper.h"
21 
22 #ifdef ARDUINO_ARCH_ESP32
24 #endif
25 
26 class Wippersnapper;
27 class ws_ledc;
28 
29 /**************************************************************************/
33 /**************************************************************************/
34 class ws_pwm {
35 public:
36  ws_pwm();
37  ws_pwm(ws_ledc *ledcManager);
38  ~ws_pwm();
39  bool attach(uint8_t pin, double freq, uint8_t resolution);
40  void detach(uint8_t pin);
41  void writeDutyCycle(uint8_t pin, int dutyCycle);
42  void writeTone(uint8_t pin, uint32_t freq);
43  void noTone(uint8_t pin);
44 
45 private:
46  ws_ledc *_ledcMgr = nullptr;
47 };
48 extern Wippersnapper WS;
49 
50 #endif // WS_PWM
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.
Definition: ws_ledc.h:37
ws_pwm()
Constructor for non-ESP32 platforms.
Definition: ws_pwm.cpp:23
void noTone(uint8_t pin)
Stops a square wave generated by writeTone().
Definition: ws_pwm.cpp:121
~ws_pwm()
Destructor.
Definition: ws_pwm.cpp:38
void writeTone(uint8_t pin, uint32_t freq)
Writes a frequency to a pin with a fixed duty cycle.
Definition: ws_pwm.cpp:107
Class that provides storage and functions for the Adafruit IO Wippersnapper interface.
Definition: Wippersnapper.h:283
bool attach(uint8_t pin, double freq, uint8_t resolution)
Attaches a PWM pin.
Definition: ws_pwm.cpp:50
Interface for WipperSnapper PWM.
Definition: ws_pwm.h:34
Wippersnapper WS
Definition: Wippersnapper.cpp:36
void writeDutyCycle(uint8_t pin, int dutyCycle)
Writes a duty cycle to a pin with a fixed freq of 5kHz.
Definition: ws_pwm.cpp:88
void detach(uint8_t pin)
Detaches a PWM pin.
Definition: ws_pwm.cpp:71