elusion has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks,
Recently I decided that I would write a peice of software for an LED display I was running. The software that came with it was awful. The software designs (frame by frame) where the dots are lit up.

I decided that I could do much better. So I've started on my new project. I've figured out how to decode the files. I just need to work on GUI and how to create them. I have a few questions.

First... The files sent to the sign (over a modem) are compiled files (right word? it's the funny chars and many boxes). I convert them to hex, where I convert them to binary 4 numbers at a time. I need to know how to get it from a LoL back to the original state.

Next, I need help on the GUI. Is it possible to take fonts and make the output a series of dots? (Does that even make sense?) I have no experience with TK and haven't bought the O'Reilly book yet. I would first like to make sure it's possible.

Thanx for your help,

- p u n k k i d
"Reality is merely an illusion, albeit a very persistent one." -Albert Einstein

Replies are listed 'Best First'.
Re: Design Software for an LED Display
by Albannach (Monsignor) on Jun 11, 2001 at 22:02 UTC
    On the part about taking fonts and turning them into a list of dots, maybe something like this will give you an idea (this is crude). It may take some fiddling to see what fonts and sizes work best, but you can always write out the result to a binary file and display it in your tk interface for a preview (or just print in text as I did below). Converting the getPixel results to the appropriate format for transfer to your display device should be straightforward.
    use strict; use GD; # create a new image my ($width,$height) = (50, 20); my $im = new GD::Image($width,$height); # allocate some colors my $white = $im->colorAllocate(255,255,255); my $black = $im->colorAllocate(0,0,0); # Put a black frame around the picture $im->rectangle(0,0,$width-1,$height-1,$black); # some TTF text: # (colour, font, pointsize, angle, x, y, string) my @bounds = $im->stringTTF($black,'c:/i386/times.ttf',14,0,2,17,'JaPh +!'); if (!@bounds) {print "TTF error: $@\n";} for my $y (0..$height-1) { for my $x (0..$width-1) { print $im->getPixel($x,$y) ? 'X':'.'; } print "\n"; } print "\n";
    For Times, this gives:
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X................................................X X................................................X X................................................X X................................................X X...........................XXX..................X X..XXXXXX........XXXXXXXXX..XXX........XX........X X....XX............XX..XXXX..XX........XX........X X....XX............XX...XXX..XX........XX........X X....XX...XXXXXX...XX....XX..XX.XXXX...XX........X X....XX...XX.XXX...XX...XXX..XXX.XXX...XX........X X....XX...XX..XX...XXX.XXXX..XX...XX...XX........X X....XX.....XXXX...XXXXXXX...XX...XX...XX........X X....XX....XXXXX...XX........XX...XX...X.........X X....XX...XXX.XX...XX........XX...XX.............X X....XX...XX..XX...XX........XX...XX.............X X.XX.XX...XXXXXXX..XX.......XXXX..XXX..XX........X X.XXXX....XXXXXXXXXXXXX.....XXXX.XXXX..XX........X X................................................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Update: Dang, da beat me to it!

    --
    I'd like to be able to assign to an luser

Re: Design Software for an LED Display
by Eradicatore (Monk) on Jun 11, 2001 at 19:40 UTC
    What you are trying to do is very do-able with a Tk application, just to answer your question. And when you talk about "compiled files" I think you really just want to say raw binary data. The display you're probably using just has a decoder IC built in that accepts raw bytes as commands for what to do to the display.

    I've used something similar recently from Matrix Orbital. You should check out the perl code examples from this page:

    Matrix Orbital Examples

    The display I got has a serial port interface, so all I have to do is print bytes out the serial port in the perl program. As for using Tk, the programs that come with Matrix Orbital have a nifty "create your own" character area where you click on buttons (easy to do in Tk with some experience) and those buttons are the actual pixels in the lcd character. So you're really just seeing a blown up version of what will show on the display.

    Anyway, just wanted to share some experiences I have had. Many a home brew mp3 player has used these displays, and its a great project to learn more about perl and Tk! I would not recommend the perl/tk book from Oreilly to learn Tk. I learned from "Programming Tcl/Tk" book actually by Brent Welsh, and was very impressed.

    Justin Eltoft

    "If at all god's gaze upon us falls, its with a mischievous grin, look at him" -- Dave Matthews

Re: Design Software for an LED Display
by the_slycer (Chaplain) on Jun 11, 2001 at 19:20 UTC
    One way of accessing a LoL is like this:
    foreach my $sec_level(@list){ foreach (@$sec_level){ # $_ is now the element in the second level list } }
    I'm not sure that a GUI is the way you need to go with displaying on an LED screen. If you want to convert say "2" to an LED 2 like
    XXXXX X XXXXX X XXXXX
    You might want to take a look at (GOLF) LED Sign for some pointers.
      Ok...

      I knew how to access an LoL (sorry, shoulda made that more clear), just not how to turn it back into the compiled form.

      I want to be able to click on a light and have it go on/off in that frame. It's more complicated than just scrolling text. It uses borders and such as well. Maybe I'll update later with a screenshot later of the current program.

      - p u n k k i d
      "Reality is merely an illusion, albeit a very persistent one." -Albert Einstein

      Update:
      Here's a picture of the current program. I am looking to implement something like the dots you see there. The program allows you to move the dots and create lines/boxes and use fonts.

        Is it possible to take fonts and make the output a series of dots?
        It certainly is. You could use GD or Image::Magick to draw the text in whatever font(s) you like, then read the image pixel by pixel using one of these methods. Take a gander at this or this for some more pixel-by-pixel manipulation info.

        ___
        -DA

Re: Design Software for an LED Display
by Johnny Golden (Scribe) on Jun 11, 2001 at 23:47 UTC
    You wouldn't be trying to hack those annoying road signs by any chance would you? (Because that would be wrong, yet highly amusing! :-))
Re: Design Software for an LED Display
by clintp (Curate) on Jun 11, 2001 at 23:30 UTC
    If you're not hung up on a GUI library, you might want to take a look at the source to a program named "figlet". It's C, but comes with an impressive array of fonts that can be used to generate bitmapped text. You might even be able to just hijack the font files themselves.
Re: Design Software for an LED Display
by Anonymous Monk on Jun 12, 2001 at 17:28 UTC
    >I have no experience with TK...
    You might also want try perl::Gtk!
    Just an idea!