|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionThis is a fairly simple application and class library that wraps the control functions of a Scott Edwards Serial Backpack LCD module. It makes use of the .NET 2.0 frameworks System.IO.Ports namespace and the proprietary (but documented) LCD control commands of the BPI-216 LCD. They are common enough that I assumed others might be interested. BackgroundThe Scott Edwards Serial LCDs have a fairly simple command structure, but if you have a 2x16 LCD, you end up writing into the offscreen area before the line wraps around again since the buffers are for a 40 character LCD. I wanted a class that would keep track of the cursor position and automatically wrap to the next line at the appropriate place. You can write any stream of bytes or any string to the display and it is wrapped automatically. With this, you can send a continuous string, including newlines to the LCD and it will never go outside the display. Additionally, you can position the cursor through an X,Y coordinate pair or individual X or Y position. Since the screen interprets characters 8-31 as repeats of the custom characters (0-7), newlines do not work without code. With this, you can optionally turn on interception of CR and/or LF as well as line blanking on new lines. I have treated CR and LF seperately- LF simply moves down a line (same X position) and CR moves to the beginning of the line you're on. I also added an option so that all CR characters can be treated as CRLF's (CR executes a LF as well). Lastly, I wrote a function that takes an 8 byte bit map (per documentation) and will load it into the specified custom character address. Summary of Features* Absolute positioning and position awareness Future Features* currently hardcoded for Scott Edwards BPI-216 Screens- perhaps will add support for other models and/or make constants instead. Using the codeAn extremely simple example application is provided that has a textbox to type into (characters appear on the LCD, and the virutal LCD (V2 only), but not the textbox) and it displays the current X & Y position. Its main purpose is to demonstrate how to instantiate the LCD class and provides a test apparatus. This code is not provided so much for educational use as it is for sharing of a handy utility. The code should be fairly straightforward and it is fairly heavily commented. I also haven't used any crazy syntactical tricks. NotesOne thing I neglected to mention above that needs pointing out- the .Pos, .X, and .Y properties set/get where the cursor is going to write. When auto scroll in on, the cursor will always jump to 0,1- and the display will not scroll up until the next character is entered. Similarly, if Clear on Wrap is on, the display doesn't clear the line until text is entered on it, even though the cursor is technically on the line already. When reading the RawScreen property, characters that have not been touched are nulls (using a nullable byte type)- this may have uses, but you have to watch for it when/if you update a virtual LCD label. Lastly, Auto Scroll implies Clear on Wrap since the display must move everything up a line, the new line is naturally clear. History* 08/31/07 - Initial Version/Release
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||