As far as callbacks, if you do:
function touch(x,y) {
...
}
require("Touchscreen").connect(touch);
Then you can redefine the touch function, either by just entering it again, or by
typing edit("touch").
Hm. That's exactly what's not working (and the problem I meant when mentioning not being clear when copying function code vs referencing functions).
When I do this like in your example above, I can edit the touch function, but it will not have any effect, as the original one seems to be "submitted" and stays active.
If I instead use a double reference like
function touch(x,y) {doTouch(x,y);}
function doTouch(x,y) {console.log(x+"/"+y);}
require("Touchscreen").connect(touch);
, I can redefine doTouch effectively using edit().
That's where I stumbled and wondered if I somehow could delete the original callback.
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.
Hm. That's exactly what's not working (and the problem I meant when mentioning not being clear when copying function code vs referencing functions).
When I do this like in your example above, I can edit the touch function, but it will not have any effect, as the original one seems to be "submitted" and stays active.
If I instead use a double reference like
, I can redefine doTouch effectively using edit().
That's where I stumbled and wondered if I somehow could delete the original callback.