Serial Wombat
a general-purpose digital interface device for hobbyists, engineers and students

 


Home
Overview
Protocol
Documentation
Getting Started
Connectivity
Pin Mode SDK Beta
Overview
Rules
Example 1
Example2
Example3
Graphic LCD
LED Display
Sample Projects
Downloads
Contact Us
Purchase
Forum

Did you know...

 

SED1330 256x128 LCD Driver SDK example

All Electronics currently has what is arguably the best hobbiest LCD deal on the net: The LCD shown here for under 20 bucks! Check it out!

The code for this pin mode, along with all of the example files and the lcd converter Windows app are available here. Look for lcd101.bin as the downloadable firmware add-on.


The driver is downloadable to the Wombat via the Xmodem command. This can be initiated from a terminal, but is most easily achieved using the file...xmodem option in the Wombat Panel sample app. Like all add-on apps, it should be downloaded to address 0xC000. This will replace any add-on pack currently in the Wombat. This pack uses flash addresses from 0xc000 to 0xD3FF. Flash space from 0xD3FF to 0xFFFF is available for download of bitmaps (see below).

The driver provides a number of relatively simple serial commands which are translated into low-level commands to the LCD. Among the available commands:

  • Draw or clear a pixel at given coordinates
  • Draw or clear a line
  • Draw or clear a rectangle outline
  • Draw or clear a filled rectangle
  • Draw or clear a circle outline
  • Place text on the display
  • Load a bitmap picture which has previously been downloaded to the Wombat's flash memory

Thanks to Duane Becker who published the initialization sequence used in this code. Find his page at http://www.sover.net/~snowleop/gdisp3/init.txt

LCD 101 uses 17 pins. Unlike many Wombat modes, eight of the Wombat pins are at fixed numbers, rather than being configurable. Four of the pins can be connected to any of the remaining Wombat pins:

Pin #   Function
1   Ground
2   Ground
3   + 5 volts
4   LCD voltage. Should be around -10 volts. This LCD is very picky with regard to the voltage on this pin if you're going to see anything. The recommended voltage on this pin will vary with variations in the +5 supply and with temperature. See the LCD datasheet for more information. I used A 12V battery and attached + to the ground of my circuit, then ran it into one side of a 10k pot. I ran the wiper to the LCD, and adjusted until the voltage matched up. Note that this will only work if the pot is sized in proportion to the current draw. A 10 ohm pot wouldn't work.
5   Reset Signal. Goes to a Wombat Pin
6   Read Signal. Goes to a Wombat Pin
7   Write Signal. Goes to a Wombat Pin. The Wombat pin which is connected to the Write signal on the LCD is the pin which should be configured for LCD 1330 control mode.
8   Chip Select. Connect this Pin to ground
9   A0 pin. Goes to a Wombat Pin.
10   Data pin. Goes to Wombat Pin 19
11   Data pin. Goes to Wombat Pin 20
12   Data pin. Goes to Wombat Pin 21
13   Data pin. Goes to Wombat Pin 22
14   Data pin. Goes to Wombat Pin 27
15   Data pin. Goes to Wombat Pin 28
16   Data pin. Goes to Wombat Pin 29
17   Data pin. Goes to Wombat Pin 30

Most commands provided with this module do all of their work when the command is received. This differs from many Serial Wombat Pin modes which do most of their work through being serviced each frame. Some commands, such as the initial setup command may take a few milliseconds to complete. During this time other pins will not be serviced, so care should be taken if millisecond response time is required by other pins.

There are a number of commands which drive the LCD. The only required command is the 200 initialization command. It must be sent before any other commands.

Data Sent to the Wombat: 200 Pin # 0xF0 Read Pin A0 Pin Reset Pin 0x55 0x55
Meaning: Configure Pin First message Wombat Pin Number Connected to the LCD Write pin First Add - on Command The Wombat Pin Number connected to the LCD Read Pin The Wombat Pin Number connected to the LCD A0 Pin The Wombat Pin Number connected to the LCD Reset Pin Unused Unused
This message is echoed back by the Wombat.

Message 201 allows the Wombat to continuously copy data from the Wombat's internal User Ram to the text area. This can be useful for testing and with other pin modes capable of putting strings into User Ram. However, this LCD exihbits flicker when continuously updated, which the user may find unacceptable. The string is 384 characters long (32 characters wide by 16 characters long).

