@@ -359,36 +359,21 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
359
359
// active configuration and forward are 100% duty
360
360
if (wave.periodCcys == wave.dutyCcys ) {
361
361
wave.nextPeriodCcy += periodCcys;
362
- waveNextEventCcy = wave.endDutyCcy = wave.nextPeriodCcy ;
362
+ wave.endDutyCcy = wave.nextPeriodCcy ;
363
363
}
364
364
else {
365
365
if (wave.autoPwm ) {
366
- if (static_cast <int32_t >(now - wave.nextPeriodCcy ) >= 0 ) {
367
- wave.endDutyCcy += periodCcys - overshootCcys;
368
- wave.nextPeriodCcy += periodCcys;
369
- waveNextEventCcy = wave.endDutyCcy ;
370
- // adapt expiry such that it occurs during intended cycle
371
- if (WaveformMode::EXPIRES == wave.mode )
372
- wave.expiryCcy += periodCcys;
373
- }
374
- else {
375
- wave.adjDutyCcys = overshootCcys;
376
- waveNextEventCcy = wave.nextPeriodCcy ;
377
- }
366
+ wave.adjDutyCcys += overshootCcys;
378
367
}
379
- else {
380
- waveNextEventCcy = wave.nextPeriodCcy ;
368
+ waveform.states ^= pinBit;
369
+ if (16 == pin) {
370
+ GP16O = 0 ;
381
371
}
382
- if (waveNextEventCcy == wave.nextPeriodCcy ) {
383
- waveform.states ^= pinBit;
384
- if (16 == pin) {
385
- GP16O = 0 ;
386
- }
387
- else {
388
- GPOC = pinBit;
389
- }
372
+ else {
373
+ GPOC = pinBit;
390
374
}
391
375
}
376
+ waveNextEventCcy = wave.nextPeriodCcy ;
392
377
}
393
378
else {
394
379
if (!wave.dutyCcys ) {
@@ -400,8 +385,12 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
400
385
int32_t dutyCcys = scaleCcys (wave.dutyCcys );
401
386
if (dutyCcys > wave.adjDutyCcys ) {
402
387
dutyCcys -= wave.adjDutyCcys ;
388
+ wave.adjDutyCcys = 0 ;
389
+ }
390
+ else {
391
+ wave.adjDutyCcys -= dutyCcys;
392
+ dutyCcys = 0 ;
403
393
}
404
- wave.adjDutyCcys = 0 ;
405
394
wave.endDutyCcy = now + dutyCcys;
406
395
if (static_cast <int32_t >(wave.endDutyCcy - wave.nextPeriodCcy ) >= 0 ) {
407
396
wave.endDutyCcy = wave.nextPeriodCcy ;
0 commit comments