Go Down

Topic: Reset Array to zeros (Read 172 times) previous topic - next topic


Mar 16, 2017, 10:46 am Last Edit: Mar 16, 2017, 12:25 pm by ChrisLewis
Hi Guys,

I have an array of 1500 elements that gets gradually filled with code before eventually being written to SD card.  Unfortunately the 1500 is intentionally too large as i only expect around 1300 events to fill the array (inderterminate amount between 1250 and 1350).

What i need to do is set the array to all zeros after the write to SD such that when it gets filled again if less elements than last time get filled then when it writes out the array i get the last few results from the previous enrties.

So i know i could loop through the array and set each element to zero but that seems inefficient.  Can anyone suggest a way to blank the array please?



Per Arduino ad Astra


You don't need to blank the whole array ;)

Overwrite the old data then when it's time to write to SD, fill whatever is left with 0 just before the write.

Or, remember how many elements were used last time, if the new amount of data to be written is less than the previous, fill with 0 to the previous element number, if more, do nothing, simples. At most you will only ever clear 100 elements.


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131