Data Sent to the Wombat: 201 Pin # 0xF0 State User Ram Address High Byte User Ram Address Low byte 0x55 0x55
Meaning: Configure Pin Second message Wombat Pin Number Connected to the LCD Write pin First Add - on Command 0 - Update paused

1- Update active

Address in User Ram where the string to be copied is located. Unused Unused
This message is echoed back by the Wombat.

Message 202 provides a number of different drawing commands. The figure to be drawn depends on the 4th byte. The 5th through 8th byte are parameters to that figure. Typically, odd numbered commands draw black figures, and even numbered commands draw white figures. In order to keep the code size as small as possible, some error checking is left to the host. For example, drawing a line which extends off of the visible screen will cause problems. Similarly, the first coordinate for a rectangle must be the upper-left-hand corner, and the second must be the lower-right-hand corner. X=0, Y=0 is the upper left hand corner. The X coordinate ranges from 0 to 255, and the Y coordinate ranges from 0 to 127.

Data Sent to the Wombat: 202 Pin # 0xF0 Shape: Single Pixel X Coordinate Y Coordinate 0x55 0x55
Meaning: Configure pin third message Wombat Pin Number Connected to the LCD Write pin First Add - on Command 0: Draw a white pixel
1: Draw a black pixel
X Coordinate of the pixel (0 to 255) Y Coordinate of the pixel (0 to 127) Unused Unused
This message is echoed back by the Wombat.

 

Data Sent to the Wombat: 202 Pin # 0xF0 Shape: Line X1 Coordinate Y1 Coordinate X2 Coordinate Y2 Coordinate
Meaning: Configure pin third message Wombat Pin Number Connected to the LCD Write pin First Add - on Command 2: Draw a white line
3: Draw a black line
X1 Coordinate of the Line (0 to 255) Y1 Coordinate of the Line (0 to 127) X2 Coordinate of the line (0 to 255) Y2 Coordinate of the line (0 to 127)
This message is echoed back by the Wombat.

 

Data Sent to the Wombat: 202 Pin # 0xF0 Shape: Filled Rectangle Upper Left X Coordinate Upper Left Y Coordinate Lower Right X Coordinate Lower Right Y Coordinate
Meaning: Configure pin third message Wombat Pin Number Connected to the LCD Write pin First Add - on Command 4: Draw a white Filled Rectangle
5: Draw a black filled Rectangle
Upper Left XCoordinate of the Rectangle (0 to 255) Upper Left Y Coordinate of the Rectangle (0 to 127) Lower Right X Coordinate of the Rectangle (0 to 255) Lower Right Y Coordinate of the Rectangle (0 to 127)
This message is echoed back by the Wombat.

 

Data Sent to the Wombat: 202 Pin # 0xF0 Shape: Outline Rectangle Upper Left X Coordinate Upper Left Y Coordinate Lower Right X Coordinate Lower Right Y Coordinate
Meaning: Configure pin third message Wombat Pin Number Connected to the LCD Write pin First Add - on Command 6: Draw a white Outline Rectangle
7: Draw a black Outline Rectangle
Upper Left XCoordinate of the Rectangle (0 to 255) Upper Left Y Coordinate of the Rectangle (0 to 127) Lower Right X Coordinate of the Rectangle (0 to 255) Lower Right Y Coordinate of the Rectangle (0 to 127)
This message is echoed back by the Wombat.

 

Data Sent to the Wombat: 202 Pin # 0xF0 Shape: Outline Rectangle Upper Left X Coordinate Upper Left Y Coordinate Lower Right X Coordinate Lower Right Y Coordinate
Meaning: Configure pin third message Wombat Pin Number Connected to the LCD Write pin First Add - on Command 6: Draw a white Outline Rectangle
7: Draw a black Outline Rectangle
Upper Left XCoordinate of the Rectangle (0 to 255) Upper Left Y Coordinate of the Rectangle (0 to 127) Lower Right X Coordinate of the Rectangle (0 to 255) Lower Right Y Coordinate of the Rectangle (0 to 127)
This message is echoed back by the Wombat.

 

Data Sent to the Wombat: 202 Pin # 0xF0 Shape: Outline Circle Center X Coordinate Center Y Coordinate Radius In Pixels 0x55
Meaning: Configure pin third message Wombat Pin Number Connected to the LCD Write pin First Add - on Command 8: Draw A White Circle outline
9: Draw A Black Circle Outline.
Center X Coordinate of the Circle (0 to 255) Center Y Coordinate of the Circle(0 to 127) 0 to 63. Circle cannot extend off of screen. Unused
This message is echoed back by the Wombat.

