Uses the same fonts as the SPI_TFT_ILI9341 Library (I have many, and a html/php font editor for that)
Diff: SPI_TFT_ILI9225.cpp
- Revision:
- 8:a569bc50b552
- Parent:
- 7:2616ae4dd315
- Child:
- 9:680f6c9940b3
--- a/SPI_TFT_ILI9225.cpp Wed Nov 23 11:05:33 2016 +0000 +++ b/SPI_TFT_ILI9225.cpp Wed Nov 23 11:31:45 2016 +0000 @@ -250,8 +250,8 @@ } } -void TFT_22_ILI9225::setOrientation(uint8_t orientation) { - +void TFT_22_ILI9225::setOrientation(uint8_t orientation) +{ _orientation = orientation % 4; // Entry Mode (R03h) // 0x1000 AM = 0: Horizontal, I/D[1:0] = 00: Horizontal: decrement, Vertical: decrement - ILI9225_PORTRAIT_R @@ -519,6 +519,61 @@ } } +void TFT_22_ILI9225::roundrect(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t rad, bool fill, uint16_t color) +{ + signed int a, b, P; + + a = 0; // increment by 1 + b = rad; // decrement by 1 using P + P = 1 - rad; + + if (fill) + { + fillrect(x1, y1 + rad, x2, y2 - rad, color); + + do + { + fillrect(x1 - a + rad, y1 - b + rad, a + x2 - rad, y1 - b + rad, color); // 8 --> 1 + fillrect(x1 - b + rad, y1 - a + rad, b + x2 - rad, y1 - a + rad, color); // 7 --> 2 + fillrect(x1 - b + rad, a + y2 - rad, b + x2 - rad, a + y2 - rad, color); // 6 --> 3 + fillrect(x1 - a + rad, b + y2 - rad, a + x2 - rad, b + y2 - rad, color); // 5 --> 4 + + if (P < 0) + P += 3 + 2 * a++; + else + P += 5 + 2 * (a++ - b--); + + } while (a <= b); + } + else + { + hline(x1 + rad, x2 - rad, y1, color); // top + hline(x1 + rad, x2 - rad, y2, color); // bottom + vline(x1, y1 + rad, y2 - rad, color); // left + vline(x2, y1 + rad, y2 - rad, color); // right + + do + { + pixel(a + x2 - rad, y1 - b + rad, color); // `````` Segment 1 + pixel(b + x2 - rad, y1 - a + rad, color); // `````` Segment 2 + + pixel(b + x2 - rad, a + y2 - rad, color); // `````` Segment 3 + pixel(a + x2 - rad, b + y2 - rad, color); // `````` Segment 4 + + pixel(x1 - a + rad, b + y2 - rad, color); // `````` Segment 5 + pixel(x1 - b + rad, a + y2 - rad, color); // `````` Segment 6 + + pixel(x1 - b + rad, y1 - a + rad, color); // `````` Segment 7 + pixel(x1 - a + rad, y1 - b + rad, color); // `````` Segment 8 + + if (P < 0) + P += 3 + 2 * a++; + else + P += 5 + 2 * (a++ - b--); + } while (a <= b); + } +} + uint16_t TFT_22_ILI9225::maxX(void) { return _maxX - 1; } @@ -699,71 +754,6 @@ //---------------------------------------------------------------------------------------------------- //************************************* ECA 2.8 inch LCD Module ************************************** //---------------------------------------------------------------------------------------------------- -// Description : Draws a beveled figure on the screen. -// Input : x0, y0 - coordinate position of the upper left center -// : x1, y1 - coordinate position of the lower right center -// : rad - defines the redius of the circle, -// : fill - fill yes or no -//---------------------------------------------------------------------------------------------------- -void TFT_22_ILI9225::roundRectangle(int x0, int y0, int x1, int y1, int rad, bool fill, int color) -{ - signed int a, b, P; - - a = 0; // increment by 1 - b = rad; // decrement by 1 using P - P = 1 - rad; - - - if (fill) - { - fillrect(x0, y0 + rad, x1, y1 - rad, color); - - do - { - fillrect(x0 - a + rad, y0 - b + rad, a + x1 - rad, y0 - b + rad, color); // 8 --> 1 - fillrect(x0 - b + rad, y0 - a + rad, b + x1 - rad, y0 - a + rad, color); // 7 --> 2 - fillrect(x0 - b + rad, a + y1 - rad, b + x1 - rad, a + y1 - rad, color); // 6 --> 3 - fillrect(x0 - a + rad, b + y1 - rad, a + x1 - rad, b + y1 - rad, color); // 5 --> 4 - - if (P < 0) - P += 3 + 2 * a++; - else - P += 5 + 2 * (a++ - b--); - - } while (a <= b); - } //fill - else - { - fillrect(x0 + rad, y0, x1 - rad, y0, color); // top - fillrect(x0 + rad, y1, x1 - rad, y1, color); // bottom - fillrect(x0, y0 + rad, x0, y1 - rad, color); // left - fillrect(x1, y0 + rad, x1, y1 - rad, color); // right - - do - { - pixel(a + x1 - rad, y0 - b + rad, color); // `````` Segment 1 - pixel(b + x1 - rad, y0 - a + rad, color); // `````` Segment 2 - - pixel(b + x1 - rad, a + y1 - rad, color); // `````` Segment 3 - pixel(a + x1 - rad, b + y1 - rad, color); // `````` Segment 4 - - pixel(x0 - a + rad, b + y1 - rad, color); // `````` Segment 5 - pixel(x0 - b + rad, a + y1 - rad, color); // `````` Segment 6 - - pixel(x0 - b + rad, y0 - a + rad, color); // `````` Segment 7 - pixel(x0 - a + rad, y0 - b + rad, color); // `````` Segment 8 - - if (P < 0) - P += 3 + 2 * a++; - else - P += 5 + 2 * (a++ - b--); - } while (a <= b); - } //no fill -} //RoundRectangle - -//---------------------------------------------------------------------------------------------------- -//************************************* ECA 2.8 inch LCD Module ************************************** -//---------------------------------------------------------------------------------------------------- // Make an ascii string from an unicode string //----------------------------------------------------------------------------------------------------