Replies: 3 comments
-
See the discussion here. But to summarize, Belay requires all "transactions" to be initiated by the host (real computer running cpython). So, in the case of reading something like a button input, unfortunately you just have to poll. You could have an interrupt set a variable, and then have the computer read that variable and reset it if set. Same thing for a rotary encoder (except maybe recording as a positive/negative integer for number of clicks since last host-read). |
Beta Was this translation helpful? Give feedback.
-
To understand why, at a fundamental level, Belay just interacts with the device over the REPL. So what can be achieved is limited to what we can conventionally perform over the REPL. |
Beta Was this translation helpful? Give feedback.
-
Aha, thanks – I had looked for prior threads on this question in the Discussion section but didn't look in Issues. I'll take my thoughts over there. And in the meantime, for my use case, going with HTTP calls is probably going to be the simplest solution, at least for now. Thanks! |
Beta Was this translation helpful? Give feedback.
-
I'm trying to figure out if I can use Belay in a project where the micropython device is used both for output (e.g. LEDs or screens) and input (e.g. buttons, rotary encoders, etc).
In my case, the host system is actually a web server, so I'm thinking possibly I could call pin.irq() inside of an @Device.setup function to establish an interrupt handler that uses requests.get() to make an HTTP request back to the host. And maybe that will work fine, but it does feel somewhat inelegant to be using such different mechanisms for calls made from host to device versus device to host. Especially given that part of the point of Belay is to provide the communication protocol.
Is this actually solved already in some way that I just haven't spotted yet? Or is it something you've thought about adding?
Beta Was this translation helpful? Give feedback.
All reactions