From 6791eaca015b1b637674bb2f5f7d24b1f7b26ee1 Mon Sep 17 00:00:00 2001 From: Michael Kamprath Date: Fri, 5 Jun 2020 11:00:20 -0700 Subject: [PATCH] Re-running clang-format after the rebase --- Adafruit_GFX.cpp | 207 ++++++++++++++++++++++++----------------------- Adafruit_GFX.h | 10 ++- 2 files changed, 113 insertions(+), 104 deletions(-) diff --git a/Adafruit_GFX.cpp b/Adafruit_GFX.cpp index f4639bf..1809a93 100644 --- a/Adafruit_GFX.cpp +++ b/Adafruit_GFX.cpp @@ -1738,8 +1738,10 @@ boolean Adafruit_GFX_Button::justReleased() { #ifdef __AVR__ // Bitmask tables of 0x80>>X and ~(0x80>>X), because X>>Y is slow on AVR -const uint8_t PROGMEM GFXcanvas1::GFXsetBit[] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 }; -const uint8_t PROGMEM GFXcanvas1::GFXclrBit[] = { 0x7F, 0xBF, 0xDF, 0xEF, 0xF7, 0xFB, 0xFD, 0xFE }; +const uint8_t PROGMEM GFXcanvas1::GFXsetBit[] = {0x80, 0x40, 0x20, 0x10, + 0x08, 0x04, 0x02, 0x01}; +const uint8_t PROGMEM GFXcanvas1::GFXclrBit[] = {0x7F, 0xBF, 0xDF, 0xEF, + 0xF7, 0xFB, 0xFD, 0xFE}; #endif /**************************************************************************/ @@ -1814,60 +1816,61 @@ void GFXcanvas1::drawPixel(int16_t x, int16_t y, uint16_t color) { /**********************************************************************/ /*! - @brief Get the pixel color value at a given coordinate - @param x x coordinate - @param y y coordinate - @returns The desired pixel's binary color value, either 0x1 (on) or 0x0 (off) + @brief Get the pixel color value at a given coordinate + @param x x coordinate + @param y y coordinate + @returns The desired pixel's binary color value, either 0x1 (on) or 0x0 + (off) */ /**********************************************************************/ bool GFXcanvas1::getPixel(int16_t x, int16_t y) const { - int16_t t; - switch(rotation) { - case 1: - t = x; - x = WIDTH - 1 - y; - y = t; - break; - case 2: - x = WIDTH - 1 - x; - y = HEIGHT - 1 - y; - break; - case 3: - t = x; - x = y; - y = HEIGHT - 1 - t; - break; - } - return getRawPixel(x, y); + int16_t t; + switch (rotation) { + case 1: + t = x; + x = WIDTH - 1 - y; + y = t; + break; + case 2: + x = WIDTH - 1 - x; + y = HEIGHT - 1 - y; + break; + case 3: + t = x; + x = y; + y = HEIGHT - 1 - t; + break; + } + return getRawPixel(x, y); } /**********************************************************************/ /*! - @brief Get the pixel color value at a given, unrotated coordinate. + @brief Get the pixel color value at a given, unrotated coordinate. This method is intended for hardware drivers to get pixel value in physical coordinates. - @param x x coordinate - @param y y coordinate - @returns The desired pixel's binary color value, either 0x1 (on) or 0x0 (off) + @param x x coordinate + @param y y coordinate + @returns The desired pixel's binary color value, either 0x1 (on) or 0x0 + (off) */ /**********************************************************************/ bool GFXcanvas1::getRawPixel(int16_t x, int16_t y) const { - if((x < 0) || (y < 0) || (x >= WIDTH) || (y >= HEIGHT)) return 0; - if(this->getBuffer()) { - uint8_t *buffer = this->getBuffer(); - uint8_t *ptr = &buffer[(x / 8) + y * ((WIDTH + 7) / 8)]; + if ((x < 0) || (y < 0) || (x >= WIDTH) || (y >= HEIGHT)) + return 0; + if (this->getBuffer()) { + uint8_t *buffer = this->getBuffer(); + uint8_t *ptr = &buffer[(x / 8) + y * ((WIDTH + 7) / 8)]; #ifdef __AVR__ - return ((*ptr) & pgm_read_byte(&GFXsetBit[x & 7])) != 0; + return ((*ptr) & pgm_read_byte(&GFXsetBit[x & 7])) != 0; #else - return ((*ptr) & (0x80 >> (x & 7))) != 0; + return ((*ptr) & (0x80 >> (x & 7))) != 0; #endif - } - return 0; + } + return 0; } - - /**************************************************************************/ /*! @brief Fill the framebuffer completely with one color @@ -1942,52 +1945,52 @@ void GFXcanvas8::drawPixel(int16_t x, int16_t y, uint16_t color) { /**********************************************************************/ /*! - @brief Get the pixel color value at a given coordinate - @param x x coordinate - @param y y coordinate - @returns The desired pixel's 8-bit color value + @brief Get the pixel color value at a given coordinate + @param x x coordinate + @param y y coordinate + @returns The desired pixel's 8-bit color value */ /**********************************************************************/ uint8_t GFXcanvas8::getPixel(int16_t x, int16_t y) const { - int16_t t; - switch(rotation) { - case 1: - t = x; - x = WIDTH - 1 - y; - y = t; - break; - case 2: - x = WIDTH - 1 - x; - y = HEIGHT - 1 - y; - break; - case 3: - t = x; - x = y; - y = HEIGHT - 1 - t; - break; - } - return getRawPixel(x, y); + int16_t t; + switch (rotation) { + case 1: + t = x; + x = WIDTH - 1 - y; + y = t; + break; + case 2: + x = WIDTH - 1 - x; + y = HEIGHT - 1 - y; + break; + case 3: + t = x; + x = y; + y = HEIGHT - 1 - t; + break; + } + return getRawPixel(x, y); } /**********************************************************************/ /*! - @brief Get the pixel color value at a given, unrotated coordinate. + @brief Get the pixel color value at a given, unrotated coordinate. This method is intended for hardware drivers to get pixel value in physical coordinates. - @param x x coordinate - @param y y coordinate - @returns The desired pixel's 8-bit color value + @param x x coordinate + @param y y coordinate + @returns The desired pixel's 8-bit color value */ /**********************************************************************/ uint8_t GFXcanvas8::getRawPixel(int16_t x, int16_t y) const { - if((x < 0) || (y < 0) || (x >= WIDTH) || (y >= HEIGHT)) return 0; - if(buffer) { - return buffer[x + y * WIDTH]; - } - return 0; + if ((x < 0) || (y < 0) || (x >= WIDTH) || (y >= HEIGHT)) + return 0; + if (buffer) { + return buffer[x + y * WIDTH]; + } + return 0; } - /**************************************************************************/ /*! @brief Fill the framebuffer completely with one color @@ -2099,52 +2102,52 @@ void GFXcanvas16::drawPixel(int16_t x, int16_t y, uint16_t color) { /**********************************************************************/ /*! - @brief Get the pixel color value at a given coordinate - @param x x coordinate - @param y y coordinate - @returns The desired pixel's 16-bit 5-6-5 color value + @brief Get the pixel color value at a given coordinate + @param x x coordinate + @param y y coordinate + @returns The desired pixel's 16-bit 5-6-5 color value */ /**********************************************************************/ uint16_t GFXcanvas16::getPixel(int16_t x, int16_t y) const { - int16_t t; - switch(rotation) { - case 1: - t = x; - x = WIDTH - 1 - y; - y = t; - break; - case 2: - x = WIDTH - 1 - x; - y = HEIGHT - 1 - y; - break; - case 3: - t = x; - x = y; - y = HEIGHT - 1 - t; - break; - } - return getRawPixel(x, y); + int16_t t; + switch (rotation) { + case 1: + t = x; + x = WIDTH - 1 - y; + y = t; + break; + case 2: + x = WIDTH - 1 - x; + y = HEIGHT - 1 - y; + break; + case 3: + t = x; + x = y; + y = HEIGHT - 1 - t; + break; + } + return getRawPixel(x, y); } /**********************************************************************/ /*! - @brief Get the pixel color value at a given, unrotated coordinate. + @brief Get the pixel color value at a given, unrotated coordinate. This method is intended for hardware drivers to get pixel value in physical coordinates. - @param x x coordinate - @param y y coordinate - @returns The desired pixel's 16-bit 5-6-5 color value + @param x x coordinate + @param y y coordinate + @returns The desired pixel's 16-bit 5-6-5 color value */ /**********************************************************************/ uint16_t GFXcanvas16::getRawPixel(int16_t x, int16_t y) const { - if((x < 0) || (y < 0) || (x >= WIDTH) || (y >= HEIGHT)) return 0; - if(buffer) { - return buffer[x + y * WIDTH]; - } - return 0; + if ((x < 0) || (y < 0) || (x >= WIDTH) || (y >= HEIGHT)) + return 0; + if (buffer) { + return buffer[x + y * WIDTH]; + } + return 0; } - /**************************************************************************/ /*! @brief Fill the framebuffer completely with one color diff --git a/Adafruit_GFX.h b/Adafruit_GFX.h index 3a33831..9526b12 100644 --- a/Adafruit_GFX.h +++ b/Adafruit_GFX.h @@ -318,8 +318,10 @@ public: */ /**********************************************************************/ uint8_t *getBuffer(void) const { return buffer; } + protected: bool getRawPixel(int16_t x, int16_t y) const; + private: uint8_t *buffer; @@ -345,8 +347,10 @@ public: */ /**********************************************************************/ uint8_t *getBuffer(void) const { return buffer; } + protected: uint8_t getRawPixel(int16_t x, int16_t y) const; + private: uint8_t *buffer; }; @@ -359,7 +363,7 @@ public: void drawPixel(int16_t x, int16_t y, uint16_t color); void fillScreen(uint16_t color); void byteSwap(void); - uint16_t getPixel(int16_t x, int16_t y) const; + uint16_t getPixel(int16_t x, int16_t y) const; /**********************************************************************/ /*! @brief Get a pointer to the internal buffer memory @@ -367,8 +371,10 @@ public: */ /**********************************************************************/ uint16_t *getBuffer(void) const { return buffer; } + protected: - uint16_t getRawPixel(int16_t x, int16_t y) const; + uint16_t getRawPixel(int16_t x, int16_t y) const; + private: uint16_t *buffer; };