Go Down

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

ChrisLewis

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?

Chris

Groove

Per Arduino ad Astra

weird_dave

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.

ChrisLewis


Go Up