@@ -1738,8 +1738,10 @@ boolean Adafruit_GFX_Button::justReleased() {
17381738
17391739#ifdef __AVR__
17401740// Bitmask tables of 0x80>>X and ~(0x80>>X), because X>>Y is slow on AVR
1741- const uint8_t PROGMEM GFXcanvas1::GFXsetBit[] = { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 };
1742- const uint8_t PROGMEM GFXcanvas1::GFXclrBit[] = { 0x7F , 0xBF , 0xDF , 0xEF , 0xF7 , 0xFB , 0xFD , 0xFE };
1741+ const uint8_t PROGMEM GFXcanvas1::GFXsetBit[] = {0x80 , 0x40 , 0x20 , 0x10 ,
1742+ 0x08 , 0x04 , 0x02 , 0x01 };
1743+ const uint8_t PROGMEM GFXcanvas1::GFXclrBit[] = {0x7F , 0xBF , 0xDF , 0xEF ,
1744+ 0xF7 , 0xFB , 0xFD , 0xFE };
17431745#endif
17441746
17451747/* *************************************************************************/
@@ -1814,60 +1816,61 @@ void GFXcanvas1::drawPixel(int16_t x, int16_t y, uint16_t color) {
18141816
18151817/* *********************************************************************/
18161818/* !
1817- @brief Get the pixel color value at a given coordinate
1818- @param x x coordinate
1819- @param y y coordinate
1820- @returns The desired pixel's binary color value, either 0x1 (on) or 0x0 (off)
1819+ @brief Get the pixel color value at a given coordinate
1820+ @param x x coordinate
1821+ @param y y coordinate
1822+ @returns The desired pixel's binary color value, either 0x1 (on) or 0x0
1823+ (off)
18211824*/
18221825/* *********************************************************************/
18231826bool GFXcanvas1::getPixel (int16_t x, int16_t y) const {
1824- int16_t t;
1825- switch (rotation) {
1826- case 1 :
1827- t = x;
1828- x = WIDTH - 1 - y;
1829- y = t;
1830- break ;
1831- case 2 :
1832- x = WIDTH - 1 - x;
1833- y = HEIGHT - 1 - y;
1834- break ;
1835- case 3 :
1836- t = x;
1837- x = y;
1838- y = HEIGHT - 1 - t;
1839- break ;
1840- }
1841- return getRawPixel (x, y);
1827+ int16_t t;
1828+ switch (rotation) {
1829+ case 1 :
1830+ t = x;
1831+ x = WIDTH - 1 - y;
1832+ y = t;
1833+ break ;
1834+ case 2 :
1835+ x = WIDTH - 1 - x;
1836+ y = HEIGHT - 1 - y;
1837+ break ;
1838+ case 3 :
1839+ t = x;
1840+ x = y;
1841+ y = HEIGHT - 1 - t;
1842+ break ;
1843+ }
1844+ return getRawPixel (x, y);
18421845}
18431846
18441847/* *********************************************************************/
18451848/* !
1846- @brief Get the pixel color value at a given, unrotated coordinate.
1849+ @brief Get the pixel color value at a given, unrotated coordinate.
18471850 This method is intended for hardware drivers to get pixel value
18481851 in physical coordinates.
1849- @param x x coordinate
1850- @param y y coordinate
1851- @returns The desired pixel's binary color value, either 0x1 (on) or 0x0 (off)
1852+ @param x x coordinate
1853+ @param y y coordinate
1854+ @returns The desired pixel's binary color value, either 0x1 (on) or 0x0
1855+ (off)
18521856*/
18531857/* *********************************************************************/
18541858bool GFXcanvas1::getRawPixel (int16_t x, int16_t y) const {
1855- if ((x < 0 ) || (y < 0 ) || (x >= WIDTH) || (y >= HEIGHT)) return 0 ;
1856- if (this ->getBuffer ()) {
1857- uint8_t *buffer = this ->getBuffer ();
1858- uint8_t *ptr = &buffer[(x / 8 ) + y * ((WIDTH + 7 ) / 8 )];
1859+ if ((x < 0 ) || (y < 0 ) || (x >= WIDTH) || (y >= HEIGHT))
1860+ return 0 ;
1861+ if (this ->getBuffer ()) {
1862+ uint8_t *buffer = this ->getBuffer ();
1863+ uint8_t *ptr = &buffer[(x / 8 ) + y * ((WIDTH + 7 ) / 8 )];
18591864
18601865#ifdef __AVR__
1861- return ((*ptr) & pgm_read_byte (&GFXsetBit[x & 7 ])) != 0 ;
1866+ return ((*ptr) & pgm_read_byte (&GFXsetBit[x & 7 ])) != 0 ;
18621867#else
1863- return ((*ptr) & (0x80 >> (x & 7 ))) != 0 ;
1868+ return ((*ptr) & (0x80 >> (x & 7 ))) != 0 ;
18641869#endif
1865- }
1866- return 0 ;
1870+ }
1871+ return 0 ;
18671872}
18681873
1869-
1870-
18711874/* *************************************************************************/
18721875/* !
18731876 @brief Fill the framebuffer completely with one color
@@ -1942,52 +1945,52 @@ void GFXcanvas8::drawPixel(int16_t x, int16_t y, uint16_t color) {
19421945
19431946/* *********************************************************************/
19441947/* !
1945- @brief Get the pixel color value at a given coordinate
1946- @param x x coordinate
1947- @param y y coordinate
1948- @returns The desired pixel's 8-bit color value
1948+ @brief Get the pixel color value at a given coordinate
1949+ @param x x coordinate
1950+ @param y y coordinate
1951+ @returns The desired pixel's 8-bit color value
19491952*/
19501953/* *********************************************************************/
19511954uint8_t GFXcanvas8::getPixel (int16_t x, int16_t y) const {
1952- int16_t t;
1953- switch (rotation) {
1954- case 1 :
1955- t = x;
1956- x = WIDTH - 1 - y;
1957- y = t;
1958- break ;
1959- case 2 :
1960- x = WIDTH - 1 - x;
1961- y = HEIGHT - 1 - y;
1962- break ;
1963- case 3 :
1964- t = x;
1965- x = y;
1966- y = HEIGHT - 1 - t;
1967- break ;
1968- }
1969- return getRawPixel (x, y);
1955+ int16_t t;
1956+ switch (rotation) {
1957+ case 1 :
1958+ t = x;
1959+ x = WIDTH - 1 - y;
1960+ y = t;
1961+ break ;
1962+ case 2 :
1963+ x = WIDTH - 1 - x;
1964+ y = HEIGHT - 1 - y;
1965+ break ;
1966+ case 3 :
1967+ t = x;
1968+ x = y;
1969+ y = HEIGHT - 1 - t;
1970+ break ;
1971+ }
1972+ return getRawPixel (x, y);
19701973}
19711974
19721975/* *********************************************************************/
19731976/* !
1974- @brief Get the pixel color value at a given, unrotated coordinate.
1977+ @brief Get the pixel color value at a given, unrotated coordinate.
19751978 This method is intended for hardware drivers to get pixel value
19761979 in physical coordinates.
1977- @param x x coordinate
1978- @param y y coordinate
1979- @returns The desired pixel's 8-bit color value
1980+ @param x x coordinate
1981+ @param y y coordinate
1982+ @returns The desired pixel's 8-bit color value
19801983*/
19811984/* *********************************************************************/
19821985uint8_t GFXcanvas8::getRawPixel (int16_t x, int16_t y) const {
1983- if ((x < 0 ) || (y < 0 ) || (x >= WIDTH) || (y >= HEIGHT)) return 0 ;
1984- if (buffer) {
1985- return buffer[x + y * WIDTH];
1986- }
1987- return 0 ;
1986+ if ((x < 0 ) || (y < 0 ) || (x >= WIDTH) || (y >= HEIGHT))
1987+ return 0 ;
1988+ if (buffer) {
1989+ return buffer[x + y * WIDTH];
1990+ }
1991+ return 0 ;
19881992}
19891993
1990-
19911994/* *************************************************************************/
19921995/* !
19931996 @brief Fill the framebuffer completely with one color
@@ -2099,52 +2102,52 @@ void GFXcanvas16::drawPixel(int16_t x, int16_t y, uint16_t color) {
20992102
21002103/* *********************************************************************/
21012104/* !
2102- @brief Get the pixel color value at a given coordinate
2103- @param x x coordinate
2104- @param y y coordinate
2105- @returns The desired pixel's 16-bit 5-6-5 color value
2105+ @brief Get the pixel color value at a given coordinate
2106+ @param x x coordinate
2107+ @param y y coordinate
2108+ @returns The desired pixel's 16-bit 5-6-5 color value
21062109*/
21072110/* *********************************************************************/
21082111uint16_t GFXcanvas16::getPixel (int16_t x, int16_t y) const {
2109- int16_t t;
2110- switch (rotation) {
2111- case 1 :
2112- t = x;
2113- x = WIDTH - 1 - y;
2114- y = t;
2115- break ;
2116- case 2 :
2117- x = WIDTH - 1 - x;
2118- y = HEIGHT - 1 - y;
2119- break ;
2120- case 3 :
2121- t = x;
2122- x = y;
2123- y = HEIGHT - 1 - t;
2124- break ;
2125- }
2126- return getRawPixel (x, y);
2112+ int16_t t;
2113+ switch (rotation) {
2114+ case 1 :
2115+ t = x;
2116+ x = WIDTH - 1 - y;
2117+ y = t;
2118+ break ;
2119+ case 2 :
2120+ x = WIDTH - 1 - x;
2121+ y = HEIGHT - 1 - y;
2122+ break ;
2123+ case 3 :
2124+ t = x;
2125+ x = y;
2126+ y = HEIGHT - 1 - t;
2127+ break ;
2128+ }
2129+ return getRawPixel (x, y);
21272130}
21282131
21292132/* *********************************************************************/
21302133/* !
2131- @brief Get the pixel color value at a given, unrotated coordinate.
2134+ @brief Get the pixel color value at a given, unrotated coordinate.
21322135 This method is intended for hardware drivers to get pixel value
21332136 in physical coordinates.
2134- @param x x coordinate
2135- @param y y coordinate
2136- @returns The desired pixel's 16-bit 5-6-5 color value
2137+ @param x x coordinate
2138+ @param y y coordinate
2139+ @returns The desired pixel's 16-bit 5-6-5 color value
21372140*/
21382141/* *********************************************************************/
21392142uint16_t GFXcanvas16::getRawPixel (int16_t x, int16_t y) const {
2140- if ((x < 0 ) || (y < 0 ) || (x >= WIDTH) || (y >= HEIGHT)) return 0 ;
2141- if (buffer) {
2142- return buffer[x + y * WIDTH];
2143- }
2144- return 0 ;
2143+ if ((x < 0 ) || (y < 0 ) || (x >= WIDTH) || (y >= HEIGHT))
2144+ return 0 ;
2145+ if (buffer) {
2146+ return buffer[x + y * WIDTH];
2147+ }
2148+ return 0 ;
21452149}
21462150
2147-
21482151/* *************************************************************************/
21492152/* !
21502153 @brief Fill the framebuffer completely with one color
0 commit comments