The SDuFAT library has some basic function for file log, can not meet some more complex requirements. Now Henning Karlsen publish a TinyFAT library and it’s really more powerful than former. And it had been designed to integrate with ITDB02_Graph and ITDB02_Graph16 - so now you can easy to use this library to read out the image in the SD cards and display on ITBD02 LCD module.
The library supports FAT16 formatted SD cards up to 2GB in size. 4GB FAT16 formatted SD cards might work, but is untested. Long filenames are not supported. Keep you filenames compliant with the old 8.3 standard.
The SD card should be connected to the SPI-pins on your Arduino. The Stackable SD Card Shield is compatible with it.
Structures:
file.buffer[];
Buffer used for reading and writing SD-card sectors.
Variables:
file.buffer[0-511]: Byte-array to hold one sector of data.
file.MBR;
Master Boot Record of the SD card.
Variables:
Part1Type: Partition1 Type. Only types 0×04, 0×06 and 0×86 can be used.
part1Start: First sector of Partition1.
part1Size: Number of sectors in Partition1.
file.BS;
Boot Sector of Partition1.
Variables:
sectorsPerCluster: Number of sectors per cluster.
reservedSectors: Number of reserved sectors.
fatCopies: Number of File Allocation Tables in partition. Almost always 2.
rootDirectoryEntries: Maximum number of root directory entries.
totalFilesystemSectors: Total number of sectors available to the file system.
sectorsPerFAT: Sectors per File Allocation Table.
hiddenSectors: Number of hidden sectors preceding the partition that contains this FAT volume.
partitionSerialNum: Partition serial number.
fat1Start: First sector of primary File Allocation Table.
fat2Start : First sector of secondary File Allocation Table.
partitionSize: Size of partition in MB.
file.DE;
Directory Entry structure. Used by findFirstFile() and findNextFile().
Variables:
filename: Char array containing the file’s name.
fileext: Char array containing the file’s extension.
attributes: File attributes.
time: File creation time (encoded).
date: File creation date (encoded).
startCluster: First cluster of file data.
fileSize: File size in bytes.
Functions:
file.initFAT(spispeed) : Initialize the interface, and connect to the SD card.
file.findFirstFile(DEstruct) : Find information about the first file in the root directory.
file.findNextFile(DEstruct) : Find information about the next file in the root directory.
file.openFile(filename, filemode) : Open a file for reading.
file.readBinary() : Read the next sector of an open binary file.
file.readLn(buffer, bufSize) : Read the next line of text from an open text-file.
file.writeLn(text) : Append a line of text to a text-file.
file.closeFile() : Close the currently open file.
file.exists(filename) : Check if a file exists.
file.rename(from-name, to-name) : Rename a file.
file.delFile(filename) : Delete a file.
file.create(filename) : Create a new, empty file.