• Perhaps you are not aware of this, but in C/C++, arrays do not know their own size(an 'array' variable is actually just the memory address of the first entry) so the size must always be supplied separately.

    I had no idea no. I've done C# and js/ts, but not much C or C++.

    What you write makes me think that I should do something like this

        this.i2c.writeTo(this.MMA8451_ADDR, this.MMA8451_REG_OUT_X_MSB);
        let buffer = this.i2c.readFrom(this.MMA8451_ADDR, 6);
    

    Where I then only send the value the "write_then_read" function sends, and then read 6 bytes from the same address, however the data I get out still seems wrong, here are 4 readings and again it's just lying on the table not moving.

    x_g 7.9755859375 y_g 2.25146484375 z_g 5.50146484375
    buffer new Uint8Array([255, 59, 72, 13, 176, 12])
    
    x_g 7.9755859375 y_g 0.50146484375 z_g 4.75146484375
    buffer new Uint8Array([255, 59, 16, 13, 152, 12])
    
    x_g 7.9755859375 y_g 4.75146484375 z_g 3.75146484375
    buffer new Uint8Array([255, 59, 152, 14, 120, 12])
    
    x_g 7.9755859375 y_g 1.00146484375 z_g 6.25146484375
    buffer new Uint8Array([255, 59, 32, 13, 200, 12])
    
About

Avatar for TheLogan @TheLogan started