@@ -84,7 +84,7 @@ WIDTH(w), HEIGHT(h)
8484 _height = HEIGHT;
8585 rotation = 0 ;
8686 cursor_y = cursor_x = 0 ;
87- textsize_x = textsize_y = 1 ;
87+ textsize = 1 ;
8888 textcolor = textbgcolor = 0xFFFF ;
8989 wrap = true ;
9090 _cp437 = false ;
@@ -772,7 +772,7 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
772772
773773/* *************************************************************************/
774774/* !
775- @brief Draw PROGMEM-resident XBitMap Files (*.xbm), exported from GIMP.
775+ @brief Draw PROGMEM-resident XBitMap Files (*.xbm), exported from GIMP.
776776 Usage: Export from GIMP to *.xbm, rename *.xbm to *.c and open in editor.
777777 C Array can be directly used with this function.
778778 There is no RAM-resident version of this function; if generating bitmaps
@@ -807,7 +807,7 @@ void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y,
807807
808808/* *************************************************************************/
809809/* !
810- @brief Draw a PROGMEM-resident 8-bit image (grayscale) at the specified (x,y) pos.
810+ @brief Draw a PROGMEM-resident 8-bit image (grayscale) at the specified (x,y) pos.
811811 Specifically for 8-bit display devices such as IS31FL3731; no color reduction/expansion is performed.
812812 @param x Top left corner x coordinate
813813 @param y Top left corner y coordinate
@@ -829,7 +829,7 @@ void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y,
829829
830830/* *************************************************************************/
831831/* !
832- @brief Draw a RAM-resident 8-bit image (grayscale) at the specified (x,y) pos.
832+ @brief Draw a RAM-resident 8-bit image (grayscale) at the specified (x,y) pos.
833833 Specifically for 8-bit display devices such as IS31FL3731; no color reduction/expansion is performed.
834834 @param x Top left corner x coordinate
835835 @param y Top left corner y coordinate
@@ -916,7 +916,7 @@ void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y,
916916
917917/* *************************************************************************/
918918/* !
919- @brief Draw a PROGMEM-resident 16-bit image (RGB 5/6/5) at the specified (x,y) position.
919+ @brief Draw a PROGMEM-resident 16-bit image (RGB 5/6/5) at the specified (x,y) position.
920920 For 16-bit display devices; no color reduction performed.
921921 @param x Top left corner x coordinate
922922 @param y Top left corner y coordinate
@@ -938,7 +938,7 @@ void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y,
938938
939939/* *************************************************************************/
940940/* !
941- @brief Draw a RAM-resident 16-bit image (RGB 5/6/5) at the specified (x,y) position.
941+ @brief Draw a RAM-resident 16-bit image (RGB 5/6/5) at the specified (x,y) position.
942942 For 16-bit display devices; no color reduction performed.
943943 @param x Top left corner x coordinate
944944 @param y Top left corner y coordinate
@@ -1032,31 +1032,13 @@ void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y,
10321032/* *************************************************************************/
10331033void Adafruit_GFX::drawChar (int16_t x, int16_t y, unsigned char c,
10341034 uint16_t color, uint16_t bg, uint8_t size) {
1035- drawChar (x, y, c, color, bg, size, size);
1036- }
1037-
1038- // Draw a character
1039- /* *************************************************************************/
1040- /* !
1041- @brief Draw a single character
1042- @param x Bottom left corner x coordinate
1043- @param y Bottom left corner y coordinate
1044- @param c The 8-bit font-indexed character (likely ascii)
1045- @param color 16-bit 5-6-5 Color to draw chraracter with
1046- @param bg 16-bit 5-6-5 Color to fill background with (if same as color, no background)
1047- @param size_x Font magnification level in X-axis, 1 is 'original' size
1048- @param size_y Font magnification level in Y-axis, 1 is 'original' size
1049- */
1050- /* *************************************************************************/
1051- void Adafruit_GFX::drawChar (int16_t x, int16_t y, unsigned char c,
1052- uint16_t color, uint16_t bg, uint8_t size_x, uint8_t size_y) {
10531035
10541036 if (!gfxFont) { // 'Classic' built-in font
10551037
10561038 if ((x >= _width) || // Clip right
10571039 (y >= _height) || // Clip bottom
1058- ((x + 6 * size_x - 1 ) < 0 ) || // Clip left
1059- ((y + 8 * size_y - 1 ) < 0 )) // Clip top
1040+ ((x + 6 * size - 1 ) < 0 ) || // Clip left
1041+ ((y + 8 * size - 1 ) < 0 )) // Clip top
10601042 return ;
10611043
10621044 if (!_cp437 && (c >= 176 )) c++; // Handle 'classic' charset behavior
@@ -1066,21 +1048,21 @@ void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
10661048 uint8_t line = pgm_read_byte (&font[c * 5 + i]);
10671049 for (int8_t j=0 ; j<8 ; j++, line >>= 1 ) {
10681050 if (line & 1 ) {
1069- if (size_x == 1 && size_y == 1 )
1051+ if (size == 1 )
10701052 writePixel (x+i, y+j, color);
10711053 else
1072- writeFillRect (x+i*size_x , y+j*size_y, size_x, size_y , color);
1054+ writeFillRect (x+i*size , y+j*size, size, size , color);
10731055 } else if (bg != color) {
1074- if (size_x == 1 && size_y == 1 )
1056+ if (size == 1 )
10751057 writePixel (x+i, y+j, bg);
10761058 else
1077- writeFillRect (x+i*size_x , y+j*size_y, size_x, size_y , bg);
1059+ writeFillRect (x+i*size , y+j*size, size, size , bg);
10781060 }
10791061 }
10801062 }
10811063 if (bg != color) { // If opaque, draw vertical line for last column
1082- if (size_x == 1 && size_y == 1 ) writeFastVLine (x+5 , y, 8 , bg);
1083- else writeFillRect (x+5 *size_x , y, size_x , 8 *size_y , bg);
1064+ if (size == 1 ) writeFastVLine (x+5 , y, 8 , bg);
1065+ else writeFillRect (x+5 *size , y, size , 8 *size , bg);
10841066 }
10851067 endWrite ();
10861068
@@ -1102,7 +1084,7 @@ void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
11021084 uint8_t xx, yy, bits = 0 , bit = 0 ;
11031085 int16_t xo16 = 0 , yo16 = 0 ;
11041086
1105- if (size_x > 1 || size_y > 1 ) {
1087+ if (size > 1 ) {
11061088 xo16 = xo;
11071089 yo16 = yo;
11081090 }
@@ -1132,11 +1114,11 @@ void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c,
11321114 bits = pgm_read_byte (&bitmap[bo++]);
11331115 }
11341116 if (bits & 0x80 ) {
1135- if (size_x == 1 && size_y == 1 ) {
1117+ if (size == 1 ) {
11361118 writePixel (x+xo+xx, y+yo+yy, color);
11371119 } else {
1138- writeFillRect (x+(xo16+xx)*size_x , y+(yo16+yy)*size_y ,
1139- size_x, size_y , color);
1120+ writeFillRect (x+(xo16+xx)*size , y+(yo16+yy)*size ,
1121+ size, size , color);
11401122 }
11411123 }
11421124 bits <<= 1 ;
@@ -1157,21 +1139,21 @@ size_t Adafruit_GFX::write(uint8_t c) {
11571139
11581140 if (c == ' \n ' ) { // Newline?
11591141 cursor_x = 0 ; // Reset x to zero,
1160- cursor_y += textsize_y * 8 ; // advance y one line
1142+ cursor_y += textsize * 8 ; // advance y one line
11611143 } else if (c != ' \r ' ) { // Ignore carriage returns
1162- if (wrap && ((cursor_x + textsize_x * 6 ) > _width)) { // Off right?
1144+ if (wrap && ((cursor_x + textsize * 6 ) > _width)) { // Off right?
11631145 cursor_x = 0 ; // Reset x to zero,
1164- cursor_y += textsize_y * 8 ; // advance y one line
1146+ cursor_y += textsize * 8 ; // advance y one line
11651147 }
1166- drawChar (cursor_x, cursor_y, c, textcolor, textbgcolor, textsize_x, textsize_y );
1167- cursor_x += textsize_x * 6 ; // Advance x one char
1148+ drawChar (cursor_x, cursor_y, c, textcolor, textbgcolor, textsize );
1149+ cursor_x += textsize * 6 ; // Advance x one char
11681150 }
11691151
11701152 } else { // Custom font
11711153
11721154 if (c == ' \n ' ) {
11731155 cursor_x = 0 ;
1174- cursor_y += (int16_t )textsize_y *
1156+ cursor_y += (int16_t )textsize *
11751157 (uint8_t )pgm_read_byte (&gfxFont->yAdvance );
11761158 } else if (c != ' \r ' ) {
11771159 uint8_t first = pgm_read_byte (&gfxFont->first );
@@ -1182,14 +1164,14 @@ size_t Adafruit_GFX::write(uint8_t c) {
11821164 h = pgm_read_byte (&glyph->height );
11831165 if ((w > 0 ) && (h > 0 )) { // Is there an associated bitmap?
11841166 int16_t xo = (int8_t )pgm_read_byte (&glyph->xOffset ); // sic
1185- if (wrap && ((cursor_x + textsize_x * (xo + w)) > _width)) {
1167+ if (wrap && ((cursor_x + textsize * (xo + w)) > _width)) {
11861168 cursor_x = 0 ;
1187- cursor_y += (int16_t )textsize_y *
1169+ cursor_y += (int16_t )textsize *
11881170 (uint8_t )pgm_read_byte (&gfxFont->yAdvance );
11891171 }
1190- drawChar (cursor_x, cursor_y, c, textcolor, textbgcolor, textsize_x, textsize_y );
1172+ drawChar (cursor_x, cursor_y, c, textcolor, textbgcolor, textsize );
11911173 }
1192- cursor_x += (uint8_t )pgm_read_byte (&glyph->xAdvance ) * (int16_t )textsize_x ;
1174+ cursor_x += (uint8_t )pgm_read_byte (&glyph->xAdvance ) * (int16_t )textsize ;
11931175 }
11941176 }
11951177
@@ -1204,19 +1186,7 @@ size_t Adafruit_GFX::write(uint8_t c) {
12041186*/
12051187/* *************************************************************************/
12061188void Adafruit_GFX::setTextSize (uint8_t s) {
1207- setTextSize (s, s);
1208- }
1209-
1210- /* *************************************************************************/
1211- /* !
1212- @brief Set text 'magnification' size. Each increase in s makes 1 pixel that much bigger.
1213- @param s_x Desired text width magnification level in X-axis. 1 is default
1214- @param s_y Desired text width magnification level in Y-axis. 1 is default
1215- */
1216- /* *************************************************************************/
1217- void Adafruit_GFX::setTextSize (uint8_t s_x, uint8_t s_y) {
1218- textsize_x = (s_x > 0 ) ? s_x : 1 ;
1219- textsize_y = (s_y > 0 ) ? s_y : 1 ;
1189+ textsize = (s > 0 ) ? s : 1 ;
12201190}
12211191
12221192/* *************************************************************************/
@@ -1283,7 +1253,7 @@ void Adafruit_GFX::charBounds(char c, int16_t *x, int16_t *y,
12831253
12841254 if (c == ' \n ' ) { // Newline?
12851255 *x = 0 ; // Reset x to zero, advance y by one line
1286- *y += textsize_y * (uint8_t )pgm_read_byte (&gfxFont->yAdvance );
1256+ *y += textsize * (uint8_t )pgm_read_byte (&gfxFont->yAdvance );
12871257 } else if (c != ' \r ' ) { // Not a carriage return; is normal char
12881258 uint8_t first = pgm_read_byte (&gfxFont->first ),
12891259 last = pgm_read_byte (&gfxFont->last );
@@ -1295,42 +1265,41 @@ void Adafruit_GFX::charBounds(char c, int16_t *x, int16_t *y,
12951265 xa = pgm_read_byte (&glyph->xAdvance );
12961266 int8_t xo = pgm_read_byte (&glyph->xOffset ),
12971267 yo = pgm_read_byte (&glyph->yOffset );
1298- if (wrap && ((*x+(((int16_t )xo+gw)*textsize_x )) > _width)) {
1268+ if (wrap && ((*x+(((int16_t )xo+gw)*textsize )) > _width)) {
12991269 *x = 0 ; // Reset x to zero, advance y by one line
1300- *y += textsize_y * (uint8_t )pgm_read_byte (&gfxFont->yAdvance );
1270+ *y += textsize * (uint8_t )pgm_read_byte (&gfxFont->yAdvance );
13011271 }
1302- int16_t tsx = (int16_t )textsize_x,
1303- tsy = (int16_t )textsize_y,
1304- x1 = *x + xo * tsx,
1305- y1 = *y + yo * tsy,
1306- x2 = x1 + gw * tsx - 1 ,
1307- y2 = y1 + gh * tsy - 1 ;
1272+ int16_t ts = (int16_t )textsize,
1273+ x1 = *x + xo * ts,
1274+ y1 = *y + yo * ts,
1275+ x2 = x1 + gw * ts - 1 ,
1276+ y2 = y1 + gh * ts - 1 ;
13081277 if (x1 < *minx) *minx = x1;
13091278 if (y1 < *miny) *miny = y1;
13101279 if (x2 > *maxx) *maxx = x2;
13111280 if (y2 > *maxy) *maxy = y2;
1312- *x += xa * tsx ;
1281+ *x += xa * ts ;
13131282 }
13141283 }
13151284
13161285 } else { // Default font
13171286
13181287 if (c == ' \n ' ) { // Newline?
13191288 *x = 0 ; // Reset x to zero,
1320- *y += textsize_y * 8 ; // advance y one line
1289+ *y += textsize * 8 ; // advance y one line
13211290 // min/max x/y unchaged -- that waits for next 'normal' character
13221291 } else if (c != ' \r ' ) { // Normal char; ignore carriage returns
1323- if (wrap && ((*x + textsize_x * 6 ) > _width)) { // Off right?
1292+ if (wrap && ((*x + textsize * 6 ) > _width)) { // Off right?
13241293 *x = 0 ; // Reset x to zero,
1325- *y += textsize_y * 8 ; // advance y one line
1294+ *y += textsize * 8 ; // advance y one line
13261295 }
1327- int x2 = *x + textsize_x * 6 - 1 , // Lower-right pixel of char
1328- y2 = *y + textsize_y * 8 - 1 ;
1296+ int x2 = *x + textsize * 6 - 1 , // Lower-right pixel of char
1297+ y2 = *y + textsize * 8 - 1 ;
13291298 if (x2 > *maxx) *maxx = x2; // Track max x, y
13301299 if (y2 > *maxy) *maxy = y2;
13311300 if (*x < *minx) *minx = *x; // Track min x, y
13321301 if (*y < *miny) *miny = *y;
1333- *x += textsize_x * 6 ; // Advance x one char
1302+ *x += textsize * 6 ; // Advance x one char
13341303 }
13351304 }
13361305}
@@ -1472,33 +1441,6 @@ void Adafruit_GFX_Button::initButton(
14721441 textcolor, label, textsize);
14731442}
14741443
1475- /* *************************************************************************/
1476- /* !
1477- @brief Initialize button with our desired color/size/settings
1478- @param gfx Pointer to our display so we can draw to it!
1479- @param x The X coordinate of the center of the button
1480- @param y The Y coordinate of the center of the button
1481- @param w Width of the buttton
1482- @param h Height of the buttton
1483- @param outline Color of the outline (16-bit 5-6-5 standard)
1484- @param fill Color of the button fill (16-bit 5-6-5 standard)
1485- @param textcolor Color of the button label (16-bit 5-6-5 standard)
1486- @param label Ascii string of the text inside the button
1487- @param textsize_x The font magnification in X-axis of the label text
1488- @param textsize_y The font magnification in Y-axis of the label text
1489- */
1490- /* *************************************************************************/
1491- // Classic initButton() function: pass center & size
1492- void Adafruit_GFX_Button::initButton (
1493- Adafruit_GFX *gfx, int16_t x, int16_t y, uint16_t w, uint16_t h,
1494- uint16_t outline, uint16_t fill, uint16_t textcolor,
1495- char *label, uint8_t textsize_x, uint8_t textsize_y)
1496- {
1497- // Tweak arguments and pass to the newer initButtonUL() function...
1498- initButtonUL (gfx, x - (w / 2 ), y - (h / 2 ), w, h, outline, fill,
1499- textcolor, label, textsize_x, textsize_y);
1500- }
1501-
15021444/* *************************************************************************/
15031445/* !
15041446 @brief Initialize button with our desired color/size/settings, with upper-left coordinates
@@ -1518,30 +1460,6 @@ void Adafruit_GFX_Button::initButtonUL(
15181460 Adafruit_GFX *gfx, int16_t x1, int16_t y1, uint16_t w, uint16_t h,
15191461 uint16_t outline, uint16_t fill, uint16_t textcolor,
15201462 char *label, uint8_t textsize)
1521- {
1522- initButtonUL (gfx, x1, y1, w, h, outline, fill, textcolor, label, textsize, textsize);
1523- }
1524-
1525- /* *************************************************************************/
1526- /* !
1527- @brief Initialize button with our desired color/size/settings, with upper-left coordinates
1528- @param gfx Pointer to our display so we can draw to it!
1529- @param x1 The X coordinate of the Upper-Left corner of the button
1530- @param y1 The Y coordinate of the Upper-Left corner of the button
1531- @param w Width of the buttton
1532- @param h Height of the buttton
1533- @param outline Color of the outline (16-bit 5-6-5 standard)
1534- @param fill Color of the button fill (16-bit 5-6-5 standard)
1535- @param textcolor Color of the button label (16-bit 5-6-5 standard)
1536- @param label Ascii string of the text inside the button
1537- @param textsize_x The font magnification in X-axis of the label text
1538- @param textsize_y The font magnification in Y-axis of the label text
1539- */
1540- /* *************************************************************************/
1541- void Adafruit_GFX_Button::initButtonUL (
1542- Adafruit_GFX *gfx, int16_t x1, int16_t y1, uint16_t w, uint16_t h,
1543- uint16_t outline, uint16_t fill, uint16_t textcolor,
1544- char *label, uint8_t textsize_x, uint8_t textsize_y)
15451463{
15461464 _x1 = x1;
15471465 _y1 = y1;
@@ -1550,8 +1468,7 @@ void Adafruit_GFX_Button::initButtonUL(
15501468 _outlinecolor = outline;
15511469 _fillcolor = fill;
15521470 _textcolor = textcolor;
1553- _textsize_x = textsize_x;
1554- _textsize_y = textsize_y;
1471+ _textsize = textsize;
15551472 _gfx = gfx;
15561473 strncpy (_label, label, 9 );
15571474}
@@ -1579,10 +1496,10 @@ void Adafruit_GFX_Button::drawButton(boolean inverted) {
15791496 _gfx->fillRoundRect (_x1, _y1, _w, _h, r, fill);
15801497 _gfx->drawRoundRect (_x1, _y1, _w, _h, r, outline);
15811498
1582- _gfx->setCursor (_x1 + (_w/2 ) - (strlen (_label) * 3 * _textsize_x ),
1583- _y1 + (_h/2 ) - (4 * _textsize_y ));
1499+ _gfx->setCursor (_x1 + (_w/2 ) - (strlen (_label) * 3 * _textsize ),
1500+ _y1 + (_h/2 ) - (4 * _textsize ));
15841501 _gfx->setTextColor (text);
1585- _gfx->setTextSize (_textsize_x, _textsize_y );
1502+ _gfx->setTextSize (_textsize );
15861503 _gfx->print (_label);
15871504}
15881505
0 commit comments