This commit is contained in:
Liz 2025-08-01 08:56:34 -04:00
parent 147f31d68d
commit 94bbaf973f
3 changed files with 83 additions and 70 deletions

13
.clang-format Normal file
View file

@ -0,0 +1,13 @@
Language: Cpp
BasedOnStyle: Google
IndentWidth: 2
ColumnLimit: 80
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBraces: Attach
DerivePointerAlignment: false
PointerAlignment: Left
SpacesBeforeTrailingComments: 1

View file

@ -98,10 +98,10 @@ uint8_t Adafruit_ImageReader_EPD::mapColorForDisplay(uint8_t r, uint8_t g,
Vertical offset in pixels; top edge = 0, positive = down. Vertical offset in pixels; top edge = 0, positive = down.
@return None (void). @return None (void).
*/ */
void Adafruit_Image_EPD::draw(Adafruit_EPD &epd, int16_t x, int16_t y) { void Adafruit_Image_EPD::draw(Adafruit_EPD& epd, int16_t x, int16_t y) {
int16_t col = x, row = y; int16_t col = x, row = y;
if (format == IMAGE_1) { if (format == IMAGE_1) {
uint8_t *buffer = canvas.canvas1->getBuffer(); uint8_t* buffer = canvas.canvas1->getBuffer();
uint8_t i, c; uint8_t i, c;
while (row < y + canvas.canvas1->height()) { while (row < y + canvas.canvas1->height()) {
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
@ -122,7 +122,7 @@ void Adafruit_Image_EPD::draw(Adafruit_EPD &epd, int16_t x, int16_t y) {
}; };
} else if (format == IMAGE_8) { } else if (format == IMAGE_8) {
} else if (format == IMAGE_16) { } else if (format == IMAGE_16) {
uint16_t *buffer = canvas.canvas16->getBuffer(); uint16_t* buffer = canvas.canvas16->getBuffer();
thinkinkmode_t displayMode = epd.getMode(); thinkinkmode_t displayMode = epd.getMode();
while (row < y + canvas.canvas16->height()) { while (row < y + canvas.canvas16->height()) {
@ -160,7 +160,7 @@ void Adafruit_Image_EPD::draw(Adafruit_EPD &epd, int16_t x, int16_t y) {
often be in pre-setup() declaration, but DOES need initializing often be in pre-setup() declaration, but DOES need initializing
before any of the image loading or size functions are called! before any of the image loading or size functions are called!
*/ */
Adafruit_ImageReader_EPD::Adafruit_ImageReader_EPD(FatVolume &fs) Adafruit_ImageReader_EPD::Adafruit_ImageReader_EPD(FatVolume& fs)
: Adafruit_ImageReader(fs) {} : Adafruit_ImageReader(fs) {}
/*! /*!
@ -182,8 +182,8 @@ Adafruit_ImageReader_EPD::Adafruit_ImageReader_EPD(FatVolume &fs)
@return One of the ImageReturnCode values (IMAGE_SUCCESS on successful @return One of the ImageReturnCode values (IMAGE_SUCCESS on successful
completion, other values on failure). completion, other values on failure).
*/ */
ImageReturnCode Adafruit_ImageReader_EPD::drawBMP(char *filename, ImageReturnCode Adafruit_ImageReader_EPD::drawBMP(char* filename,
Adafruit_EPD &epd, int16_t x, Adafruit_EPD& epd, int16_t x,
int16_t y, boolean transact) { int16_t y, boolean transact) {
uint16_t epdbuf[BUFPIXELS]; // Temp space for buffering EPD data uint16_t epdbuf[BUFPIXELS]; // Temp space for buffering EPD data
// Call core BMP-reading function, passing address to EPD object, // Call core BMP-reading function, passing address to EPD object,
@ -222,12 +222,12 @@ ImageReturnCode Adafruit_ImageReader_EPD::drawBMP(char *filename,
completion, other values on failure). completion, other values on failure).
*/ */
ImageReturnCode Adafruit_ImageReader_EPD::coreBMP( ImageReturnCode Adafruit_ImageReader_EPD::coreBMP(
char *filename, // SD file to load char* filename, // SD file to load
Adafruit_EPD *epd, // Pointer to TFT object, or NULL if to image Adafruit_EPD* epd, // Pointer to TFT object, or NULL if to image
uint16_t *dest, // EPD working buffer, or NULL if to canvas uint16_t* dest, // EPD working buffer, or NULL if to canvas
int16_t x, // Position if loading to EPD (else ignored) int16_t x, // Position if loading to EPD (else ignored)
int16_t y, int16_t y,
Adafruit_Image_EPD *img, // NULL if load-to-screen Adafruit_Image_EPD* img, // NULL if load-to-screen
boolean transact) { // SD & EPD sharing bus, use transactions boolean transact) { // SD & EPD sharing bus, use transactions
thinkinkmode_t displayMode = epd ? epd->getMode() : THINKINK_TRICOLOR; thinkinkmode_t displayMode = epd ? epd->getMode() : THINKINK_TRICOLOR;
ImageReturnCode status = IMAGE_ERR_FORMAT; // IMAGE_SUCCESS on valid file ImageReturnCode status = IMAGE_ERR_FORMAT; // IMAGE_SUCCESS on valid file
@ -238,7 +238,7 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP(
uint8_t depth; // BMP bit depth uint8_t depth; // BMP bit depth
uint32_t compression = 0; // BMP compression mode uint32_t compression = 0; // BMP compression mode
uint32_t colors = 0; // Number of colors in palette uint32_t colors = 0; // Number of colors in palette
uint16_t *quantized = NULL; // EPD Color palette uint16_t* quantized = NULL; // EPD Color palette
uint32_t rowSize; // >bmpWidth if scanline padding uint32_t rowSize; // >bmpWidth if scanline padding
uint8_t sdbuf[3 * BUFPIXELS]; // BMP read buf (R+G+B/pixel) uint8_t sdbuf[3 * BUFPIXELS]; // BMP read buf (R+G+B/pixel)
int16_t epd_col = 0, epd_row = 0; int16_t epd_col = 0, epd_row = 0;
@ -248,7 +248,7 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP(
uint16_t srcidx = sizeof sdbuf; uint16_t srcidx = sizeof sdbuf;
#endif #endif
uint32_t destidx = 0; uint32_t destidx = 0;
uint8_t *dest1 = NULL; // Dest ptr for 1-bit BMPs to img uint8_t* dest1 = NULL; // Dest ptr for 1-bit BMPs to img
boolean flip = true; // BMP is stored bottom-to-top boolean flip = true; // BMP is stored bottom-to-top
uint32_t bmpPos = 0; // Next pixel position in file uint32_t bmpPos = 0; // Next pixel position in file
int loadWidth, loadHeight, // Region being loaded (clipped) int loadWidth, loadHeight, // Region being loaded (clipped)
@ -366,7 +366,7 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP(
} }
if ((depth >= 16) || if ((depth >= 16) ||
(quantized = (uint16_t *)malloc(colors * sizeof(uint16_t)))) { (quantized = (uint16_t*)malloc(colors * sizeof(uint16_t)))) {
if (depth < 16) { if (depth < 16) {
// Load and quantize color table // Load and quantize color table
thinkinkmode_t displayMode = thinkinkmode_t displayMode =

View file

@ -23,10 +23,10 @@
ImageReader.loadBMP() and Image.draw(), not ImageReader.drawBMP(). ImageReader.loadBMP() and Image.draw(), not ImageReader.drawBMP().
*/ */
class Adafruit_Image_EPD : public Adafruit_Image { class Adafruit_Image_EPD : public Adafruit_Image {
public: public:
void draw(Adafruit_EPD &epd, int16_t x, int16_t y); void draw(Adafruit_EPD& epd, int16_t x, int16_t y);
protected: protected:
friend class Adafruit_ImageReader_EPD; ///< Loading occurs here friend class Adafruit_ImageReader_EPD; ///< Loading occurs here
}; };
@ -43,17 +43,17 @@ protected:
for use. for use.
*/ */
class Adafruit_ImageReader_EPD : public Adafruit_ImageReader { class Adafruit_ImageReader_EPD : public Adafruit_ImageReader {
public: public:
Adafruit_ImageReader_EPD(FatVolume &fs); Adafruit_ImageReader_EPD(FatVolume& fs);
ImageReturnCode drawBMP(char *filename, Adafruit_EPD &epd, int16_t x, ImageReturnCode drawBMP(char* filename, Adafruit_EPD& epd, int16_t x,
int16_t y, boolean transact = true); int16_t y, boolean transact = true);
static uint8_t mapColorForDisplay(uint8_t r, uint8_t g, uint8_t b, static uint8_t mapColorForDisplay(uint8_t r, uint8_t g, uint8_t b,
thinkinkmode_t mode); thinkinkmode_t mode);
private: private:
ImageReturnCode coreBMP(char *filename, Adafruit_EPD *epd, uint16_t *dest, ImageReturnCode coreBMP(char* filename, Adafruit_EPD* epd, uint16_t* dest,
int16_t x, int16_t y, Adafruit_Image_EPD *img, int16_t x, int16_t y, Adafruit_Image_EPD* img,
boolean transact); boolean transact);
}; };