Yeah, good thing about PIRs is that they're easy to work with and there's lots of existing examples to work off of. Just be mindful that the Teensy is a 3.3V device (if the PIR can run at 3.3V, great, but otherwise you might need a logic level converter or something).
'Fraid I've got a lot on my plate and can't get deep into custom code at the moment, but if you want to try tackling it yourself (the uncannyEyes sketch is a huge ratsnest), I think doing things in the drawEye() function would be least problematic. I'll just give hacky pseudocode here that hopefully explains well enough...
Have a *global* variable (an unsigned long) that keeps track of the last time the PIR was triggered, initialize it to zero. e.g.:
Code: Select all
unsigned long lastTriggerTime = 0L;
Early in the drawEye() function, poll the PIR using whatever method, and if triggered, set lastTriggerTime to the current millis() time, e.g.:
Code: Select all
if(digitalRead(PIRpin) ) { // PIR triggered
lastTriggerTime = millis(); // Save last trigger time
}
A little later, in the gap between the SPI transaction start and the Y/X loops that issue data to the screens, check the current time against the saved trigger time, and if it's less than some threshold (let's say 5 seconds), draw the eyes, otherwise issue a bunch of 0 bytes to keep the screens empty, a la:
Code: Select all
if((millis() - lastTriggerTime) <= 5000) { // 5000 ms = 5 seconds
... existing Y/X drawing loops go here ...
} else {
... make a copy of the Y/X loops but just rig it so 'p' is ALWAYS zero ...
}
This is kinda hacky-kludgey-not-efficient but probably the least troublesome way to get it implemented in a hurry. The screens do have on/off commands (and if I recall correctly the TFT's have backlight a backlight control line), but this involves some deeper digging.