Skip to content

Commit d0463bf

Browse files
authored
Merge pull request #752 from adafruit/fix-duty-cycle
Fix LEDC PWM DutyCycle
2 parents bcf1d08 + 564191c commit d0463bf

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit WipperSnapper
2-
version=1.0.0-beta.100
2+
version=1.0.0-beta.101
33
author=Adafruit
44
maintainer=Adafruit <adafruitio@adafruit.com>
55
sentence=Arduino application for Adafruit.io WipperSnapper

src/Wippersnapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
#endif
143143

144144
#define WS_VERSION \
145-
"1.0.0-beta.100" ///< WipperSnapper app. version (semver-formatted)
145+
"1.0.0-beta.101" ///< WipperSnapper app. version (semver-formatted)
146146

147147
// Reserved Adafruit IO MQTT topics
148148
#define TOPIC_IO_THROTTLE "/throttle" ///< Adafruit IO Throttle MQTT Topic

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 =
58+
(uint32_t)(((double)4095 / 255.0) * min((uint32_t)value, (uint32_t)255));
5859

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

0 commit comments

Comments
 (0)