Remove LEDC_BASE_FREQ to calculate duty (#381)
This commit is contained in:
parent
d36e9bbfa9
commit
05a3de262a
@ -28,8 +28,8 @@ int fadeAmount = 5; // how many points to fade the LED by
|
||||
// Arduino like analogWrite
|
||||
// value has to be between 0 and valueMax
|
||||
void ledcAnalogWrite(uint8_t channel, uint32_t value, uint32_t valueMax = 255) {
|
||||
// calculate duty
|
||||
uint32_t duty = (LEDC_BASE_FREQ / valueMax) * min(value, valueMax);
|
||||
// calculate duty, 8191 from 2 ^ 13 - 1
|
||||
uint32_t duty = (8191 / valueMax) * min(value, valueMax);
|
||||
|
||||
// write duty to LEDC
|
||||
ledcWrite(channel, duty);
|
||||
|
Loading…
Reference in New Issue
Block a user