@@ -1179,38 +1179,6 @@ size_t Adafruit_GFX::write(uint8_t c) {
11791179 return 1 ;
11801180}
11811181
1182- /* *************************************************************************/
1183- /* !
1184- @brief Set text cursor location
1185- @param x X coordinate in pixels
1186- @param y Y coordinate in pixels
1187- */
1188- /* *************************************************************************/
1189- void Adafruit_GFX::setCursor (int16_t x, int16_t y) {
1190- cursor_x = x;
1191- cursor_y = y;
1192- }
1193-
1194- /* *************************************************************************/
1195- /* !
1196- @brief Get text cursor X location
1197- @returns X coordinate in pixels
1198- */
1199- /* *************************************************************************/
1200- int16_t Adafruit_GFX::getCursorX (void ) const {
1201- return cursor_x;
1202- }
1203-
1204- /* *************************************************************************/
1205- /* !
1206- @brief Get text cursor Y location
1207- @returns Y coordinate in pixels
1208- */
1209- /* *************************************************************************/
1210- int16_t Adafruit_GFX::getCursorY (void ) const {
1211- return cursor_y;
1212- }
1213-
12141182/* *************************************************************************/
12151183/* !
12161184 @brief Set text 'magnification' size. Each increase in s makes 1 pixel that much bigger.
@@ -1221,50 +1189,6 @@ void Adafruit_GFX::setTextSize(uint8_t s) {
12211189 textsize = (s > 0 ) ? s : 1 ;
12221190}
12231191
1224- /* *************************************************************************/
1225- /* !
1226- @brief Set text font color with transparant background
1227- @param c 16-bit 5-6-5 Color to draw text with
1228- */
1229- /* *************************************************************************/
1230- void Adafruit_GFX::setTextColor (uint16_t c) {
1231- // For 'transparent' background, we'll set the bg
1232- // to the same as fg instead of using a flag
1233- textcolor = textbgcolor = c;
1234- }
1235-
1236- /* *************************************************************************/
1237- /* !
1238- @brief Set text font color with custom background color
1239- @param c 16-bit 5-6-5 Color to draw text with
1240- @param b 16-bit 5-6-5 Color to draw background/fill with
1241- */
1242- /* *************************************************************************/
1243- void Adafruit_GFX::setTextColor (uint16_t c, uint16_t b) {
1244- textcolor = c;
1245- textbgcolor = b;
1246- }
1247-
1248- /* *************************************************************************/
1249- /* !
1250- @brief Whether text that is too long should 'wrap' around to the next line.
1251- @param w Set true for wrapping, false for clipping
1252- */
1253- /* *************************************************************************/
1254- void Adafruit_GFX::setTextWrap (boolean w) {
1255- wrap = w;
1256- }
1257-
1258- /* *************************************************************************/
1259- /* !
1260- @brief Get rotation setting for display
1261- @returns 0 thru 3 corresponding to 4 cardinal rotations
1262- */
1263- /* *************************************************************************/
1264- uint8_t Adafruit_GFX::getRotation (void ) const {
1265- return rotation;
1266- }
1267-
12681192/* *************************************************************************/
12691193/* !
12701194 @brief Set rotation setting for display
@@ -1287,22 +1211,6 @@ void Adafruit_GFX::setRotation(uint8_t x) {
12871211 }
12881212}
12891213
1290- /* *************************************************************************/
1291- /* !
1292- @brief Enable (or disable) Code Page 437-compatible charset.
1293- There was an error in glcdfont.c for the longest time -- one character
1294- (#176, the 'light shade' block) was missing -- this threw off the index
1295- of every character that followed it. But a TON of code has been written
1296- with the erroneous character indices. By default, the library uses the
1297- original 'wrong' behavior and old sketches will still work. Pass 'true'
1298- to this function to use correct CP437 character values in your code.
1299- @param x Whether to enable (True) or not (False)
1300- */
1301- /* *************************************************************************/
1302- void Adafruit_GFX::cp437 (boolean x) {
1303- _cp437 = x;
1304- }
1305-
13061214/* *************************************************************************/
13071215/* !
13081216 @brief Set the font to display when print()ing, either custom or default
@@ -1486,26 +1394,6 @@ void Adafruit_GFX::getTextBounds(const __FlashStringHelper *str,
14861394 }
14871395}
14881396
1489- /* *************************************************************************/
1490- /* !
1491- @brief Get width of the display, accounting for the current rotation
1492- @returns Width in pixels
1493- */
1494- /* *************************************************************************/
1495- int16_t Adafruit_GFX::width (void ) const {
1496- return _width;
1497- }
1498-
1499- /* *************************************************************************/
1500- /* !
1501- @brief Get height of the display, accounting for the current rotation
1502- @returns Height in pixels
1503- */
1504- /* *************************************************************************/
1505- int16_t Adafruit_GFX::height (void ) const {
1506- return _height;
1507- }
1508-
15091397/* *************************************************************************/
15101398/* !
15111399 @brief Invert the display (ideally using built-in hardware command)
@@ -1617,36 +1505,17 @@ void Adafruit_GFX_Button::drawButton(boolean inverted) {
16171505
16181506/* *************************************************************************/
16191507/* !
1620- @brief Helper to let us know if a coordinate is within the bounds of the button
1508+ @brief Helper to let us know if a coordinate is within the bounds of the button
16211509 @param x The X coordinate to check
16221510 @param y The Y coordinate to check
1623- @returns True if within button graphics outline
1511+ @returns True if within button graphics outline
16241512*/
16251513/* *************************************************************************/
16261514boolean Adafruit_GFX_Button::contains (int16_t x, int16_t y) {
16271515 return ((x >= _x1) && (x < (int16_t ) (_x1 + _w)) &&
16281516 (y >= _y1) && (y < (int16_t ) (_y1 + _h)));
16291517}
16301518
1631- /* *************************************************************************/
1632- /* !
1633- @brief Sets the state of the button, should be done by some touch function
1634- @param p True for pressed, false for not.
1635- */
1636- /* *************************************************************************/
1637- void Adafruit_GFX_Button::press (boolean p) {
1638- laststate = currstate;
1639- currstate = p;
1640- }
1641-
1642- /* *************************************************************************/
1643- /* !
1644- @brief Query whether the button is currently pressed
1645- @returns True if pressed
1646- */
1647- /* *************************************************************************/
1648- boolean Adafruit_GFX_Button::isPressed () { return currstate; }
1649-
16501519/* *************************************************************************/
16511520/* !
16521521 @brief Query whether the button was pressed since we last checked state
@@ -1707,20 +1576,10 @@ GFXcanvas1::~GFXcanvas1(void) {
17071576
17081577/* *************************************************************************/
17091578/* !
1710- @brief Get a pointer to the internal buffer memory
1711- @returns A pointer to the allocated buffer
1712- */
1713- /* *************************************************************************/
1714- uint8_t * GFXcanvas1::getBuffer (void ) {
1715- return buffer;
1716- }
1717-
1718- /* *************************************************************************/
1719- /* !
1720- @brief Draw a pixel to the canvas framebuffer
1721- @param x x coordinate
1722- @param y y coordinate
1723- @param color 16-bit 5-6-5 Color to fill with
1579+ @brief Draw a pixel to the canvas framebuffer
1580+ @param x x coordinate
1581+ @param y y coordinate
1582+ @param color 16-bit 5-6-5 Color to fill with
17241583*/
17251584/* *************************************************************************/
17261585void GFXcanvas1::drawPixel (int16_t x, int16_t y, uint16_t color) {
@@ -1765,8 +1624,8 @@ void GFXcanvas1::drawPixel(int16_t x, int16_t y, uint16_t color) {
17651624
17661625/* *************************************************************************/
17671626/* !
1768- @brief Fill the framebuffer completely with one color
1769- @param color 16-bit 5-6-5 Color to fill with
1627+ @brief Fill the framebuffer completely with one color
1628+ @param color 16-bit 5-6-5 Color to fill with
17701629*/
17711630/* *************************************************************************/
17721631void GFXcanvas1::fillScreen (uint16_t color) {
@@ -1799,23 +1658,12 @@ GFXcanvas8::~GFXcanvas8(void) {
17991658 if (buffer) free (buffer);
18001659}
18011660
1802-
1803- /* *************************************************************************/
1804- /* !
1805- @brief Get a pointer to the internal buffer memory
1806- @returns A pointer to the allocated buffer
1807- */
1808- /* *************************************************************************/
1809- uint8_t * GFXcanvas8::getBuffer (void ) {
1810- return buffer;
1811- }
1812-
18131661/* *************************************************************************/
18141662/* !
1815- @brief Draw a pixel to the canvas framebuffer
1816- @param x x coordinate
1817- @param y y coordinate
1818- @param color 16-bit 5-6-5 Color to fill with
1663+ @brief Draw a pixel to the canvas framebuffer
1664+ @param x x coordinate
1665+ @param y y coordinate
1666+ @param color 16-bit 5-6-5 Color to fill with
18191667*/
18201668/* *************************************************************************/
18211669void GFXcanvas8::drawPixel (int16_t x, int16_t y, uint16_t color) {
@@ -1846,8 +1694,8 @@ void GFXcanvas8::drawPixel(int16_t x, int16_t y, uint16_t color) {
18461694
18471695/* *************************************************************************/
18481696/* !
1849- @brief Fill the framebuffer completely with one color
1850- @param color 16-bit 5-6-5 Color to fill with
1697+ @brief Fill the framebuffer completely with one color
1698+ @param color 16-bit 5-6-5 Color to fill with
18511699*/
18521700/* *************************************************************************/
18531701void GFXcanvas8::fillScreen (uint16_t color) {
@@ -1916,20 +1764,10 @@ GFXcanvas16::~GFXcanvas16(void) {
19161764
19171765/* *************************************************************************/
19181766/* !
1919- @brief Get a pointer to the internal buffer memory
1920- @returns A pointer to the allocated buffer
1921- */
1922- /* *************************************************************************/
1923- uint16_t * GFXcanvas16::getBuffer (void ) {
1924- return buffer;
1925- }
1926-
1927- /* *************************************************************************/
1928- /* !
1929- @brief Draw a pixel to the canvas framebuffer
1930- @param x x coordinate
1931- @param y y coordinate
1932- @param color 16-bit 5-6-5 Color to fill with
1767+ @brief Draw a pixel to the canvas framebuffer
1768+ @param x x coordinate
1769+ @param y y coordinate
1770+ @param color 16-bit 5-6-5 Color to fill with
19331771*/
19341772/* *************************************************************************/
19351773void GFXcanvas16::drawPixel (int16_t x, int16_t y, uint16_t color) {
@@ -1960,8 +1798,8 @@ void GFXcanvas16::drawPixel(int16_t x, int16_t y, uint16_t color) {
19601798
19611799/* *************************************************************************/
19621800/* !
1963- @brief Fill the framebuffer completely with one color
1964- @param color 16-bit 5-6-5 Color to fill with
1801+ @brief Fill the framebuffer completely with one color
1802+ @param color 16-bit 5-6-5 Color to fill with
19651803*/
19661804/* *************************************************************************/
19671805void GFXcanvas16::fillScreen (uint16_t color) {
@@ -1976,3 +1814,22 @@ void GFXcanvas16::fillScreen(uint16_t color) {
19761814 }
19771815}
19781816
1817+ /* *************************************************************************/
1818+ /* !
1819+ @brief Reverses the "endian-ness" of each 16-bit pixel within the
1820+ canvas; little-endian to big-endian, or big-endian to little.
1821+ Most microcontrollers (such as SAMD) are little-endian, while
1822+ most displays tend toward big-endianness. All the drawing
1823+ functions (including RGB bitmap drawing) take care of this
1824+ automatically, but some specialized code (usually involving
1825+ DMA) can benefit from having pixel data already in the
1826+ display-native order. Note that this does NOT convert to a
1827+ SPECIFIC endian-ness, it just flips the bytes within each word.
1828+ */
1829+ /* *************************************************************************/
1830+ void GFXcanvas16::byteSwap (void ) {
1831+ if (buffer) {
1832+ uint32_t i, pixels = WIDTH * HEIGHT;
1833+ for (i=0 ; i<pixels; i++) buffer[i] = __builtin_bswap16 (buffer[i]);
1834+ }
1835+ }
0 commit comments