Question

For an 8-bit embedded system that has a small monochrome LCD with black/white pixels (not grayscale), I need an efficient way of storing and displaying fonts. I will probably choose two fixed-width fonts, 4x5 pixels and 5x7 pixels. The resources are very limited: 30k ROM, 2k RAM. The fonts will be written to the buffer with a 1:1 scale, as a one-line string with a given start offset in pixels (char* str, byte x, byte y)

I think I would use 1k of RAM for the buffer. Unless there's a more efficient structure for writing the fonts to, I would have it arranged so it can be written sequentially into the LCD, which would be as follows:

byte buffer[1024];

Where each byte represents a horizontal line of 8 pixels (MSB on the left), and each line of the display is completed from left to right, and in that fashion, top to bottom. (So each line is represented by (128px / 8 =) 16 bytes.)

So my question:

  1. How should the fonts be stored?
  2. What form should the buffer take?
  3. How should the fonts be written to the buffer?

I presume there are some standard algorithms for this, but I can't find anything in searches. Any suggestions would be very helpful (I don't expect anyone to code this for me!!)

Thanks

Was it helpful?

Solution

As a first cut, implement bit blit, a primitive with many uses, including drawing characters. This dictates the following answers to your questions.

  1. As bitmaps.
  2. A bitmap.
  3. Bit blit.

The implementation of bit blit itself involves a bunch of bitwise operations repeatedly extracting a byte or combination of two partial bytes from the source bitmap to be combined with the destination byte.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top