Since I am a speed freak, I wanted to make something that will actually be fast.
A quick look at the code
void PCD8544_SPI_FB::writeBitmap(const uint8_t *bitmap, uint8_t x, uint8_t y, uint8_t width, uint8_t height)
{
if (x >= LCD_X || y >= LCD_Y) return;
this->gotoXY(x, y);
uint16_t pos = this->m_Position;
for (uint8_t y = 0; y < height; y++)
{
memcpy(this->m_Buffer + pos, bitmap + (y*width), width);
pos += LCD_X;
}
}
could be squeezed a bit by bringing some math out of the loop.
void PCD8544_SPI_FB::writeBitmap(const uint8_t *bitmap, uint8_t x, uint8_t y, uint8_t width, uint8_t height)
{
if (x >= LCD_X || y >= LCD_Y) return;
this->gotoXY(x, y);
uint16_t pos = this->m_Buffer + this->m_Position;
uint16_t maxY = bitmap + height * width;
for (uint16_t y = bitmap; y < maxY; y+=width)
{
memcpy(pos, y, width);
pos += LCD_X;
}
}
can you time it?