• define 'not going to be especially fast'. In this particular case I'll have 10 second sampling interval

    It'd be perfect. You'll hit trouble if you try 100s a second, but for that it's fine :)

    If your object is simple, just using DataView does makes a lot of sense. DataView itself is based on the standard JS one so we're stuck without any kind of increment - you could always add your own functionality I guess:

    DataView.prototype.setUint16i = function(v) {
      this.setUint16(this.idx,v);
      this.idx+=2;
    };
    
    var buf = new ArrayBuffer(15);
    var d = new DataView(buf);
    d.idx = 0;
    d.setUint16i(1);
    d.setUint16i(2);
    d.setUint16i(3);
    

    While you can modify byteOffset in Espruino, you can't in normal JS so I'd avoid doing that if possible :)

About

Avatar for Gordon @Gordon started