Skip to content

Commit

Permalink
Fixes -Wshadow "error: declaration of 'byte' shadows a global declara…
Browse files Browse the repository at this point in the history
…tion"

Arduino.h defines "typedef uint8_t byte" that conflicts with this declaration
  • Loading branch information
waynepiekarski committed Jun 22, 2022
1 parent f8e9621 commit c341c18
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions Adafruit_GFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,16 +718,16 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
int16_t w, int16_t h, uint16_t color) {

int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
uint8_t byte = 0;
uint8_t b = 0;

startWrite();
for (int16_t j = 0; j < h; j++, y++) {
for (int16_t i = 0; i < w; i++) {
if (i & 7)
byte <<= 1;
b <<= 1;
else
byte = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
if (byte & 0x80)
b = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
if (b & 0x80)
writePixel(x + i, y, color);
}
}
Expand All @@ -753,16 +753,16 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
uint16_t bg) {

int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
uint8_t byte = 0;
uint8_t b = 0;

startWrite();
for (int16_t j = 0; j < h; j++, y++) {
for (int16_t i = 0; i < w; i++) {
if (i & 7)
byte <<= 1;
b <<= 1;
else
byte = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
writePixel(x + i, y, (byte & 0x80) ? color : bg);
b = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
writePixel(x + i, y, (b & 0x80) ? color : bg);
}
}
endWrite();
Expand All @@ -784,16 +784,16 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w,
int16_t h, uint16_t color) {

int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
uint8_t byte = 0;
uint8_t b = 0;

startWrite();
for (int16_t j = 0; j < h; j++, y++) {
for (int16_t i = 0; i < w; i++) {
if (i & 7)
byte <<= 1;
b <<= 1;
else
byte = bitmap[j * byteWidth + i / 8];
if (byte & 0x80)
b = bitmap[j * byteWidth + i / 8];
if (b & 0x80)
writePixel(x + i, y, color);
}
}
Expand All @@ -818,16 +818,16 @@ void Adafruit_GFX::drawBitmap(int16_t x, int16_t y, uint8_t *bitmap, int16_t w,
int16_t h, uint16_t color, uint16_t bg) {

int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
uint8_t byte = 0;
uint8_t b = 0;

startWrite();
for (int16_t j = 0; j < h; j++, y++) {
for (int16_t i = 0; i < w; i++) {
if (i & 7)
byte <<= 1;
b <<= 1;
else
byte = bitmap[j * byteWidth + i / 8];
writePixel(x + i, y, (byte & 0x80) ? color : bg);
b = bitmap[j * byteWidth + i / 8];
writePixel(x + i, y, (b & 0x80) ? color : bg);
}
}
endWrite();
Expand All @@ -852,18 +852,18 @@ void Adafruit_GFX::drawXBitmap(int16_t x, int16_t y, const uint8_t bitmap[],
int16_t w, int16_t h, uint16_t color) {

int16_t byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte
uint8_t byte = 0;
uint8_t b = 0;

startWrite();
for (int16_t j = 0; j < h; j++, y++) {
for (int16_t i = 0; i < w; i++) {
if (i & 7)
byte >>= 1;
b >>= 1;
else
byte = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
b = pgm_read_byte(&bitmap[j * byteWidth + i / 8]);
// Nearly identical to drawBitmap(), only the bit order
// is reversed here (left-to-right = LSB to MSB):
if (byte & 0x01)
if (b & 0x01)
writePixel(x + i, y, color);
}
}
Expand Down Expand Up @@ -937,15 +937,15 @@ void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y,
const uint8_t mask[], int16_t w,
int16_t h) {
int16_t bw = (w + 7) / 8; // Bitmask scanline pad = whole byte
uint8_t byte = 0;
uint8_t b = 0;
startWrite();
for (int16_t j = 0; j < h; j++, y++) {
for (int16_t i = 0; i < w; i++) {
if (i & 7)
byte <<= 1;
b <<= 1;
else
byte = pgm_read_byte(&mask[j * bw + i / 8]);
if (byte & 0x80) {
b = pgm_read_byte(&mask[j * bw + i / 8]);
if (b & 0x80) {
writePixel(x + i, y, (uint8_t)pgm_read_byte(&bitmap[j * w + i]));
}
}
Expand All @@ -971,15 +971,15 @@ void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y,
void Adafruit_GFX::drawGrayscaleBitmap(int16_t x, int16_t y, uint8_t *bitmap,
uint8_t *mask, int16_t w, int16_t h) {
int16_t bw = (w + 7) / 8; // Bitmask scanline pad = whole byte
uint8_t byte = 0;
uint8_t b = 0;
startWrite();
for (int16_t j = 0; j < h; j++, y++) {
for (int16_t i = 0; i < w; i++) {
if (i & 7)
byte <<= 1;
b <<= 1;
else
byte = mask[j * bw + i / 8];
if (byte & 0x80) {
b = mask[j * bw + i / 8];
if (b & 0x80) {
writePixel(x + i, y, bitmap[j * w + i]);
}
}
Expand Down Expand Up @@ -1048,15 +1048,15 @@ void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap,
void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[],
const uint8_t mask[], int16_t w, int16_t h) {
int16_t bw = (w + 7) / 8; // Bitmask scanline pad = whole byte
uint8_t byte = 0;
uint8_t b = 0;
startWrite();
for (int16_t j = 0; j < h; j++, y++) {
for (int16_t i = 0; i < w; i++) {
if (i & 7)
byte <<= 1;
b <<= 1;
else
byte = pgm_read_byte(&mask[j * bw + i / 8]);
if (byte & 0x80) {
b = pgm_read_byte(&mask[j * bw + i / 8]);
if (b & 0x80) {
writePixel(x + i, y, pgm_read_word(&bitmap[j * w + i]));
}
}
Expand All @@ -1081,15 +1081,15 @@ void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y, const uint16_t bitmap[],
void Adafruit_GFX::drawRGBBitmap(int16_t x, int16_t y, uint16_t *bitmap,
uint8_t *mask, int16_t w, int16_t h) {
int16_t bw = (w + 7) / 8; // Bitmask scanline pad = whole byte
uint8_t byte = 0;
uint8_t b = 0;
startWrite();
for (int16_t j = 0; j < h; j++, y++) {
for (int16_t i = 0; i < w; i++) {
if (i & 7)
byte <<= 1;
b <<= 1;
else
byte = mask[j * bw + i / 8];
if (byte & 0x80) {
b = mask[j * bw + i / 8];
if (b & 0x80) {
writePixel(x + i, y, bitmap[j * w + i]);
}
}
Expand Down

0 comments on commit c341c18

Please sign in to comment.