Quick update. I got UART.write, UART.eval, and a custom UART.on('myevent', callback) all working simultaneously.
UART.on('myevent', callback)
When I register a customconnection.on('data', ...) callback, it overwrites the on('data', ...) callback defined within UART.write (see https://github.com/espruino/EspruinoWebTools/blob/13032d0e862d9976ed5eed33b42f07e93e6c25c3/uart.js#L470-L474), so I had to copy those few lines back into my custom one. A bit hacky as I inject data back into the connection from the outside.
connection.on('data', ...)
Code is very rough right now, just working my way around things. But, if curious, for now code is here: https://editor.p5js.org/jgrizou/sketches/Si31amD_p (see robot.js and sketch.js) and testable at https://editor.p5js.org/jgrizou/present/Si31amD_p
Next I will try the proxy trick :)
@jgrizou started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Quick update. I got UART.write, UART.eval, and a custom
UART.on('myevent', callback)
all working simultaneously.When I register a custom
connection.on('data', ...)
callback, it overwrites the on('data', ...) callback defined within UART.write (see https://github.com/espruino/EspruinoWebTools/blob/13032d0e862d9976ed5eed33b42f07e93e6c25c3/uart.js#L470-L474), so I had to copy those few lines back into my custom one. A bit hacky as I inject data back into the connection from the outside.Code is very rough right now, just working my way around things. But, if curious, for now code is here: https://editor.p5js.org/jgrizou/sketches/Si31amD_p (see robot.js and sketch.js) and testable at https://editor.p5js.org/jgrizou/present/Si31amD_p
Next I will try the proxy trick :)