Look Here First

Curious why I created this blog? The following two posts explain it all. Click on the titles below to read more.

What this Blog is about.

Project Description.

Saturday, March 19, 2011

Display Driver Part 1

The display driver the student chose to use lacks some basic functionality.
1. It does not have a function to change an area of pixels.
2. It does not have a way of displaying a font to the screen.

Setting an area of pixels is a trivial matter of extending the write columns and rows before sending the color code. The code should be sufficient explanation of the process.

The font however is not trivial. And will require some explanation. The Driver needs a way to display a character to the screen with a simple call to the effect of PutChar(char charToWrite, unsigned char topLeftX, unsigned char topLeftY) where charToWrite is the character to output and topLeftX and topLeftY define the top left of the area to write the character to. Others have written similar functions for other micro-controllers. I'll use some of those principles to create a font output system for the LPC2418 ARM7.

By creating an array of bytes I should be able to store the value of pixel that should be turned on by column (row). Multiple pixels (a column or a row) could be stored in each byte having the each of the first 5 bits in a byte representing a pixel. For example the hex value 0x03 would correspond to 00000101b as a binary value. The least significant bit would respond to the first pixel in the column etc...

For example, with the font 'Bored', available at Font Download A to Z, the letter A could be represented with the following 5 hex values:
 (0x1F, 0x05, 0x05, 0x05, 0x1F).
    1        1        1        1        1
    1        0        0        0        1
    1        1        1        1        1
    1        0        0        0        1
    1        0        0        0        1

The binary ones would represent each pixel that composes the 'A'.  The process could be repeated for each character the student chooses to support.

The array would then be laid out with 5 bytes representing the map for each character supported.  It would make sense to arrange this map so it corresponds to the ASCII table in order.  Characters 32 through 122 should be sufficient.

After a few hours of work this table was the result of converting the 'Bored' font to a hex map.


// starts with the ASCI value 32
// all characters used the bored font except for " # % ( ) * + , - / 1 7 : ; = I [ \ ] ^ _ `

