Graphic LCD


Now we get to some really cool stuff, putting a graphic LCD through its paces. This could seem mightily daunting, but luckily the PIC Micro Pascal cross-compiler contains a built-in unit to handle most of the tricky bits. But I've taken this one step further by putting together an even more extensive unit based upon that (entitled "KS107_108_alt.pas"). Here are four exercises, then, to see just what is possible.

First off, let's get the hardware requirements out of the way. I've used the Longtech LGM12864H-FSB-FBW graphic LCD. This is a 128 by 64 pixel affair serviced by KS107/108 drivers. I got mine from Amazon for around ten bucks several years ago. Here's how to hook it up to a PIC16F88:


Now there are a couple things to keep in mind. First, on some units the CS1 and CS2 pins are swapped, meaning that the left and right halves of the screen will be reversed. That's easy enough to fix; just exchange the wires to the two port pins controlling them (A.0 and A.1 in this schematic) should you see a weird folded over display.

Not so pleasant is that some graphic LCD modules also exchange the power pins (+5V and ground). Whoa! That'll make some expensive smoke if you don't catch it ahead of time. So, please, be sure to download a data sheet for the particular unit you're using and make adjustments accordingly.

If you've got that all worked out, then let's turn our attention to the software. As mentioned above, I've provided an extensive Pascal unit that really makes things smooth as silk. You'll find commands to print text, boxes, rounded boxes, circles, ellipse, lines and points. Moreover, there are commands to mirror images, do photographic negatives and show bit-mapped images. You'll even find transitions to use between screens, things like video wipes and venetian blinds effects. As usual, spend some time with the files included in the download, especially since I've included all sorts of documentation in them.

By the way, I've also enclosed a font file containing several representative fonts that will hold you in good stead. Feel free to add your own to it.

There are four demo programs in the download package. The photo above shows #1 in action. It displays a rounded box with text, blinks it, mirrors it and makes a photo negative.

Demo #2 shows the bit map in action, with mirroring, photo negatives, venetian blinds and wiping transitions, etc.


Demo #3 gets in to what can be done with geometric objects, things like lines, circles, rectangles and such. You'll also see the split screen effect in play.


And finally in Demo #4 we meet the many possibilities of the font options. In particular, the 8X8 font set includes all numerals, digits, punctuation and so forth, but also mathematical symbols, diacritical marks and accents, as well as box drawing symbols.


There's an awful lot here, so spend some time with the source code files.

Click to get the source code.
Click to get the schematic PDF.

Next Project: Pushbutton Switch

No comments:

Post a Comment