noisybox.net

CrystalFontz 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 
    baud 
    clear
    contrast 
    cursor_style 
    get_hardware
    led  <[red|green]> 
    ping 
    pos_data   
    position  
    reboot
    store_state

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: