Scrolling LEDs

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]

 

Search

Search WWW

Search DelphiForFun.org

As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.

 

Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 

     

We receive a few cents from each purchase.  Thanks

 


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa 365 Puzzlers  Calendar 2017

Mensa 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)

Contact

Feedback:  Send an e-mail with your comments about this program (or anything else).

Search DelphiForFun.org only

 

 

 

Problem Description

Here's a program to simulate those scrolling LED signs commonly seen at Burger King and other favorite watering holes.

 

Background & Techniques

The idea for this program actually popped into my head last week while browsing the July issue of Nut and Volts - a gadgeteers electronic magazine.   One article there is "Build this Scrolling LED Clock".  " Well, we can do that without any extra hardware" thinks  I.  And we could.    

First, how to get the fonts?  I spent an hour or so searching for existing fonts without much luck.  Defining the shapes for numerals 0-9 by hand wouldn't be too bad, but I decided I wanted to  the full "Burgerking" experience.  I spent a day programming down a dead end path using the Tcanvas Textout procedure to write text onto a bitmap and then digitizing LED sized chunks - if more than half of the pixels are black, call the LED on, otherwise off.  The result was very, very  ugly.   Character lines and curves just don't line up with LED boundaries well enough to make this approach feasible.  So back to the drawing board.     

Several font files are included with the LEDSign download.   A couple have an extra carriage return  character at the end of each line which prevents them from loading properly in my program.  I wrote a little program to remove these extra characters.   Corrected font files  (prefixed with "Fixed") are included with the downloads below.  The File FixUp   program used is described and available here. 

Actually back to the web - this time I found two downloadable programs LEDSign - a Java app that displays scrolling LED signage, and  LEDFont - a program to convert TrueType fonts to LED font files in a format usable by LEDSign.   The font files generated by LEDFont and used by LEDSign are plain text and straightforward so I decided to use their format.  (For some reason, probably historical, they don't allow for defining a space  character, so I ended up generating that character in the program at font load time. ) 

The program itself is not too complex - about 300 lines of user code -  we'll call it Intermediate.   I included controls to let the user set the message text and  font,  and LED size and colors.  A TLEDChar record type defines a single character - it contains the Charwidth integer variable and a doubly dimensioned dynamic array of bytes (rows and columns of the LED image and  with 0 = off and 1= on).  A Chars array contains TLEDChar records for all 256 possible characters.  Undefined characters can be identified by a 0 CharWidth value.   The LoadFont procedure loads the Chars array from a font file selected by the user. 

Characters are generated in a temporary bitmap and then copied to a TImage for display. The  DrawLED function generates a specified character in the bitmap starting at a specified location.

Once the LED message is built, Copyrect is used to copy it to the visible TImage.  Now we need to scroll it.    A loop is used to copy the rightmost part of the bitmap (from starting position that increases by 1 LED each time through) to the  leftmost part of the image.  Then the un-copied leftmost part of the bitmap is copied to the rightmost part of the image.  This gives the illusion that the message is scrolling left.    A user controllable speedbar sets the milliseconds to delay between images.  

Addendum Feb. 21, 2003: A new version posted today incorporates a couple of changes made as a result of users' requests.    A new tabsheet now allows date/times in various formats to be displayed.  And messages may now optionally be displayed in a separate resizable window.    From the programmer's point of view, the tricky part was finding how to display tabsheet tabs "grayed out" when the control is disabled.  It does not happen automatically as with most controls.    An OnDrawTab exit from the TPageControl did handle it though.  

Addendum April 16, 2004:  An instructor teaching English in China is using Scrolling LEDs to present new vocabulary and prompted today's update.  He asked that program settings be preserved from  run to run, which seemed like a good idea to me.  So now font and screen information is saved for each run restored when the program is next started (In a text file named LEDS.ini).    

Addendum September 7, 2004:  The same fellow who prompted the April 16 changes wondered if it would be feasible to add a "countdown" timer so he he keep track of the time remaining before his tour of duty is up.  Today's change implements that feature.  Symbols &dt and &ct can be inserted in message text to include current date and countdown time respectively.  Separate tab pages define the format for date and countdown time time fields.   .   

Running/Exploring the Program 

Note:  The single font I generated using the LEDFont program is named arial.led and is the default font. Fonts copied from the LEDSign download have a .font suffix and several are also included.  

bulletBrowse source extract
bulletDownload source (includes font files)
bulletDownload  executable (includes font files)

Suggestions for Further Explorations

Add images to fonts.  Any unused character could be used define an image in a font file.   
(Jan 04, 2003 -Done). Oh yeah -- I never did get around making the scrolling clock described in the article that started this project.
A TLEDSign component (or at least a class object) should  be defined to encapsulate the building and drawing logic. 

 

Created: July  17, 2001

Modified: July 29, 2017

 

 
  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright 2000-2017, Gary Darby    All rights reserved.