Closed technoblogy closed 12 months ago
The easiest solution I can think of is to replace the single delay()
call with a while loop
unsigned long ms = /* time to delay */;
while (--ms) {
delay(1);
testescape();
}
Good suggestion. More accurate is:
object *fn_delay (object *args, object *env) {
(void) env;
object *arg1 = first(args);
unsigned long start = millis();
unsigned long total = checkinteger(arg1);
do testescape();
while (millis() - start < total);
return arg1;
}
Ah, I forgot that testescape() takes a small, but significant, amount of time to run.
If you evaluate a delay, such as:
you can't escape with '~'.