Skip to content

OLED display details

Michael Mattioli edited this page Mar 17, 2017 · 3 revisions

Display orientation

As noted here, there are three specific SPI commands that need to be sent which reflect the orientation of the display; the table below reflects what these values are relative to the orientation of the ZedBoard.

Command Normal Inverted
Segment Re-map 0xA0 0xA1
COM Output Scan Direction 0xC0 0xC8
COM Pins Hardware Configuration 0x00 0x20

Displaying text

The OLED display has a width of 128 pixels and a height of 32 pixels (128x32); each character displayed has a width of 8 pixels and a height of 8 pixels (8x8) which results in 4 usable rows each of which can hold 16 characters.

A 2D array of size 4x16 holds 64 characters which are represented by 8-bit (1-byte) ASCII hexadecimal values. The ASCII hexadecimal representation of Hello world! is:

0x48 0x65 0x6c 0x6c 0x6f 0x20 0x77 0x6f 0x72 0x6c 0x64 0x21 0x20 0x20 0x20 0x20
H    e    l    l    o         w    o    r    l    d    !

Since each character has a width of 8 pixels and a height of 8 pixels, a single 8-bit (1-byte) value will represent a single column; therefore, in order to display a single character, 8 (one for each column) 8-bit values must be sent via SPI to the display. When displaying any arbitrary ASCII hexadecimal character, the hexadecimal representation is used as the starting memory address to reference the 8-bit values required to display the character; for example, when displaying H (0x48) the following memory addresses hold the 8-bit values sent to the display, these addresses contain hexadecimal values which represent 8-bit (1-byte) binary values:

Column Address Hexadecimal Binary
0 0x48 & 000 0x41 0100 0001
1 0x48 & 001 0x7f 0111 1111
2 0x48 & 010 0x08 0000 1000
3 0x48 & 011 0x08 0000 1000
4 0x48 & 100 0x08 0000 1000
5 0x48 & 101 0x7f 0111 1111
6 0x48 & 110 0x41 0100 0001
7 0x48 & 111 0x00 0000 0000

When a bit is set to 1, that indicates that the corresponding pixel should be turned on; the following grid shows how the bits correspond to individual pixels used to depict the ASCII character H on the display.

Column 0 (0x41) Column 1 (0x7f) Column 2 (0x08) Column 3 (0x08) Column 4 (0x08) Column 5 (0x7f) Column 6 (0x41) Column 7 (0x00)
1 1 1 1
1 1
1 1
1 1
1 1 1 1 1
1 1
1 1
1 1 1 1
Clone this wiki locally