From 2d3cecc0be66cb4224a2690419908b84ccdc5e2b Mon Sep 17 00:00:00 2001 From: Jochen Kiemes Date: Fri, 26 Apr 2024 22:54:09 +0200 Subject: [PATCH] test for issue #250 fails faster --- examples/Issue250/Issue250.ino | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/Issue250/Issue250.ino b/examples/Issue250/Issue250.ino index 3dfd0af..4ac5159 100644 --- a/examples/Issue250/Issue250.ino +++ b/examples/Issue250/Issue250.ino @@ -43,18 +43,24 @@ void loop() { loopcnt++; Serial.print("Loop="); Serial.println(loopcnt); + uint32_t start_ms; uint32_t delayForward = (rand() % 50) + 50; uint32_t delayBackward = (rand() % 50) + 50; stepper->runForward(); - delay(delayForward); + start_ms = millis(); + while (millis() < delayForward + start_ms) { + noInterrupts(); + _delay_us(25); + interrupts(); + } stepper->runBackward(); - uint32_t start_ms = millis(); + start_ms = millis(); while (millis() < delayBackward + start_ms) { noInterrupts(); _delay_us(25); interrupts(); } - if (loopcnt == 1000) { + if (loopcnt == 200) { #ifdef SIMULATOR stepper->moveTo(0, true); noInterrupts();