LCD Driver, some teensy code, SDCard code, MBR/FAT32

This commit is contained in:
2021-02-11 20:08:25 +01:00
parent 3babe3f1ef
commit faf6e55bc5
19 changed files with 1679 additions and 25 deletions

View File

@@ -0,0 +1,45 @@
class DirIterator {
FS& fs;
ClusterNr nextCluster;
int curEntryInCluster;
uint8_t buf[512];
public:
DirIterator(FS& fs, ClusterNr clusterNr) : fs(fs), nextCluster(clusterNr), curEntryInCluster(255) {
}
bool hasNext() {
while(true) {
++curEntryInCluster;
// reached end of cluster? load the next one
if (curEntryInCluster > fs.tmp.dirEntriesPerSector) {
fs.dev.read(fs.clusterToAbsPos(nextCluster), 512, buf);
nextCluster = fs.getNextCluster(nextCluster);
curEntryInCluster = 0;
}
DirEntry* desc = reinterpret_cast<DirEntry*>(buf + (sizeof(DirEntry) * curEntryInCluster));
if (desc->isLongFileName()) {continue;}
if (desc->isUnused()) {continue;}
if (desc->isEndOfDirectory()) {return false;}
return true;
}
}
DirEntry next() {
DirEntry* de = reinterpret_cast<DirEntry*>(buf + (sizeof(DirEntry) * curEntryInCluster));
return *de;
}
};