Skip to content

Commit ab82347

Browse files
committed
Attempt to fix the AnalogWrite issue
1 parent bcf1d08 commit ab82347

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/components/ledc/ws_ledc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ bool ws_ledc::analogWrite(uint8_t pin, int value) {
5454

5555
// Calculate duty cycle for the `value` passed in
5656
// (assumes 12-bit resolution, 2^12)
57-
uint32_t dutyCycle = (4095 / 255) * min(value, 255);
57+
//uint32_t dutyCycle = (4095 / 255) * min(value, 255);
58+
uint32_t dutyCycle =(uint32_t)(((double)12 / 255.0) * min(value, (uint32_t)255));
5859

5960
// Call duty cycle write
6061
return setDuty(pin, dutyCycle);

0 commit comments

Comments
 (0)