NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » LED Scrolling display

July 26, 2010
by ermias
ermias's Avatar

Hi Rick, I was trying to add some characters in font.h file. Actually i already modified the font.h file to add more characters. My problem is how to display them. can you Please help me out? I am new for c.

To make my question clear: for example in my font.h file i have a character called 'Al' that represent some kind of drawing. The array reads as follow:

const char font_2[ ] PROGMEM = { 'A1', 4, 0x1f, 0x10, 0x10, 0x1f, 0x00 };

so i want to display this drawing in my LED board using your scrolling function as follow:

scroll_display(PSTR("A1 "));

However, i couldn't do that because your scroll_display function takes one character at a time and compare that character with the characters in font.h file. As a result my LED board will display A and 1 instead of the drawing. I think there should be a way to make the font_get() and the font_display() functions to take two characters at a time instead of one. I have tried different ways and did succeed. Can You please give me a hint or help me modify the code.

Thanks,

Ermias

July 26, 2010
by hevans
(NerdKits Staff)

hevans's Avatar

Hi Erminas,

The led array code does a linear search through the font table to find the next character to display. If you want to mark characters as multi-character strings, you will run into a problem. What do you do when you actually want to display an "A" then a "1"? You could come up with a complicated solution for this, but there is a quick work around with our particular implementation. Remember how the font table only has capital letters defined. Well this allows us to use lower case characters as whatever we want. We have already highjacked the z, and a few other lower case letters, but you can use the other ones to define custom characters. Hope that makes sense!

Humberto

July 26, 2010
by ermias
ermias's Avatar

Hi Humberto,

Thank you for the quick response. I already used the lower case characters to display lower cases on my board. I just need to know how can i make the Font_get() function to take two characters at a time and search through the font table to find the next character to display. My ultimate goal is to represent every character to be displayed as a multi-character. for example the character A can be represented as .A, or a 1 can be represented as .1 or a character B can be represented as .B

Therefore all my single characters can be represented as: . character

To make my question more clear let me show you how i represent characters in my font.h :

const char font_1[ ] PROGMEM = { '.A', 4, 0x1e, 0x05, 0x05, 0x1e, 0x00 };

const char font_2[ ] PROGMEM = { 'A1', 4, 0x1f, 0x10, 0x10, 0x1f, 0x00 };

const char font_3[ ] PROGMEM = { 'A2', 5, 0x1f, 0x10, 0x10, 0x1f, 0x04 };

const char font_9[ ] PROGMEM = { '.B', 3, 0x1f, 0x15, 0x0a, 0x00, 0x00 };

const char font_35[ ] PROGMEM = { '.1', 3, 0x11, 0x1f, 0x10, 0x00, 0x00 };

As you can see i don't have any single character representation. so i really don't need to worry about those problems you mentioned in your response.

so my question is how can i make the font_display and font_ get functions to read two characters at a time and search through the font array to display the corresponding character on my LED board.

Thanks again,

Ermias

July 26, 2010
by Rick_S
Rick_S's Avatar

Is the reasoning behind this so you can have multiple fonts in a single file? Sorry I'm a little late... I've been a bit busy and just noticed. I'm just trying to see what your goal is.

July 26, 2010
by Rick_S
Rick_S's Avatar

Here's my thought on your question. If you are wanting to have 3 different character sets like .A, A1, A2 you could create a parsing function that would look at the 2 digit character and then shift it by x to read the next set. You should be able to use 255 different characters so depending on what characters you want to display you could get a few different fonts (52 upper/lower case + 0-9 =62 + maybe 10 punctuation = 72 per font) you could get 3 different sets with 216 characters used.

I don't know if that was too confusing but I'm kinda thinking out loud. Of course all this is based on my assumption that you are wanting to use different character sets in the same font file.

Rick

July 26, 2010
by ermias
ermias's Avatar

Hi Rick,

Thank you for taking your time to answer my question. as i mentioned earlier i am new for c. I never have any experience with programming language c. what i want to do in this project is that when i call the scroll_display(PSTR( )) function i want the font_get() function to read two characters at a time and search through the font table to display the corresponding character on my LED board.

for example when i call the scrolling function as:

scroll_display(PSTR(".H.A.P.P .B.I.R.T.H.D.A.Y "));

the final display should read as :

HAPPY BIRTHDAY

my reasoning for representing one character by two characters (for example in the above example H is represented by .H) is to increase the number of characters in the font table.

In my font table the characters A to Z are represented as .A to .Z which means if I want to display the character A in my LED display board i need to call the scrolling function as scroll_display(PSTR(".A ")); the same way all lower case letters are also represented as .a to .z This is true for the numbers too (.0 to .9)

By doing so i can add any thing i want by combining two characters together.

For example if i want to add a heart shape drawing in my font table i can represent that shape by A1

Therefore when i call the scrolling function as scroll_display(PSTR("A1 ")); i should be able to see the heart drawing in my display board.

I am not sure if this clarify my question better.

Thanks again,

Ermias

July 27, 2010
by Rick_S
Rick_S's Avatar

OK, If you aren't wanting to use more than one font, the easy way is to assign different values to your "Special" characters. For example, last Holiday season, I wanted a Christmas tree (kinda looked funny on a 5 pixel tall display, but I digress). I simply assigned a character that wasn't used in the original file.

As I stated in my prior post, there are 256 (0 thru 255) possible characters to choose from in a "char" variable type. That is the maximum you can have in your font file.

To add a special character, I just added another single digit character to the font file. I think I used a degree symbol "°". To get those characters, press and hold ALT then press the 4 digit decimal representation of the ascii value (for for the degree it's ALT 0176). Now you won't be able to do all 255 characters that way some (especially the lower numbers) are special functions but anything over 30 should be safe.

The other thing to keep in mind, is that every new character you add to your font table will take away from your available program memory on the chip. This is because the table is store in program memory.

What you want to do with double characters, while not impossible, would take a huge undertaking with the program as it's originally written. Adding single digit specials and keeping them to a minimum is much easier.

One last thing, I too am still pretty green in the world of C programming. While I've messed around with computers and electronics since the early 80's, I never really seriously delved into the world of C until my NerdKit. So if anything I stated proves to be incorrect, I apologise upfront.

Rick

July 27, 2010
by ermias
ermias's Avatar

Thanks Rick, I will tray your way and let you know what's up.

Thanks again,

Ermias

Post a Reply

Please log in to post a reply.

Did you know that you can build a giant scrolling LED array with our microcontroller kit? Learn more...