Adafruit Library
ws_ledc.h
Go to the documentation of this file.
1 
16 #ifndef WS_LEDC_H
17 #define WS_LEDC_H
18 
19 #include "Wippersnapper.h"
20 
21 #include "esp32-hal-ledc.h"
22 #include "esp_err.h"
23 
24 // forward decl.
25 class Wippersnapper;
26 
27 /**************************************************************************/
36 /**************************************************************************/
37 class ws_ledc {
38 public:
39  /**************************************************************************/
43  /**************************************************************************/
44  ws_ledc(){};
45  /**************************************************************************/
49  /**************************************************************************/
50  ~ws_ledc(){};
51  bool attachPin(uint8_t pin, uint32_t freq, uint8_t resolution);
52  bool detachPin(uint8_t pin);
53  // LEDC-API
54  bool setDuty(uint8_t pin, uint32_t duty);
55  bool analogWrite(uint8_t pin, int value);
56  uint32_t tone(uint8_t pin, uint32_t freq);
57 };
58 extern Wippersnapper WS;
59 
60 #endif // ws_ledc_H
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_ledc()
Dtor.
Definition: ws_ledc.h:50
bool analogWrite(uint8_t pin, int value)
Arduino AnalogWrite function, but for ESP32's LEDC.
Definition: ws_ledc.cpp:51
bool setDuty(uint8_t pin, uint32_t duty)
Sets the duty cycle of a LEDC pin.
Definition: ws_ledc.cpp:71
Class that provides storage and functions for the Adafruit IO Wippersnapper interface.
Definition: Wippersnapper.h:283
bool detachPin(uint8_t pin)
Detaches a pin from LEDC.
Definition: ws_ledc.cpp:41
ws_ledc()
Ctor.
Definition: ws_ledc.h:44
bool attachPin(uint8_t pin, uint32_t freq, uint8_t resolution)
Sets up a LEDC pin with given frequency and resolution.
Definition: ws_ledc.cpp:30
Wippersnapper WS
Definition: Wippersnapper.cpp:36
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 a...
Definition: ws_ledc.cpp:85