Skip to content

Commit

Permalink
Adafruit_GFX_AS: Use a macro to achieve s/textsize/textsize_x/.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiki-lamb committed Nov 25, 2020
1 parent d9adc52 commit 70f99b7
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions STM32F1/libraries/Adafruit_GFX_AS/Adafruit_GFX_AS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ POSSIBILITY OF SUCH DAMAGE.
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#endif

#define textsize textsize_x

Adafruit_GFX_AS::Adafruit_GFX_AS(int16_t w, int16_t h): Adafruit_GFX(w, h)
{
}
Expand Down Expand Up @@ -139,14 +141,14 @@ byte line = 0;
for(int16_t i=0; i<height; i++)
{
if (textcolor != textbgcolor) {
if (textsize_x == 1) drawFastHLine(x, pY, width+gap, textbgcolor);
else fillRect(x, pY, (width+gap)*textsize_x, textsize_x, textbgcolor);
if (textsize == 1) drawFastHLine(x, pY, width+gap, textbgcolor);
else fillRect(x, pY, (width+gap)*textsize, textsize, textbgcolor);
}
for (int16_t k = 0;k < w; k++)
{
line = pgm_read_byte(flash_address+w*i+k);
if(line) {
if (textsize_x==1){
if (textsize==1){
pX = x + k*8;
if(line & 0x80) drawPixel(pX, pY, textcolor);
if(line & 0x40) drawPixel(pX+1, pY, textcolor);
Expand All @@ -158,21 +160,21 @@ for(int16_t i=0; i<height; i++)
if(line & 0x1) drawPixel(pX+7, pY, textcolor);
}
else {
pX = x + k*8*textsize_x;
if(line & 0x80) fillRect(pX, pY, textsize_x, textsize_x, textcolor);
if(line & 0x40) fillRect(pX+textsize_x, pY, textsize_x, textsize_x, textcolor);
if(line & 0x20) fillRect(pX+2*textsize_x, pY, textsize_x, textsize_x, textcolor);
if(line & 0x10) fillRect(pX+3*textsize_x, pY, textsize_x, textsize_x, textcolor);
if(line & 0x8) fillRect(pX+4*textsize_x, pY, textsize_x, textsize_x, textcolor);
if(line & 0x4) fillRect(pX+5*textsize_x, pY, textsize_x, textsize_x, textcolor);
if(line & 0x2) fillRect(pX+6*textsize_x, pY, textsize_x, textsize_x, textcolor);
if(line & 0x1) fillRect(pX+7*textsize_x, pY, textsize_x, textsize_x, textcolor);
pX = x + k*8*textsize;
if(line & 0x80) fillRect(pX, pY, textsize, textsize, textcolor);
if(line & 0x40) fillRect(pX+textsize, pY, textsize, textsize, textcolor);
if(line & 0x20) fillRect(pX+2*textsize, pY, textsize, textsize, textcolor);
if(line & 0x10) fillRect(pX+3*textsize, pY, textsize, textsize, textcolor);
if(line & 0x8) fillRect(pX+4*textsize, pY, textsize, textsize, textcolor);
if(line & 0x4) fillRect(pX+5*textsize, pY, textsize, textsize, textcolor);
if(line & 0x2) fillRect(pX+6*textsize, pY, textsize, textsize, textcolor);
if(line & 0x1) fillRect(pX+7*textsize, pY, textsize, textsize, textcolor);
}
}
}
pY+=textsize_x;
pY+=textsize;
}
return (width+gap)*textsize_x; // x +
return (width+gap)*textsize; // x +
}

/***************************************************************************************
Expand Down Expand Up @@ -246,7 +248,7 @@ int16_t Adafruit_GFX_AS::drawCentreString(char *string, int16_t dX, int16_t poY,
#endif
*pointer++;
}
len = len*textsize_x;
len = len*textsize;
int16_t poX = dX - len/2;

if (poX < 0) poX = 0;
Expand Down Expand Up @@ -297,7 +299,7 @@ int16_t Adafruit_GFX_AS::drawRightString(char *string, int16_t dX, int16_t poY,
*pointer++;
}

len = len*textsize_x;
len = len*textsize;
int16_t poX = dX - len;

if (poX < 0) poX = 0;
Expand Down Expand Up @@ -377,3 +379,5 @@ int16_t Adafruit_GFX_AS::drawFloat(float floatNumber, int16_t decimal, int16_t p
}
return sumX;
}

#undef textsize

0 comments on commit 70f99b7

Please sign in to comment.