Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 05a3de2

Browse filesBrowse files
Maxme-no-dev
Max
authored andcommitted
Remove LEDC_BASE_FREQ to calculate duty (espressif#381)
1 parent d36e9bb commit 05a3de2
Copy full SHA for 05a3de2

File tree

Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed

‎libraries/ESP32/examples/AnalogOut/LEDCSoftwareFade/LEDCSoftwareFade.ino

Copy file name to clipboardExpand all lines: libraries/ESP32/examples/AnalogOut/LEDCSoftwareFade/LEDCSoftwareFade.ino
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ int fadeAmount = 5; // how many points to fade the LED by
2828
// Arduino like analogWrite
2929
// value has to be between 0 and valueMax
3030
void ledcAnalogWrite(uint8_t channel, uint32_t value, uint32_t valueMax = 255) {
31-
// calculate duty
32-
uint32_t duty = (LEDC_BASE_FREQ / valueMax) * min(value, valueMax);
31+
// calculate duty, 8191 from 2 ^ 13 - 1
32+
uint32_t duty = (8191 / valueMax) * min(value, valueMax);
3333

3434
// write duty to LEDC
3535
ledcWrite(channel, duty);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.