Storing values in the array

Hi,

I am trying to save some values in the array but looks like Mongoose OS does not support .push() method in MJS. I have tried to use .splice() bit it does not seem to work. This is the code that I have

let arr = [];
let stId =Timer.set(0.5, Timer.REPEAT, function() {
    let r = ADC.read(34);
    arr.splice(arr.length,0,r);
    if (arr.length > 100) {
        Timer.del(stId);
        print('array ', arr)
    }
}, null);

You’re installing a 0.5 millisecond timer. Maybe you meant 500, not 0.5

@cpq No, it is supposed to be 0.5. I am trying to sample a 60Hz sinusoid signal. The problem is with arr.splice(arr.length,0,r);. It throws this error. Sorry for not posting it before

MJS callback error: unsupported object type

The first argument of Timer.set should an integer representing the timeout in milliseconds.

mgos_set_hw_timer can be used for shorter timeouts, but it is not available in mJS.