Here's an example created using the line commands (for the asteriod thing) and the circle command, along with the put text command (205) below. The commands to do this are listed in the command script lcd101test.wbt in the zip file above.

 

Message 203 is used to load a bitmap which has been previously downloaded into flash using the Xmodem command. The bitmap format is as follows:

1st -byte: X width of the bitmap in pixels. Must be divisible by 8.
2nd-byte: Y length of the bitmap in pixels.
3rd-byte: Whether bitmap is compressed. 0: No compression. 1: Run-Length compression (see format below).
Remainder of bytes: Data. If uncompressed, this should be X * Y / 8 bytes. Bytes start at the upper left corner and scan horizontally then vertically to the lower right hand corner. 1 bits are black, 0 bits are white. The Most Significant bit of each bit is the leftmost of the 8 pixels.

Compressed data is compressed using run-length encoding. The RLE escape value is 0x15. The decompression algorithm starts with the first data byte. If it is not the RLE escape value, then the value is plotted to the LCD. If it is the escape value, then the next byte is the number of repetitions minus 1, and the following byte is the value to be repeated. For example:

0x15 0x05 0x00 would result in a decoding of 6 0x00 bytes.

RLE generally works best on graphics which contain streams of the same color pixel. A stream of at least 32 consecutive black or white pixels is necessary to achieve compression. Since the RLE character 0x15 is used for compression, representing a single data byte of 0x15 results in three bytes being used (translated into english, the following string means "Data 0x15 repeated 1 time")

0x15 0x00 0x15

Graphics which contain 0x15 data values but few or no compressible streams may result in "compressed" files which are larger than "uncompressed" files. Typically, uncompressed is best for dithered photos, while compressed is best for line art, graphics, and logos.

 

Data Sent to the Wombat: 203 Pin # 0xF0 Bitmap flash address high byte Bitmap flash address low byte Screen coordinate X for upper left corner Screen coordinate Y for upper left corner Unused
Meaning: Configure pin fourth message Wombat Pin Number Connected to the LCD Write pin First Add - on Command 16 bit flash address into which the bitmap was previously loaded. For the 18F4620 based Serial Wombat this will be somewhere between 0xC000 and 0xFFFF. 0 to 248 (must be divisible by 8) 0 to 127  
This message is echoed back by the Wombat.

Here's a couple of bitmaps, both contained in the zip file above:

The Paris one took up 4.0k uncompressed, and 3.89 compressed. The Wombat logo took up 4.0k uncompressed, and 1.8k compressed. The large sections of all white in the wombat pic make for good run-length compression.

I created the downloadable files with a crummy C# .net application I wrote. Basically, you press a button and give it a .bmp file and it pops out a compressend and uncompressed file ready for downloading to the Wombat with Xmodem. This app is also in the zip file above. It's super slow because it makes a bunch of function calls per pixel, but it works. It expects a BMP which is black and white, and 2 to 128 pixels long, and 8 to 256 pixels wide. The width will be automatically padded to a multiple of 8 if necessary.

Commands 204 and 205 are used to place text directly on the screen. These commands can be used instead of the 201 command and have two advantages: they don't cause noticable screen flicker, and they don't require the use of the Wombat's internal user RAM.

Command 204 sends 1 text character to the screen at a given address. Command 205 sends three text characters.

Data Sent to the Wombat: 204 Pin # 0xF0 Text location high byte Text Locaiton Low byte Character to place at that location 0x55 0x55
Meaning: Configure pin fifth message Wombat Pin Number Connected to the LCD Write pin First Add - on Command Values 0 to 511 fall on the screen. 32 characters per line. 0 to 255 Unused Unused
This message is echoed back by the Wombat.

 

Data Sent to the Wombat: 205 Pin # 0xF0 Text location high byte Text Location Low byte Character to place at that location Character to place at location + 1 Character to place at location + 2
Meaning: Configure pin fifth message Wombat Pin Number Connected to the LCD Write pin First Add - on Command Values 0 to 511 fall on the screen. 32 characters per line. 0 to 255 0 to 255 0 to 255
This message is echoed back by the Wombat.
 

Copyright Wombat Interface Products, 2005-2008. All Rights Reserved.