PIC KS0108 LCD Drawing Routines

By Peter Onion

The LCD code I promised is here

There are three user functions in there.

initGRLCD: This sets a few things up and turns the display on

clearLCD: Clears the display to all OFF (light) pixels.

linedraw: This draws a line between (x1,y1) and (x2,y2). x1,y1,x2,y2 are declared as GLOBAL. A 64 byte cache is used to hold modified pixels from the current LCD page. The line is always drawn from left to right and while the pixels to be plotted remain in the same page , each step to the right only requires the next byte to read from the LCD, the appropriate bit to be set and the modified value written into the cache. When a vertical step (up or down) crosses a page boundary the used part of the cache is flushed back to the LCD.

I have also put a bit of demo code here. The first file is a sin/cosine lookup table with values scaled to draw circles on the LCD.

The second file is a little demo that draws a series of lines from vertical to horizontal, then draws a rotating “clock hand”.

Just assemble and link the three files together. Note there is no fuses definition included.

Questions: