Add exFAT support (#150)

## Summary

* Swap to updated SDCardManager which uses SdFat
* Add exFAT support
  * Swap to using FsFile everywhere
* Use newly exposed `SdMan` macro to get to static instance of
SDCardManager
* Move a bunch of FsHelpers up to SDCardManager
This commit is contained in:
Dave Allie
2025-12-30 15:09:30 +10:00
committed by GitHub
parent d4bd119950
commit fb5fc32c5d
50 changed files with 289 additions and 355 deletions

View File

@@ -123,7 +123,7 @@ Bitmap::~Bitmap() {
delete[] errorNextRow;
}
uint16_t Bitmap::readLE16(File& f) {
uint16_t Bitmap::readLE16(FsFile& f) {
const int c0 = f.read();
const int c1 = f.read();
const auto b0 = static_cast<uint8_t>(c0 < 0 ? 0 : c0);
@@ -131,7 +131,7 @@ uint16_t Bitmap::readLE16(File& f) {
return static_cast<uint16_t>(b0) | (static_cast<uint16_t>(b1) << 8);
}
uint32_t Bitmap::readLE32(File& f) {
uint32_t Bitmap::readLE32(FsFile& f) {
const int c0 = f.read();
const int c1 = f.read();
const int c2 = f.read();
@@ -192,7 +192,7 @@ BmpReaderError Bitmap::parseHeaders() {
const uint16_t bfType = readLE16(file);
if (bfType != 0x4D42) return BmpReaderError::NotBMP;
file.seek(8, SeekCur);
file.seekCur(8);
bfOffBits = readLE32(file);
// --- DIB HEADER ---
@@ -214,10 +214,10 @@ BmpReaderError Bitmap::parseHeaders() {
// Allow BI_RGB (0) for all, and BI_BITFIELDS (3) for 32bpp which is common for BGRA masks.
if (!(comp == 0 || (bpp == 32 && comp == 3))) return BmpReaderError::UnsupportedCompression;
file.seek(12, SeekCur); // biSizeImage, biXPelsPerMeter, biYPelsPerMeter
file.seekCur(12); // biSizeImage, biXPelsPerMeter, biYPelsPerMeter
const uint32_t colorsUsed = readLE32(file);
if (colorsUsed > 256u) return BmpReaderError::PaletteTooLarge;
file.seek(4, SeekCur); // biClrImportant
file.seekCur(4); // biClrImportant
if (width <= 0 || height <= 0) return BmpReaderError::BadDimensions;

View File

@@ -1,6 +1,6 @@
#pragma once
#include <FS.h>
#include <SdFat.h>
enum class BmpReaderError : uint8_t {
Ok = 0,
@@ -28,7 +28,7 @@ class Bitmap {
public:
static const char* errorToString(BmpReaderError err);
explicit Bitmap(File& file) : file(file) {}
explicit Bitmap(FsFile& file) : file(file) {}
~Bitmap();
BmpReaderError parseHeaders();
BmpReaderError readRow(uint8_t* data, uint8_t* rowBuffer, int rowY) const;
@@ -40,10 +40,10 @@ class Bitmap {
int getRowBytes() const { return rowBytes; }
private:
static uint16_t readLE16(File& f);
static uint32_t readLE32(File& f);
static uint16_t readLE16(FsFile& f);
static uint32_t readLE32(FsFile& f);
File& file;
FsFile& file;
int width = 0;
int height = 0;
bool topDown = false;

View File

@@ -2,7 +2,6 @@
#include <EInkDisplay.h>
#include <EpdFontFamily.h>
#include <FS.h>
#include <map>