PaulStoffregen / SD

70 stars 41 forks source link

If we detected no SD return 0 for usedSize/totalSize #43

Closed KurtE closed 2 years ago

KurtE commented 2 years ago

Hi @PaulStoffregen @mjs513

With the media detection code when we detect that the SD went away, when you do a refresh of the top level Teensy object in MTP, it still returns the same values as before as the SDFat has this data cached.

This code simply detect that our cardPreviouslyPresent is set when we do begin and when we do detection so if we belive there is no SD card, simply return 0.

WIth this now if you do a refresh in MTP, the drive shows up in RED as expected.

Edit: Also picked up the change I hit sitting in my branch that SdFat_Usage example sketch was not building. Not sure why we need to cast: myfile.write((uint8_t)'\0') But it works