@@ -337,8 +337,8 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
337
337
busyPins ^= pinBit;
338
338
}
339
339
else {
340
- const uint32_t overshootCcys = now - waveNextEventCcy;
341
- if (static_cast < int32_t >( overshootCcys) >= 0 ) {
340
+ const int32_t overshootCcys = now - waveNextEventCcy;
341
+ if (overshootCcys >= 0 ) {
342
342
const int32_t periodCcys = scaleCcys (wave.periodCcys );
343
343
if (waveform.states & pinBit) {
344
344
// active configuration and forward are 100% duty
@@ -361,12 +361,11 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
361
361
waveNextEventCcy = wave.nextPeriodCcy ;
362
362
}
363
363
else {
364
+ wave.nextPeriodCcy += periodCcys;
364
365
if (!wave.dutyCcys ) {
365
- wave.nextPeriodCcy += periodCcys;
366
366
wave.endDutyCcy = wave.nextPeriodCcy ;
367
367
}
368
368
else {
369
- wave.nextPeriodCcy += periodCcys;
370
369
int32_t dutyCcys = scaleCcys (wave.dutyCcys );
371
370
if (dutyCcys > wave.adjDutyCcys ) {
372
371
dutyCcys -= wave.adjDutyCcys ;
@@ -377,7 +376,7 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
377
376
dutyCcys = 0 ;
378
377
}
379
378
wave.endDutyCcy = now + dutyCcys;
380
- if (static_cast <int32_t >(wave.endDutyCcy - wave.nextPeriodCcy ) >= 0 ) {
379
+ if (static_cast <int32_t >(wave.endDutyCcy - wave.nextPeriodCcy ) > 0 ) {
381
380
wave.endDutyCcy = wave.nextPeriodCcy ;
382
381
}
383
382
waveform.states |= pinBit;
0 commit comments