0x416c6578

Display

Writing Text To The Screen

Speeding It Up

My implementation is described here:

void drawCharPixelToBuffer(int charColumn, int charRow, uint8_t pixelsPerPixel, bool pixelInCharHere, uint16_t colour) {
  //Get the row and column of the origin of the current FONT pixel as a DISPLAY position
  //by scaling by the font size
  int columnFontIndexScaledByPixelCount = charColumn * pixelsPerPixel;
  int rowFontIndexScaledByPixelCount = charRow * pixelsPerPixel;
  //Get the number of display pixels per character row
  int pixelsPerRow = FONT_WIDTH * pixelsPerPixel;
  int newXAddOffset, newYAddOffset;
  //Loop through every display pixel in the current FONT pixel
  for (int i = 0; i < pixelsPerPixel; i++) {
    for (int j = 0; j < pixelsPerPixel; j++) {
      //Handle the current offsets from the origin calculated above
      newXAddOffset = columnFontIndexScaledByPixelCount + j;
      newYAddOffset = rowFontIndexScaledByPixelCount + i;
      //Write to the LCD buffer using the logic presented above
      lcdBuffer[2*(newYAddOffset * pixelsPerRow + newXAddOffset)] = pixelInCharHere ? (colour >> 8) & 0xFF : 0x00;
      lcdBuffer[2*(newYAddOffset * pixelsPerRow + newXAddOffset) + 1] = pixelInCharHere ? colour & 0xFF : 0x00;
    }
  }
}