Re: Nokia PCD8544 (5110 LCD display) is a little strange

Home Evil Mad Scientist Forums Electronics Nokia PCD8544 (5110 LCD display) is a little strange Re: Nokia PCD8544 (5110 LCD display) is a little strange

#20740
protheus
Participant

So, after going back and looking at the library, things are slightly stranger than I thought.  The drawBitmap function assumes that each byte
you hand it is a column (yes, really) of 8 bits, but the columns are
written out from left to right, then top to bottom.  So the first byte
represents the top, left column of 8 bits.  The second represents the
one to the right of it, and so on.  It’s quite odd.  It draws it back
out with this code:

void Adafruit_GFX::drawBitmap(int16_t x, int16_t y,
const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color) {
for (int16_t j=0; j<h; j++) {
for (int16_t i=0; i<w; i++ ) {
if (pgm_read_byte(bitmap + i + (j/8)*w) & _BV(j%8)) {
drawPixel(x+i, y+j, color);
}
}
}
}

Anyway, once you arrange your pixels in this way, they do show up in the correct spot on the screen.

Chris