Forum Index > Projects > Micro-readerboard project support
 Font table help
 |  Printable Version
By: theyallhateme (offline) on Wednesday, December 14 2011 @ 05:29 PM PST (Read 2934 times)  
theyallhateme

Let me start by saying that I'm a noob to programming. I've only been tinkering with my Arduino for about a year.

I bought some display boards, battery holders, and a USBtinyISP. Paired with some attiny2313V-10PU's, I'm up and running on the breadboard! (This is probably more exciting to me than it should be).

Now I'm in the tweaking phase. Using the tech sheet, I was able to change the "A" font into a more classic, readable style. I also added the spinning clock hack (even though I don't know how he got those codes, lol).

Anyway, what I'd like to do now is add numbers to the font table so I can add dates to quotes; but I don't really understand how the the decimal values correspond to what's been typed in the string. I've already decoded what the decimal value should be for each digit. I tried tacking them to the end of the code, in the style of the spinning clock or the asterisk, but got an "out of range" error when I tried to compile it. Any ideas or suggestions? Or has someone already added digits to the code and would like to share? Thanks!


Forum Apprentice
Apprentice


Status: offline

Registered: 12/13/11
Posts: 3

Profile Email    
   
By: Windell (offline) on Thursday, December 15 2011 @ 11:12 AM PST  
Windell

Now I'm in the tweaking phase. Using the tech sheet, I was able to change the "A" font into a more classic, readable style.

So it sounds like you have the basic idea of translating between the data tables and the display already.

I presume that you're using the "newer" version of the code from here:
http://www.evilmadscientist.com/source/LED_MRB2.1.zip

Anyway, what I'd like to do now is add numbers to the font table so I can add dates to quotes; but I don't really understand how the the decimal values correspond to what's been typed in the string.

What you'll probably want to do is add the ten characters to the font_table.

The way that the character decoding works is by using an ascii table-- the character 'A' corresponds to decimal 65, so we subtract 'A' from each character to find its position in the array called font_table. If the character that we want to display is an 'A', then we take 'A' - 'A' = 0, so the first element of font_table, font_table[0]. If our character is a 'C', then 'C' - 'A' - 2, so we take font_table[2] to find the next element. There are also special cases for the couple of symbols that are supported. If you add characters to the font table, you'll need to also add a case for decoding them in that section.

Regarding the out of range, that could be where you tried to retrieve an element beyond the limits of a matrix, or perhaps you ran out of memory on the device.


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: theyallhateme (offline) on Thursday, December 15 2011 @ 08:44 PM PST  
theyallhateme

Quote by: Windell

I presume that you're using the "newer" version of the code from here: http://www.evilmadscientist.com/source/LED_MRB2.1.zip



Ooops, I was using an older version. Updated to 2.1 now.

Unfortunately, still getting an error. Here's what I did:

PHP Formatted Code
const unsigned int font_table[] PROGMEM =
{
51609,63940,12689,              //A,B,C
47556,12697,16793,              //D,E,F
31121,51225,12740,              //G,H,I
47105,1561,12305,               //J,K,L
35377,35889,47505,              //M,N,O
49561,48529,50585,              //P,Q,R
31128,452,47121,                //S,T,U
531,35859,1570,                 //V,W,X
548,13186,                              //Y,Z
18030,                                  //Asterisk ('*') character.
514,                                            //Forward slash ('/') character.

48019,                          // 0
34816,61833,63872,              // 1,2,3
51224,13720,31129,              // 4,5,6
35200,63897,63896               // 7,8,9

};
 



and also

PHP Formatted Code
        if (buf[i] == ' ')
                        FontWord = 0;
                else if (buf[i] == '*')
                        FontWord = (uint16_t)pgm_read_word(&font_table[26]);
                else if (buf[i] == '/')
                        FontWord = (uint16_t)pgm_read_word(&font_table[27]);
               
                else if (buf[i] == '0')
                        FontWord = (uint16_t)pgm_read_word(&font_table[28]);
                else if (buf[i] == '1')
                        FontWord = (uint16_t)pgm_read_word(&font_table[29]);
                else if (buf[i] == '2')
                        FontWord = (uint16_t)pgm_read_word(&font_table[30]);
                else if (buf[i] == '3')
                        FontWord = (uint16_t)pgm_read_word(&font_table[31]);
                else if (buf[i] == '4')
                        FontWord = (uint16_t)pgm_read_word(&font_table[32]);
                else if (buf[i] == '5')
                        FontWord = (uint16_t)pgm_read_word(&font_table[33]);
                else if (buf[i] == '6')
                        FontWord = (uint16_t)pgm_read_word(&font_table[34]);
                else if (buf[i] == '7')
                        FontWord = (uint16_t)pgm_read_word(&font_table[35]);
                else if (buf[i] == '8')
                        FontWord = (uint16_t)pgm_read_word(&font_table[36]);
                else if (buf[i] == '9')
                        FontWord = (uint16_t)pgm_read_word(&font_table[37]);

                else
                        FontWord = (uint16_t)pgm_read_word(&font_table[buf[i] - 'A']);
                        //Note: The ASCII char 'A' is element 0 of the font table.



Using the above, I get:

PHP Formatted Code
avrdude: ERROR: address 0x0810 out of range at line 129 of mrb.hex
avrdude: write to file 'mrb.hex' failed
 



Any suggestions?


Forum Apprentice
Apprentice

Status: offline

Registered: 12/13/11
Posts: 3

Profile Email    
   
By: Windell (offline) on Friday, December 16 2011 @ 12:49 PM PST  
Windell

You may have exceeded the available flash space. Try reducing the number and/or length of text strings, to see if that fixes it.

Also, your digit cases are *way* too complicated. Maybe try something like this, to save *a lot* of flash space.


PHP Formatted Code
  if (buf[i] == ' ')
                        FontWord = 0;
                else if (buf[i] == '*')
                        FontWord = (uint16_t)pgm_read_word(&font_table[26]);
                else if (buf[i] == '/')
                        FontWord = (uint16_t)pgm_read_word(&font_table[27]);
                else if (buf[i] <= '9')
                        FontWord = (uint16_t)pgm_read_word(&font_table[buf[i] - 20]);
                else
                        FontWord = (uint16_t)pgm_read_word(&font_table[buf[i] - 'A']);


Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Forum Evil Scientist
Evil Scientist

Status: offline

Registered: 06/15/06
Posts: 1932
Sunnyvale, CA

Profile Email Website  
   
By: theyallhateme (offline) on Friday, December 16 2011 @ 01:29 PM PST  
theyallhateme

That streamlined digit case did the trick. I used that without removing any strings, and it worked. I had a feeling I was doing it wrong, because it was too easy. Razz

Thanks for all of your help!


Forum Apprentice
Apprentice


Status: offline

Registered: 12/13/11
Posts: 3

Profile Email    
   



 All times are PDT. The time is now 09:13 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
Filtered HTML Allowed 
Censored Content 

Evil Mad Scientist Forum Archives — Read only!

Please visit our new forums for new discussions.


DIY Hardware for Electronic Art


The Original Egg-Bot Kit


Octolively
Interactive LED kits


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits

My Account






Lost your password?