• Personally, I reckon a lot of that is handled by firmata already on the Arduino side... It is kind of a bytecode interpreter already - just without loops :)

    Now a module for Espruino that emits firmata? That'd be very cool - and yes, I guess you could parse rudimentary JS into bytecode.

    However something like this might work for functions?

    var wiring = require("Wiring").connect(Serial1);
    wiring.digitalWrite(13,HIGH);
    var commandList = wiring.record(function(wiring) {
        wiring.digitalWrite(8, LOW);
        wiring.shiftOut(11, 12, LSBFIRST, 16); //make 74hc595 go 0b00010000   
        wiring.digitalWrite(8, HIGH);
    });
    wiring.send(commandList);
    

    so when you do wiring.record it actually executes the JS on Espruino, but instead of sending the bytes for those commands to Espruino, it stores them in an array. Then, if you want to do something fast you can just blurt the command list out.

    I guess if you wanted to go faster, you could extend firmata on the Arduino with 'store command list' and 'play command list' commands? I don't know if that exists already - it seems like it'd be great if not?

About

Avatar for Gordon @Gordon started