CrystalFontz 635 in Perl

crystalfontz in perl

Last updated Nov 25th, 2007.

About:

This little hack is my own implementation of the CrystalFontz seral packet protocol in the Perl language. This program can be used to talk to the 635 (and 633?) CrystalFontz LCD modules over an RS232 (seral port) link. It can be used in an interactive fashion to poke at a device, and it can probably also be used to script/automate LCD tasks (thought I wouldn't recommend it).

This project came about by my desire to program the power-up boot message into the CF-635 mounted inside my audiopint setup. Instead of waiting for LCDProc to start up as a daemon during boot to replace the default CrystalFontz screen, I opted to have a more relevant message displayed while the system boots.

As usual, I'm probably reinventing the wheel here. There are certainly several other Perl implementations out in the wild, but again, none of them really did what I had hoped, so I built my own. As it turns out, the Perl CRC implementation in the 635 PDF specification itself doesn't work correctly, so I set out to make my own. The work presented here was created entirely from the 635 specification.

Features:

This is not a full implementation of the 635 packet protocol specification. This simple hack does, however, support the following features:

Download:

This software is made available as-is to the public domain without any warranty of support or claims of operability. Please download, redistribute, sell, modify, and improve this code as you will:

Usage:

Invoke the app as "perl crystalfontz.pl" or chmod 0744 and run it directly.

Note: The default port is /dev/ttyS1 and the default baud is 115200. If this does not match your setup, you must edit the script and change the appropriate configuration items.

When the application starts, you'll be given a prompt that looks like this:
lcd >

Enter commands one line at a time. To exit, type "quit". For additional help about available commands, type "help" (or simply '?'). This will display a screen like this:

Perl interface to CrystalFontz 635
by jason plumb (jason@noisybox.net)

Commands:
    backlight <value[0-100]>baud <rate(115200|19200)>clear
    contrast <value[0-255]>cursor_style <style[0-4]>get_hardware
    led <led index=""><[red|green]> <state>ping <text_data>pos_data  <row><string_data>position <x><y>reboot
    store_state</y></x></string_data></row></text_data></state></led></style[0-4]></value[0-255]></rate(115200|19200)></value[0-100]>

Please note that all commands are line-based and parameters are then space separated. If you find a bug/problem or make a patch/improvement, please let me know.

Todo:

Of course, there's always room for improvement. Because this program has been built to suit my somewhat specific needs, it is doubtful that I will do significant additional development on this hack. With that in mind, here's a brief list of things that could be improved and ways that this utility could generally be made more useful: