Skip to content

Commit 2ab38f4

Browse files
committed
Update analogWrite.cpp
1 parent 8b465d4 commit 2ab38f4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/analogWrite.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**********************************************************************************
2-
AnalogWrite Library for ESP32-ESP32S2 Arduino core - Version 2.0.6
2+
AnalogWrite Library for ESP32-ESP32S2 Arduino core - Version 2.0.8
33
by dlloydev https://github.com/Dlloydev/ESP32-ESP32S2-AnalogWrite
44
This Library is licensed under the MIT License
55
**********************************************************************************/
@@ -236,12 +236,14 @@ int32_t analogWriteResolution(int8_t pin, uint8_t resolution) {
236236
if (ch >= 0) {
237237
if ((aw::pinsStatus[ch / aw::chd].pin) > 47) return -1;
238238
if (aw::pinsStatus[ch / aw::chd].resolution != resolution) {
239+
ledcDetachPin(pin);
239240
aw::awLedcSetup(ch, aw::pinsStatus[ch / aw::chd].frequency, resolution & 0xF);
241+
ledcAttachPin(pin, ch);
240242
ledcWrite(ch, aw::pinsStatus[ch / aw::chd].value);
241243
aw::pinsStatus[ch / aw::chd].resolution = resolution & 0xF;
242244
}
243245
}
244-
return 1 << resolution & 0xF;
246+
return 1 << (resolution & 0xF);
245247
}
246248

247249
void setPinsStatusDefaults(int32_t value, float frequency, uint8_t resolution, uint32_t phase) {

0 commit comments

Comments
 (0)