File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -332,8 +332,8 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
332
332
wave.nextPeriodCcy += wave.periodCcys ;
333
333
nextEdgeCcy = wave.endDutyCcy = wave.nextPeriodCcy ;
334
334
}
335
- else if (wave.autoPwm && now >= wave.nextPeriodCcy ) {
336
- const uint32_t adj = 2 + (( overshootCcys / wave.periodCcys ) << 1 ) ;
335
+ else if (wave.autoPwm && static_cast < int32_t >( now - wave.nextPeriodCcy ) >= 0 ) {
336
+ const uint32_t adj = ( overshootCcys + wave.dutyCcys ) / wave. periodCcys ;
337
337
// maintain phase, maintain duty/idle ratio, temporarily reduce frequency by fwdPeriods
338
338
nextEdgeCcy = wave.endDutyCcy = wave.nextPeriodCcy + adj * wave.dutyCcys ;
339
339
wave.nextPeriodCcy += adj * wave.periodCcys ;
@@ -360,8 +360,8 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
360
360
else {
361
361
wave.nextPeriodCcy += wave.periodCcys ;
362
362
wave.endDutyCcy = now + wave.dutyCcys ;
363
- if (overshootCcys >= wave.dutyCcys ) {
364
- const uint32_t adj = 1 + (( overshootCcys / wave.dutyCcys ) << 1 ) ;
363
+ if (static_cast < int32_t >(wave. endDutyCcy - wave.nextPeriodCcy ) >= 0 ) {
364
+ const uint32_t adj = ( overshootCcys + wave.dutyCcys ) / wave. periodCcys ;
365
365
wave.nextPeriodCcy += adj * wave.periodCcys ;
366
366
if (wave.autoPwm ) {
367
367
// maintain phase, maintain duty/idle ratio, temporarily reduce frequency by fwdPeriods
You can’t perform that action at this time.
0 commit comments