@@ -89,7 +89,7 @@ void Denko::dWrite(byte p, byte v, boolean echo) {
8989 #if defined(SOC_DAC_SUPPORTED)
9090 dacDisable (p);
9191 #endif
92- ledcDetachPin (p);
92+ ledcDetach (p);
9393 #endif
9494
9595 if (v == 0 ) {
@@ -117,9 +117,9 @@ void Denko::pwmWrite(byte p, int v, boolean echo) {
117117 byte channel = ledcChannel (p);
118118
119119 // Reattach the pin in case dWrite detached it.
120- ledcAttachPin (p , channel);
120+ ledcAttachChannel (p, 1000 , esp32AnalogWRes , channel);
121121
122- ledcWrite (channel , v);
122+ ledcWrite (p , v);
123123 #else
124124 analogWrite (p,v);
125125 #endif
@@ -158,8 +158,7 @@ byte Denko::assignLEDC(byte channel, byte p){
158158 // First 8 channels: up to 40Mhz @ 16-bits
159159 // Last 8 channels: up to 500kHz @ 13-bits
160160 // Just use similar settings to ATmega for now.
161- ledcSetup (channel, 1000 , 8 );
162- ledcAttachPin (p, channel);
161+ ledcAttachChannel (p, 1000 , esp32AnalogWRes, channel);
163162
164163 // Save the pin and mark it as in use.
165164 ledcPins[channel][0 ] = 1 ;
@@ -170,7 +169,7 @@ byte Denko::assignLEDC(byte channel, byte p){
170169// Release a LEDC channel when done with it.
171170void Denko::releaseLEDC (byte p){
172171 // Detach the pin from the channel.
173- ledcDetachPin (p);
172+ ledcDetach (p);
174173
175174 // Mark any channel associated with the pin as unused.
176175 for (int i = LEDC_CHANNEL_COUNT -1 ; i > 0 ; i--){
@@ -182,7 +181,7 @@ void Denko::releaseLEDC(byte p){
182181void Denko::clearLedcChannels (){
183182 for (int i = LEDC_CHANNEL_COUNT -1 ; i > 0 ; i--){
184183 // Stop the channel if it was still enabled.
185- if (ledcPins[i][0 ] != 0 ) ledcDetachPin (ledcPins[i][1 ]);
184+ if (ledcPins[i][0 ] != 0 ) ledcDetach (ledcPins[i][1 ]);
186185
187186 // Mark the channel as unused.
188187 ledcPins[i][0 ] = 0 ;
0 commit comments