diff --git a/.clang-format b/.clang-format index ed70f56..eba585d 100644 --- a/.clang-format +++ b/.clang-format @@ -2,12 +2,21 @@ Language: Cpp BasedOnStyle: Google IndentWidth: 2 ColumnLimit: 80 -AllowShortFunctionsOnASingleLine: Empty +AllowShortFunctionsOnASingleLine: All AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false BinPackArguments: true BinPackParameters: true BreakBeforeBraces: Attach DerivePointerAlignment: false -PointerAlignment: Left -SpacesBeforeTrailingComments: 1 \ No newline at end of file +PointerAlignment: Right +SpacesBeforeTrailingComments: 1 +IndentCaseLabels: true +SortIncludes: false +AlignTrailingComments: true +MaxEmptyLinesToKeep: 2 +SpaceAfterCStyleCast: false +AllowShortBlocksOnASingleLine: false +KeepEmptyLinesAtTheStartOfBlocks: true +AccessModifierOffset: -2 +IndentAccessModifiers: false \ No newline at end of file diff --git a/Adafruit_ImageReader.cpp b/Adafruit_ImageReader.cpp index a746245..972e887 100644 --- a/Adafruit_ImageReader.cpp +++ b/Adafruit_ImageReader.cpp @@ -529,8 +529,8 @@ ImageReturnCode Adafruit_ImageReader::coreBMP( } } else { // Canvas is simpler, file.read(sdbuf, sizeof sdbuf); // just load sdbuf - } // (destidx never resets) - srcidx = 0; // Reset bmp buf index + } // (destidx never resets) + srcidx = 0; // Reset bmp buf index } if (depth == 24) { // Convert each pixel from BMP to 565 format, save in dest @@ -564,7 +564,7 @@ ImageReturnCode Adafruit_ImageReader::coreBMP( } } } - } // end pixel loop + } // end pixel loop if (tft) { // Drawing to TFT? if (destidx) { // Any remainders? // See notes above re: DMA @@ -584,11 +584,11 @@ ImageReturnCode Adafruit_ImageReader::coreBMP( img->palette = quantized; // Keep palette with img } } // end depth>24 or quantized malloc OK - } // end top/left clip - } // end malloc check - } // end depth check - } // end planes/compression check - } // end signature + } // end top/left clip + } // end malloc check + } // end depth check + } // end planes/compression check + } // end signature file.close(); return status; @@ -643,7 +643,7 @@ ImageReturnCode Adafruit_ImageReader::bmpDimensions(const char *filename, @return Unsigned 16-bit value, native endianism. */ uint16_t Adafruit_ImageReader::readLE16(void) { -#if !defined(ESP32) && !defined(ESP8266) && \ +#if !defined(ESP32) && !defined(ESP8266) && \ (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) // Read directly into result -- BMP data and variable both little-endian. uint16_t result; @@ -662,7 +662,7 @@ uint16_t Adafruit_ImageReader::readLE16(void) { @return Unsigned 32-bit value, native endianism. */ uint32_t Adafruit_ImageReader::readLE32(void) { -#if !defined(ESP32) && !defined(ESP8266) && \ +#if !defined(ESP32) && !defined(ESP8266) && \ (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) // Read directly into result -- BMP data and variable both little-endian. uint32_t result; diff --git a/Adafruit_ImageReader_EPD.cpp b/Adafruit_ImageReader_EPD.cpp index a0d51fa..cc21adc 100644 --- a/Adafruit_ImageReader_EPD.cpp +++ b/Adafruit_ImageReader_EPD.cpp @@ -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. @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; if (format == IMAGE_1) { - uint8_t* buffer = canvas.canvas1->getBuffer(); + uint8_t *buffer = canvas.canvas1->getBuffer(); uint8_t i, c; while (row < y + canvas.canvas1->height()) { 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_16) { - uint16_t* buffer = canvas.canvas16->getBuffer(); + uint16_t *buffer = canvas.canvas16->getBuffer(); thinkinkmode_t displayMode = epd.getMode(); 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 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) {} /*! @@ -182,8 +182,8 @@ Adafruit_ImageReader_EPD::Adafruit_ImageReader_EPD(FatVolume& fs) @return One of the ImageReturnCode values (IMAGE_SUCCESS on successful completion, other values on failure). */ -ImageReturnCode Adafruit_ImageReader_EPD::drawBMP(char* filename, - Adafruit_EPD& epd, int16_t x, +ImageReturnCode Adafruit_ImageReader_EPD::drawBMP(char *filename, + Adafruit_EPD &epd, int16_t x, int16_t y, boolean transact) { uint16_t epdbuf[BUFPIXELS]; // Temp space for buffering EPD data // 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). */ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP( - char* filename, // SD file to load - Adafruit_EPD* epd, // Pointer to TFT object, or NULL if to image - uint16_t* dest, // EPD working buffer, or NULL if to canvas + char *filename, // SD file to load + Adafruit_EPD *epd, // Pointer to TFT object, or NULL if to image + uint16_t *dest, // EPD working buffer, or NULL if to canvas int16_t x, // Position if loading to EPD (else ignored) 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 thinkinkmode_t displayMode = epd ? epd->getMode() : THINKINK_TRICOLOR; 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 uint32_t compression = 0; // BMP compression mode 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 uint8_t sdbuf[3 * BUFPIXELS]; // BMP read buf (R+G+B/pixel) int16_t epd_col = 0, epd_row = 0; @@ -248,7 +248,7 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP( uint16_t srcidx = sizeof sdbuf; #endif 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 uint32_t bmpPos = 0; // Next pixel position in file int loadWidth, loadHeight, // Region being loaded (clipped) @@ -366,7 +366,7 @@ ImageReturnCode Adafruit_ImageReader_EPD::coreBMP( } if ((depth >= 16) || - (quantized = (uint16_t*)malloc(colors * sizeof(uint16_t)))) { + (quantized = (uint16_t *)malloc(colors * sizeof(uint16_t)))) { if (depth < 16) { // Load and quantize color table thinkinkmode_t displayMode = diff --git a/Adafruit_ImageReader_EPD.h b/Adafruit_ImageReader_EPD.h index 3689572..14a5c00 100644 --- a/Adafruit_ImageReader_EPD.h +++ b/Adafruit_ImageReader_EPD.h @@ -23,10 +23,10 @@ ImageReader.loadBMP() and Image.draw(), not ImageReader.drawBMP(). */ class Adafruit_Image_EPD : public Adafruit_Image { - public: - void draw(Adafruit_EPD& epd, int16_t x, int16_t y); +public: + void draw(Adafruit_EPD &epd, int16_t x, int16_t y); - protected: +protected: friend class Adafruit_ImageReader_EPD; ///< Loading occurs here }; @@ -43,17 +43,17 @@ class Adafruit_Image_EPD : public Adafruit_Image { for use. */ class Adafruit_ImageReader_EPD : public Adafruit_ImageReader { - public: - Adafruit_ImageReader_EPD(FatVolume& fs); - ImageReturnCode drawBMP(char* filename, Adafruit_EPD& epd, int16_t x, +public: + Adafruit_ImageReader_EPD(FatVolume &fs); + ImageReturnCode drawBMP(char *filename, Adafruit_EPD &epd, int16_t x, int16_t y, boolean transact = true); static uint8_t mapColorForDisplay(uint8_t r, uint8_t g, uint8_t b, thinkinkmode_t mode); - private: - ImageReturnCode coreBMP(char* filename, Adafruit_EPD* epd, uint16_t* dest, - int16_t x, int16_t y, Adafruit_Image_EPD* img, +private: + ImageReturnCode coreBMP(char *filename, Adafruit_EPD *epd, uint16_t *dest, + int16_t x, int16_t y, Adafruit_Image_EPD *img, boolean transact); };