@@ -359,36 +359,21 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
359359 // active configuration and forward are 100% duty
360360 if (wave.periodCcys == wave.dutyCcys ) {
361361 wave.nextPeriodCcy += periodCcys;
362- waveNextEventCcy = wave.endDutyCcy = wave.nextPeriodCcy ;
362+ wave.endDutyCcy = wave.nextPeriodCcy ;
363363 }
364364 else {
365365 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;
378367 }
379- else {
380- waveNextEventCcy = wave.nextPeriodCcy ;
368+ waveform.states ^= pinBit;
369+ if (16 == pin) {
370+ GP16O = 0 ;
381371 }
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;
390374 }
391375 }
376+ waveNextEventCcy = wave.nextPeriodCcy ;
392377 }
393378 else {
394379 if (!wave.dutyCcys ) {
@@ -400,8 +385,12 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
400385 int32_t dutyCcys = scaleCcys (wave.dutyCcys );
401386 if (dutyCcys > wave.adjDutyCcys ) {
402387 dutyCcys -= wave.adjDutyCcys ;
388+ wave.adjDutyCcys = 0 ;
389+ }
390+ else {
391+ wave.adjDutyCcys -= dutyCcys;
392+ dutyCcys = 0 ;
403393 }
404- wave.adjDutyCcys = 0 ;
405394 wave.endDutyCcy = now + dutyCcys;
406395 if (static_cast <int32_t >(wave.endDutyCcy - wave.nextPeriodCcy ) >= 0 ) {
407396 wave.endDutyCcy = wave.nextPeriodCcy ;
0 commit comments