??? 12/19/08 04:37 Read: times |
#161048 - Simple Table Lookup Responding to: ???'s previous message |
This is a simple table lookup problem. Assign one bit in each byte of the table entry to be for a segment of the display. I think you were already trying to drive to that in the part you showed. Skip the DP as part of the entry into the table so only 7-bits per entry are needed for segment data. (You handle the DPs outside the digit lookup anyway with separate code partly because you may want something with or without a DP and not wanting the segment data to change). Use the now "extra" bit to indicate when an entry in the table does not encode to a valid display pattern.
Arrange the entries in your table in ASCII order start the table with the entry for '0'. To find a character in the table, take its ASCII value and subtract '0' from it (0x30) to make a zero based index. Add this insdex to the base address of the table to find the entry in the table. If in C the table is an array of unsigned char and the index is used as the [index] subscript of the array. (The compiler takes care of the add for you. :-) Here is the layout for the whole table. Notice that the value of '9' is only a short way from 'A' and so just put dummy entries in the table and mark the extra bit to show invalid. --- Complementary XLS Image --- Michael Karas |
Topic | Author | Date |
Looking for a fast elegant solution to an SAA1064 | 01/01/70 00:00 | |
several ways | 01/01/70 00:00 | |
Simple Table Lookup | 01/01/70 00:00 | |
Constructing the table symbolically | 01/01/70 00:00 | |
That looks like it will do the trick | 01/01/70 00:00 | |
Ok I'm here now....... | 01/01/70 00:00 | |
first convert to decimal, then to ASCII | 01/01/70 00:00 | |
So... | 01/01/70 00:00 | |
Keep track of binary/BCD/hex/ASCII | 01/01/70 00:00 | |
Final answer and it works | 01/01/70 00:00 | |
But '0' - 0x30 is zero :)![]() | 01/01/70 00:00 | |
not exactly | 01/01/70 00:00 |