@@ -96,7 +96,6 @@ namespace {
96
96
// we can avoid looking at the other pins.
97
97
int startPin = 0 ;
98
98
int endPin = 0 ;
99
- int nextPin = 0 ;
100
99
uint32_t nextEventCcy;
101
100
} waveform;
102
101
@@ -284,13 +283,11 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
284
283
wave.nextPeriodCcy = waveform.pins [wave.alignPhase ].nextPeriodCcy + wave.nextPeriodCcy ;
285
284
if (static_cast <int32_t >(waveform.nextEventCcy - wave.nextPeriodCcy ) > 0 ) {
286
285
waveform.nextEventCcy = wave.nextPeriodCcy ;
287
- waveform.nextPin = waveform.toSet ;
288
286
}
289
287
}
290
288
else {
291
289
wave.nextPeriodCcy = isrStartCcy;
292
290
waveform.nextEventCcy = wave.nextPeriodCcy ;
293
- waveform.nextPin = waveform.toSet ;
294
291
}
295
292
if (!wave.expiryCcy ) {
296
293
wave.mode = WaveformMode::INFINITE;
@@ -310,31 +307,13 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
310
307
311
308
// Exit the loop if the next event, if any, is sufficiently distant.
312
309
const uint32_t isrTimeoutCcy = isrStartCcy + ISRTIMEOUTCCYS;
313
- uint32_t isrNextEventCcy;
314
- uint32_t busyPins = waveform.enabled ;
315
- if (waveform.enabled ) {
316
- if (static_cast <int32_t >(waveform.nextEventCcy - isrTimeoutCcy) >= 0 ) {
317
- busyPins = 0 ;
318
- }
319
- else {
320
- isrNextEventCcy = waveform.nextEventCcy ;
321
- waveform.nextEventCcy = isrStartCcy + MAXIRQTICKSCCYS;
322
- if (!(waveform.enabled & (1UL << waveform.nextPin ))) {
323
- waveform.nextPin = waveform.startPin ;
324
- }
325
- }
326
- }
327
- else {
310
+ uint32_t busyPins = (static_cast <int32_t >(waveform.nextEventCcy - isrTimeoutCcy) < 0 ) ? waveform.enabled : 0 ;
311
+ if (!waveform.enabled ) {
328
312
waveform.nextEventCcy = isrStartCcy + MAXIRQTICKSCCYS;
329
313
}
330
314
331
- const int stopPin = waveform.nextPin ;
332
- int pin = stopPin;
333
315
while (busyPins) {
334
- while (static_cast <int32_t >(isrNextEventCcy - ESP.getCycleCount ()) > 0 ) {
335
- }
336
- isrNextEventCcy = isrTimeoutCcy;
337
- do {
316
+ for (int pin = waveform.startPin ; pin <= waveform.endPin ; ++pin) {
338
317
const uint32_t pinBit = 1UL << pin;
339
318
// If it's not on, ignore
340
319
if (!(busyPins & pinBit))
@@ -415,14 +394,10 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
415
394
busyPins ^= pinBit;
416
395
if (static_cast <int32_t >(waveform.nextEventCcy - waveNextEventCcy) > 0 ) {
417
396
waveform.nextEventCcy = waveNextEventCcy;
418
- waveform.nextPin = pin;
419
397
}
420
398
}
421
- else if (static_cast <int32_t >(isrNextEventCcy - waveNextEventCcy) > 0 ) {
422
- isrNextEventCcy = waveNextEventCcy;
423
- }
424
399
}
425
- } while ((pin = (pin < waveform. endPin ) ? pin + 1 : waveform. startPin ) != stopPin);
400
+ }
426
401
}
427
402
428
403
int32_t callbackCcys = 0 ;
0 commit comments