Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/16/05 10:10
Read: times


 
#89767 - Lookup Table Character Generator
Responding to: ???'s previous message
Rahul Sadagopan said:
http://www.8052.com/forum/read.phtml?id=89755
I've made my own character generater...and thus made my list of pins to be fired and made the functions...
I have written a function called fire...where i give in the pin numbers...and the function fires them for the required ontime...
so for the char 'H' my funtion is like
H()
{
   fire( pin1,pin2,pin3,pin4,pin5,pin6,pin7);
   fire( oo,  oo,  oo,  pin4,oo,  oo,  oo  ); //oo means pin not fired
   fire( oo,  oo,  oo,  pin4,oo,  oo,  oo  );
   fire( oo,  oo,  oo,  pin4,oo,  oo,  oo  );
   fire( pin1,pin2,pin3,pin4,pin5,pin6,pin7);
}
I really dont get how to go about doing this look up table.


For a start, that's a very inefficient way of passing the required pins to your 'fire' function!
Think about it: each pin can either be fired, or not fired - that should suggest something to you...
Yes, it's a Binary system! Therefore each pin can be represented by a single bit - say, '1' to fire it, '0' not to fire. You have only 7 pins, so you can fit all those pins into a single byte:
void fire( unsigned char pins_to_fire );
and your 'H' function becomes
H()
{
   fire( 0x7F ); // 01111111
   fire( 0x08 ); // 00001000
   fire( 0x08 ); // 00001000
   fire( 0x08 ); // 00001000
   fire( 0x7F ); // 01111111
}
Now we can make a simple lookup table for the columns of this one character, and your 'H' function becomes:
H()
{
   // LOOKUP TABLE
   // Each entry in the table (ie, each element of the array)
   // contains the bitmap of pins to be fired for the particular column;
   // ie, pins_to_fire[x] contains the bitmap of pins to be fired for the column 'x'. 
   unsigned char pins_to_fire[] =
   {
         0x7F,  // 01111111 - the pins to fire for column 0
         0x08,  // 00001000 - the pins to fire for column 1
         0x08,  // 00001000 - the pins to fire for column 2
         0x08,  // 00001000 - the pins to fire for column 3
         0x7F,  // 01111111 - the pins to fire for column 4
   } // pins_to_fire

   fire( pins_to_fire[0] ); // Fire the pins for column 0
   fire( pins_to_fire[1] ); // Fire the pins for column 1
   fire( pins_to_fire[2] ); // Fire the pins for column 2
   fire( pins_to_fire[3] ); // Fire the pins for column 3
   fire( pins_to_fire[4] ); // Fire the pins for column 4
}
OK, so we haven't actually gained much yet, but you should now be able to see the principle of using a lookup table.

The next step is to make a big lookup table that defines all of the characters in your character set.
This will need to be a two-dimensional array - each character has 5 columns of dots:
unsigned char pins_to_fire[NUMBER_OF_CHARACTERS][] =
{
   { // Character 0 - 'A'
      0x7C, // 01111100  - the pins to fire for column 0 of an 'A'
      0x12, // 00010010  - the pins to fire for column 1 of an 'A'
      0x11, // 00010001  - the pins to fire for column 2 of an 'A'
      0x12, // 00010010  - the pins to fire for column 3 of an 'A'
      0x7C  // 01111100  - the pins to fire for column 4 of an 'A'
   },

   { // Character 1 - 'B'
      0x7F, // 01111111  - the pins to fire for column 0 of an 'B'
      0x49, // 01001001  - the pins to fire for column 1 of an 'B'
      0x49, // 01001001  - the pins to fire for column 2 of an 'B'
      0x49, // 01001001  - the pins to fire for column 3 of an 'B'
      0x36  // 00110110  - the pins to fire for column 4 of an 'B'
   },

   etc, etc,...

} // pins_to_fire
and now you can write a simple, generic function to print any character from your defined character set:
void print_character( unsigned char character_number )
{
   fire( pins_to_fire[character_number][0] ); // Fire pins for column 0 of required character
   fire( pins_to_fire[character_number][1] ); // Fire pins for column 1 of required character
   fire( pins_to_fire[character_number][2] ); // Fire pins for column 2 of required character
   fire( pins_to_fire[character_number][3] ); // Fire pins for column 3 of required character
   fire( pins_to_fire[character_number][4] ); // Fire pins for column 4 of required character
}

You will probably want your lookup table to be stored in your code ROM - you will need to read the Manual for your particular compiler (SDCC?) to find out how it does that.

List of 53 messages in thread
TopicAuthorDate
problem with labels            01/01/70 00:00      
   First of all....            01/01/70 00:00      
   Jump to a specific point            01/01/70 00:00      
      Don't Do It!!            01/01/70 00:00      
         DO it!            01/01/70 00:00      
            No, don't!            01/01/70 00:00      
      Same label problem            01/01/70 00:00      
      Message Not Useful?            01/01/70 00:00      
         (-1 Message Not Useful)            01/01/70 00:00      
            Your wish...            01/01/70 00:00      
   break            01/01/70 00:00      
      this is for a printer            01/01/70 00:00      
         Bizarre!            01/01/70 00:00      
            Proportional font?            01/01/70 00:00      
               count columns            01/01/70 00:00      
                  columns?            01/01/70 00:00      
                     intelligent            01/01/70 00:00      
                  line printers            01/01/70 00:00      
                     hit me with a thud            01/01/70 00:00      
                        DP Lineprinters            01/01/70 00:00      
         breaking out of loops            01/01/70 00:00      
   the RETI barrier            01/01/70 00:00      
      The clever 8051 designers!            01/01/70 00:00      
         Clever            01/01/70 00:00      
         Bunch of bull.            01/01/70 00:00      
            RE:Bunch of bull.            01/01/70 00:00      
               Mehdi            01/01/70 00:00      
   Don't start from here            01/01/70 00:00      
   sdcc says unreachable code !            01/01/70 00:00      
      You get rid of it by....            01/01/70 00:00      
      Just don't do it!            01/01/70 00:00      
      Structure            01/01/70 00:00      
      global and local variables            01/01/70 00:00      
         Re:            01/01/70 00:00      
            Give It Up Rahul.            01/01/70 00:00      
            Man @ bottom of hole should stop digging            01/01/70 00:00      
               Man @ bottom of hole            01/01/70 00:00      
                  Stop digging!!            01/01/70 00:00      
                  OK, here it is!            01/01/70 00:00      
                     counting is getting difficult            01/01/70 00:00      
                        Counting should be easy!            01/01/70 00:00      
                           as a starter...            01/01/70 00:00      
                              solved !            01/01/70 00:00      
            Back to Basics            01/01/70 00:00      
      Blinker            01/01/70 00:00      
         need to jump..            01/01/70 00:00      
            Do NOT jump!            01/01/70 00:00      
            Timer            01/01/70 00:00      
   Lookup Table Character Generator            01/01/70 00:00      
      bit based lookup table            01/01/70 00:00      
         Try this:            01/01/70 00:00      
      Character building            01/01/70 00:00      
      Things are working good..            01/01/70 00:00      

Back to Subject List