Safeguard if delay is too high

This commit is contained in:
Hadinger 2020-02-02 18:02:31 +01:00
parent ed455df760
commit 02df35b6b5
1 changed files with 1 additions and 0 deletions

View File

@ -262,6 +262,7 @@ static ICACHE_RAM_ATTR void timer1Interrupt() {
// Check for toggles // Check for toggles
int32_t cyclesToGo = wave->nextServiceCycle - now; int32_t cyclesToGo = wave->nextServiceCycle - now;
if (cyclesToGo < 0) { if (cyclesToGo < 0) {
cyclesToGo = -((-cyclesToGo) % (wave->nextTimeHighCycles + wave->nextTimeLowCycles));
waveformState ^= mask; waveformState ^= mask;
if (waveformState & mask) { if (waveformState & mask) {
if (i == 16) { if (i == 16) {