From 014def4c661047aec6b9cb194d933fdc630f51da Mon Sep 17 00:00:00 2001 From: Gregg Date: Wed, 15 Sep 2021 20:05:15 -0500 Subject: [PATCH] Fixed compiler complaint about pow() function. AND added 2.0.0 only variable - see LED_USE_APB_CLK. --- src/extras/PwmPin.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/extras/PwmPin.cpp b/src/extras/PwmPin.cpp index 59e7aa6..e33902f 100644 --- a/src/extras/PwmPin.cpp +++ b/src/extras/PwmPin.cpp @@ -18,6 +18,7 @@ LedC::LedC(uint8_t pin, uint16_t freq){ timerList[nTimer][nMode]->speed_mode=(ledc_mode_t)nMode; timerList[nTimer][nMode]->timer_num=(ledc_timer_t)nTimer; timerList[nTimer][nMode]->freq_hz=freq; + timerList[nTimer][nMode]->clk_cfg=LEDC_USE_APB_CLK; int res=LEDC_TIMER_BIT_MAX-1; // find the maximum possible resolution while(getApbFrequency()/(freq*pow(2,res))<1) @@ -75,7 +76,7 @@ void LedPin::set(float level){ if(level>100) level=100; - channel->duty=level*(pow(2,timer->duty_resolution)-1); + channel->duty=level*(pow(2,(int)timer->duty_resolution)-1); channel->duty/=100; ledc_channel_config(channel); @@ -177,7 +178,7 @@ void ServoPin::set(double degrees){ else if(usec>maxMicros) usec=maxMicros; - usec*=timer->freq_hz/1e6*(pow(2,timer->duty_resolution)-1); + usec*=timer->freq_hz/1e6*(pow(2,(int)timer->duty_resolution)-1); channel->duty=usec; ledc_channel_config(channel);