OpenBCI / OpenBCI_Cyton_Library

Repository for OpenBCI Cyton Arduino Libraries
MIT License
87 stars 88 forks source link

SD Data-logging Fix- V3.1.4 #102

Open IoaSman1 opened 2 years ago

IoaSman1 commented 2 years ago
zeyus commented 2 years ago

Thanks for this, I'm in the process of testing this at the moment, the code looks good, I'm just wondering if it wouldn't make sense to also include a check for the current sample rate so the block allocation varies depending on the sample rate, e.g.:

// SD_Card_Stuff.ino

// ...
boolean setupSDcard(char limit){
  // ...
  BLOCK_COUNT = ceil(BLOCK_COUNT / 250 * board.getSampleRate().toInt());
  // ...
}
// ...

That way if you use 1000Hz, you'll get a larger file...also this setting shouldn't affect performance as it only happens once during the SD card setup.

zeyus commented 2 years ago

I've just noticed that if the data overruns the file there's no footer written to the sdcard (I'll need to have another look but I'm guessing the limit for writing data should be reserved size - footer length

IoaSman1 commented 2 years ago

One more fixed is included