8 #ifndef LIBRARIES_ESP32SERVO_SRC_ESP32PWM_H_ 9 #define LIBRARIES_ESP32SERVO_SRC_ESP32PWM_H_ 10 #include "esp32-hal-ledc.h" 12 #define PWM_BASE_INDEX 0 13 #define USABLE_ESP32_PWM (NUM_PWM-PWM_BASE_INDEX) 34 static float mapf(
float x,
float in_min,
float in_max,
float out_min,
40 return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
43 double setup(
double freq, uint8_t resolution_bits=10);
55 void attachPin(uint8_t pin,
double freq, uint8_t resolution_bits=10);
61 void write(uint32_t duty);
66 double writeNote(note_t note, uint8_t octave);
103 ((pin >= 12) && (pin <= 19)) ||
104 ((pin >= 21) && (pin <= 23)) ||
105 ((pin >= 25) && (pin <= 27)) ||
106 (pin == 32) || (pin == 33))
void adjustFrequency(double freq, float dutyScaled=-1)
void adjustFrequencyLocal(double freq, float dutyScaled)
double setup(double freq, uint8_t resolution_bits=10)
static void allocateTimer(int timerNumber)
static int channelsRemaining()
static int timerAndIndexToChannel(int timer, int index)
void attachPin(uint8_t pin)
static ESP32PWM * ChannelUsed[NUM_PWM]
bool checkFrequencyForSideEffects(double freq)
static float mapf(float x, float in_min, float in_max, float out_min, float out_max)
static bool explicateAllocationMode
void write(uint32_t duty)
int allocatenext(double freq)
static double _ledcSetupTimerFreq(uint8_t chan, double freq, uint8_t bit_num)
double writeTone(double freq)
double writeNote(note_t note, uint8_t octave)
static long timerFreqSet[4]
static bool hasPwm(int pin)
ESP32PWM * pwmFactory(int pin)
void writeScaled(float duty)