提交 05a3de26 编写于 作者: M Max 提交者: Me No Dev

Remove LEDC_BASE_FREQ to calculate duty (#381)

上级 d36e9bbf
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册