circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 


Published April 2000

LOOKING GOOD

Silicon Online Using a Graphics-Based LCD
Module with C

by Bob Perrin and Tak Auyeung

StartSoftware OverviewThe Bottom LayerInitializing the LCD DisplayShadow DisplayDrawing Dots and LinesPrinting TextExtensionsSources and PDF

INITIALIZING THE LCD DISPLAY

The lcdInit() function initializes the LCD display for normal operation. The function first configures the bit-addressable I/O port properly and performs hardware reset. Then the driver software sends a software-reset command to the LCD module. Next, the software driver sets up the power supply for the LCD module. The Hantronix HDG12864F-1 module uses a Epson SED1565 LCD controller. This LCD controller has three on-chip features to provide the negative voltage for contrast control.

For a 5-V single-supply system, the Hantronix HDG12864F-1 recommends setting the 5-V regulator internal resistor ratio to 4 (out of 7); enabling the booster, voltage regulator, and voltage follower circuits; and setting the electronic volume (contrast) control to 0 x 24 (36) out of 0xff (255).

As with any LCD controllers, it is important to set up the display hardware before enabling the display. The last step in lcdInit() enables the display.

PIXEL ARRANGEMENT

The arrangement of pixels on the Hantronix HDG12864F-1 is awkward and deserves discussion. For consistency purposes, up or top refers to the side of the LCD module where the interconnect cable is located. Furthermore, we use the x,y coordinate convention, which denotes the pixel on column x and row y. Column 0 is the first and leftmost column. Row 0 is the first and top row. In other words, (0,0) is the pixel at the top-left corner.

The LCD comprises eight pages. Each page is a 128-pixel wide by 8-pixel high rectangle. Page 0 refers to the rectangle with (0,0) as the top-left corner, and page N+1 is eight pixels below page N. A register on the Epson SED1565 stores the address of the current (or active) page. The command to set the page address is abstracted as the lcdPageAddressSet macro.

Each page is comprised of 128 columns. Each column is eight pixels high and one pixel wide. Each column in a page is represented by a byte in which bit 0 is the top pixel of the column. The most awkward aspect is that the first column of a page is the right-most column. This is backward compared to most coordinate conventions. A register on the Epson SED1565 maintains the address of the current column. This backward horizontal pixel arrangement does not affect the API, because the driver translates the commonly used leftmost-is-first orientation to the LCD specific orientation. The command to set the column address is abstracted as the lcdColumnAddressSet macro.

Note that writing to the display data (using the macro lcdDisplayDataWrite) automatically increments the column address. However, at the end of a page, the page address is not incremented. Furthermore, if the page address is altered, the column address remains the same.

PREVIOUSNEXT