Added method to change the ledc PWM frequency programmatically (#5003)

Added method to change the ledc PWM frequence programmatically
Returning frequency from ledcChangeFrequency
This commit is contained in:
Richard Strassheim 2021-04-17 01:06:58 +02:00 committed by GitHub
parent 57cf2fb9f5
commit 01c8cae0dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -318,3 +318,12 @@ void ledcDetachPin(uint8_t pin)
{
pinMatrixOutDetach(pin, false, false);
}
double ledcChangeFrequency(uint8_t chan, double freq, uint8_t bit_num)
{
if (chan > 15) {
return 0;
}
double res_freq = _ledcSetupTimerFreq(chan, freq, bit_num);
return res_freq;
}

View File

@ -35,6 +35,7 @@ uint32_t ledcRead(uint8_t channel);
double ledcReadFreq(uint8_t channel);
void ledcAttachPin(uint8_t pin, uint8_t channel);
void ledcDetachPin(uint8_t pin);
double ledcChangeFrequency(uint8_t channel, double freq, uint8_t resolution_bits);
#ifdef __cplusplus