-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Actually support interrupts #46
Comments
You could implement an observer pattern that unblocks each "interrupt thread" depending on the user's configuration. For instance, you could have the user insert a specially formatted comment on how often they would like their thread triggered. //*~* 20ms
attachInterrupt(digitalPinToInterrupt(2), tick, RISING); Just a first thought from the top of my head. |
Wouldn't that only apply to |
I haven't really understood how you were planning to "visualize" this, but I imagine you would want the user to somehow set a frequency that "pulses" (and therefore trigger these events) are arriving or to be able trigger things manually (e.g. pressing a switch). This could be done somehow via a parsable comment in the code or a separate menu/config somewhere else in the emulation environment. Btw, ultimately, all interrupts are |
Well, let's take this basic example (as bad as it looks, at least it is simple): void setup(){
attachInterrupt(digitalPinToInterrupt(1), +[](){ Serial.println("Button pressed!"); }, RISING);
}
void loop(){} Assuming a push button is correctly wired to GPIO1, to us expected behavior would be to have |
Regarding the polling frequency, the game engine's milliseconds per tick are the bottleneck, since it is the only possible source of events, and all interrupts are checked at the end of every tick. Our only problem is guaranteeing that the board thread won't be suspended in a syscall that locks system mutexes, since that would quickly cause a deadlock and hang the whole process (and that's obviously not what the user wants) |
Hmmm, don't understand the context fully so I can't add much more but good luck nonetheless! 😛 |
Thanks, we'll need it; enjoy seeing the result whenever I manage to get it stable across all 3 major platforms and compilers |
Right now interrupts are never fired
This needs to change; people often rely on them, and even smartcar_shield has a snippet relying on them.
This basically means have suspendable threads
On Windows use
SuspendThread
On Un*x, attempt to use
pthread_suspend
(which basically nobody implemented anywhere)pthread_suspend_np
(OpenBSD and FreeBSD implemented that)Some ideas and info can be dug from this SO answer and its comments
Acceptance criteria: Interrupts are fired when the user expects them to, and they do not cause deadlocks.
The text was updated successfully, but these errors were encountered: