Click here to Skip to main content
Click here to Skip to main content

Simple Scott Edwards Serial Backpack LCD Class and Example

By , 9 Sep 2007
Rate this:
Please Sign up or sign in to vote.

Screenshot - virtual_lcd.jpg

Screenshot - _MG_3300_300.jpg


This 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 framework's 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.


The Scott Edwards Serial LCDs have a fairly simple command structure, but if you have a 2x16 LCD, you end up writing into the off-screen 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 separately - LF simply moves down a line (same X position), and CR moves to the beginning of the line you are on. I also added an option so that all CR characters can be treated as CRLFs (CR executes an 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.
  • Automatic line wrap at the edge of screen rather than the end of the buffer off-screen.
  • Optional interception/translation of CR and LF with optional CR = CRLF.
  • Support for custom characters.
  • Supports cursor type setting.
  • V2 supports a virtual screen buffer for saving and restoring.
  • The V2 example code has a virtual LCD label that reflects what is on the real LCD - excluding special or custom characters.
  • V2.1 adds support for auto-scroll, leveraging the virtual buffer to be able to scroll the previous line upwards.
  • V2.2 fixes the missing backslash in the LCD firmware by automatically loading a backslash character into the custom character memory #7 whenever RemapBackslash is turned on. Note that if you disable RemapBackslash and load a new character into #7, and eventually turn remap back on, it will reload the backslash character again. Off by default, since you lose a custom character space.
  • V2.3 adds a screen updated event and an LCD clock you can enable/disable with a checkbox. The new example app consumes the event, of course.
  • V2.4 adds a differential write procedure where, given a supplied array, it will write only the changed characters to the screen. Has some optimizing, so positioning commands aren't sent when the screen is already at a position (e.g., writing a character and then the adjacent character).

Future Features

  • Currently hardcoded for Scott Edwards BPI-216 screens - perhaps, will add support for other models and/or make constants instead.
  • Perhaps support for multiple snapshots and restores.
  • Implement stream class for direct output.
  • Make remap backslash only load the replacement character when needed, and reload either the default #7 (space), or if the user has uploaded a custom char, put it back before its next use. Update: tried it, but unfortunately, the hardware redraws the display every time you add a character, and it uses the current custom character map, so this feature is impossible.
  • Others? Ideas?

Using the Code

An extremely simple example application is provided, that has a textbox to type into (characters appear on the LCD and the virtual LCD (V2 only), but not the textbox), and it displays the current X and 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.


One 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 is 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.


  • 08/31/07 - Initial version/release.
  • 09/01/07 - V2 includes updated example app and new snapshot feature.
  • 09/01/07 - V2.1 adds auto-scroll, and adds a CLS button and a cursor type selector list to the example app.
  • 09/01/07 - V2.2 works around the missing backslash, and has a few typo fixes in comments.
  • 09/01/07 - V2.3 added the ScreenUpdated event for easier client use/updating of virtual displays.
  • 09/10/07 - V2.4 added the differential write method (WriteByDiff).


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Brett Trotter
Systems Engineer BT Technical Services
United States United States
No Biography provided

Comments and Discussions

Questionhow to implement the same with the display of the <b>Nokia 3310</b>? Pinmemberpainterargon12-Jul-12 22:32 
GeneralMy vote of 5 Pinmemberpainterargon12-Jul-12 22:20 
GeneralGreat get tuning! PinmemberSoftwareDom9-Sep-07 20:57 
QuestionWhy no screen shot? Pinmemberyojiq3-Sep-07 23:29 
AnswerRe: Why no screen shot? PinmemberBrett Trotter4-Sep-07 3:03 
Answerdone! PinmemberBrett Trotter9-Sep-07 15:38 
GeneralRe: done! Pinmemberyojiq10-Sep-07 21:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 9 Sep 2007
Article Copyright 2007 by Brett Trotter
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid