arrayFIFO in flash memory


#1

hi,
I’m trying to insert into the flash memory a FIFO array that cyclically saves values ​​every 2 minutes

var a = [];
popolaArray(a);
while(true) 
{
    for (var count = 0; count < 500; count++)
    {
        setInterval(function()
        {
            a[count] = count;
            console.log(a[count]);
        },2 * 60 * 1000);
    }
}

I am aware that as it is a horrible code,
anyway it gives me LOW_MEMORY error, MEMORY is because I’m not using flash memory?


#2

Hello,

There’s a few issues with your code.

  • You’re running in a while(true), which means RuuviTag cannot sleep and power consumption is large.
  • You’re setting the setInterval() in a for-loop 500 times which gives you 500 instances of function running at interval
  • The for-loop is within while(true), so you’re adding the setInterval() instances until you run out of memory. Using flash would not help here, you’d fill the flash almost instantly.

Try implementing the FIFO push and pop -functions, and calling those from one setInterval-function.


#3

Hi

I think that you are confusing setInterval and setTimeout methods.
I think that all you need is one call for setInterval.