Added a new method to allow sketch to specify an IO pin for external SD cards to use as a media detect pin. Both Sparkfun and Adafruit boards have them. Which makes faster detecting of changes.
As part of the testing with MTP, I found that at times when card went away, that when we tell MTP that storage changed, that when it asked the SD for their new information, it mostly returned previous data as it is cached within the SDFat object.
I resolved that within the test sketches like:
if (media_present != myfs[i].media_present) {
storage_changed = true;
myfs[i].media_present = media_present;
if (media_present) DBGSerial.printf("\n### %s(%d) inserted dt:%u\n", myfs[i].name, i, (uint32_t)em);
else {
DBGSerial.printf("\n### %s(%d) removed dt:%u\n", myfs[i].name, i, (uint32_t)em);
myfs[i].sd.sdfs.end();
}
} else {
But wondering if I should put the call to sdfs.end(); within the mediaPresent call when we detect the transition?
@PaulStoffregen @mjs513
Added a new method to allow sketch to specify an IO pin for external SD cards to use as a media detect pin. Both Sparkfun and Adafruit boards have them. Which makes faster detecting of changes.
As part of the testing with MTP, I found that at times when card went away, that when we tell MTP that storage changed, that when it asked the SD for their new information, it mostly returned previous data as it is cached within the SDFat object.
I resolved that within the test sketches like:
But wondering if I should put the call to sdfs.end(); within the mediaPresent call when we detect the transition?