{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00,  // ' ' !
  0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  // " #
  0x0e, 0x1e, 0x0e, 0x00, 0x00, 0x10, 0x0A, 0x04, 0x10, 0x01,  // $ %
  0x1f, 0x15, 0x15, 0x1f, 0x08, 0x03, 0x00, 0x00, 0x00, 0x00,  // & '
  0x00, 0x04, 0x1b, 0x11, 0x00, 0x00, 0x11, 0x1b, 0x04, 0x00,  // ( )
  0x00, 0x0a, 0x05, 0x0a, 0x00, 0x00, 0x04, 0x0E, 0x04, 0x00,  // * +
  0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x00,  // , -
  0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x04, 0x02, 0x01,  // . /
  0x1f, 0x11, 0x11, 0x11, 0x1f, 0x00, 0x11, 0x1f, 0x10, 0x00,  // 0 1
  0x1d, 0x15, 0x15, 0x15, 0x16, 0x11, 0x15, 0x15, 0x15, 0x1f,  // 2 3
  0x08, 0x0c, 0x0a, 0x1f, 0x08, 0x17, 0x15, 0x15, 0x15, 0x0d,  // 4 5
  0x1e, 0x15, 0x15, 0x15, 0x1d, 0x01, 0x11, 0x09, 0x05, 0x03,  // 6 7
  0x1f, 0x15, 0x15, 0x15, 0x1f, 0x17, 0x15, 0x15, 0x15, 0x1f,  // 8 9
  0x00, 0x12  0x00, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00,  // : ;
  0x00, 0x08, 0x14, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x00,  // < =
  0x00, 0x14, 0x08, 0x00, 0x00, 0x01, 0x15, 0x07, 0x00, 0x00,  // > ?
  0x1e, 0x1e, 0x16, 0x1e, 0x00, 0x1f, 0x05, 0x05, 0x05, 0x1f,  // @ A
  0x1f, 0x15, 0x15, 0x15, 0x1b, 0x1f, 0x11, 0x11, 0x11, 0x1b,  // B C
  0x1f, 0x11, 0x11, 0x11, 0x0c, 0x1f, 0x15, 0x1g, 0x15, 0x11,  // D E
  0x1f, 0x05, 0x05, 0x05, 0x01, 0x1f, 0x11, 0x11, 0x15, 0x1d,  // F G
  0x1f, 0x04, 0x04, 0x04, 0x1f, 0x00, 0x11, 0x1f, 0x11, 0x00,  // H I
  0x18, 0x10, 0x10, 0x10, 0x1f, 0x1f, 0x04, 0x04, 0x0a, 0x11,  // J K
  0x1f, 0x10, 0x10, 0x10, 0x10, 0x1f, 0x01, 0x1e, 0x01, 0x1f,  // L M
  0x1f, 0x02, 0x04, 0x08, 0x1f, 0x1f, 0x11, 0x11, 0x11, 0x1f,  // N O
  0x1f, 0x05, 0x05, 0x05, 0x07, 0x1f, 0x11, 0x11, 0x19, 0x1f,  // P Q
  0x1f, 0x05, 0x05, 0x0d, 0x17, 0x17, 0x15, 0x15, 0x15, 0x1d,  // R S
  0x01, 0x01, 0x1f, 0x01, 0x01, 0x1f, 0x10, 0x10, 0x10, 0x1f,  // T U
  0x07, 0x08, 0x10, 0x08, 0x07, 0x1f, 0x10, 0x0f, 0x10, 0x1f,  // V W
  0x11, 0x0a, 0x04, 0x0a, 0x11, 0x17, 0x14, 0x14, 0x14, 0x1f,  // X Y
  0x11, 0x19, 0x15, 0x13, 0x11, 0x00, 0x00, 0x1f, 0x11, 0x11,  // Z [
  0x01, 0x02, 0x04, 0x08, 0x10, 0x11, 0x11, 0x1f, 0x00, 0x00,  // \ ]
  0x00, 0x02, 0x01, 0x02, 0x00, 0x10, 0x10, 0x10, 0x10, 0x10,  // ^ _
  0x00, 0x01, 0x02, 0x00, 0x00, 0x1f, 0x05, 0x05, 0x05, 0x1f,  // ` a
  0x1f, 0x15, 0x15, 0x15, 0x1b, 0x1f, 0x11, 0x11, 0x11, 0x1b,  // b c
  0x1f, 0x11, 0x11, 0x11, 0x0c, 0x1f, 0x15, 0x1g, 0x15, 0x11,  // d e
  0x1f, 0x05, 0x05, 0x05, 0x01, 0x1f, 0x11, 0x11, 0x15, 0x1d,  // f g
  0x1f, 0x04, 0x04, 0x04, 0x1f, 0x00, 0x11, 0x1f, 0x11, 0x00,  // h i
  0x18, 0x10, 0x10, 0x10, 0x1f, 0x1f, 0x04, 0x04, 0x0a, 0x11,  // j k
  0x1f, 0x10, 0x10, 0x10, 0x10, 0x1f, 0x01, 0x1e, 0x01, 0x1f,  // l m
  0x1f, 0x02, 0x04, 0x08, 0x1f, 0x1f, 0x11, 0x11, 0x11, 0x1f,  // n o
  0x1f, 0x05, 0x05, 0x05, 0x07, 0x1f, 0x11, 0x11, 0x19, 0x1f,  // p q
  0x1f, 0x05, 0x05, 0x0d, 0x17, 0x17, 0x15, 0x15, 0x15, 0x1d,  // r s
  0x01, 0x01, 0x1f, 0x01, 0x01, 0x1f, 0x10, 0x10, 0x10, 0x1f,  // t u
  0x07, 0x08, 0x10, 0x08, 0x07, 0x1f, 0x10, 0x0f, 0x10, 0x1f,  // v w
  0x11, 0x0a, 0x04, 0x0a, 0x11, 0x17, 0x14, 0x14, 0x14, 0x1f,  // x y
  0x11, 0x19, 0x15, 0x13} // z

To display the font there will need to be code that reads the bytes for each font out of the array,  displays the character on a background color, and adds space above, below and on each side of the character.

No comments:

Post a Comment