Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to access two dimentinal arraies which hold ASCII code,

Status
Not open for further replies.

10043

MIS
Dec 7, 2008
1
0
0
i have written the following code i have used two dimentinal arries and i want each of the letters in ASCII code to be accessed as they are required by the print funtion. this program is used for an LCD i want to write in print funtion and want the outcome to be displayed in LCD. i dont think if im in the right track please help me.

thanks



char PRTFuntion (unsigned char*)
{
int CHARlength = 8;
char LCDByte = 0;
for ( int LCDPage = 0 ; LCDPage <=3; LCDPage++) // going through the 4 pages of the
{

for (int columnAD=0; columnAD<=79; columnAD++)
{
outportb (CONTROLLATCH,0x04);
outportb (CONTROLLATCH,0x05);
outportb (CONTROLLATCH,0x04);
}

outportb (DATALATCH, LCDByte);

for ( int LCDByte=0; LCDByte<=5; LCDByte++)
{
CHARlength++;
}

}


char ASCII[27][6] =
{
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // space
{0x1E, 0x68, 0x88, 0x68, 0x1E, 0x00 }, // 41 A
{0xFE, 0x92, 0x92, 0x92, 0x6C, 0x00 }, // 42 B
{0x38, 0x44, 0x82, 0x82, 0x44, 0x00 }, // 43 C
{0xFE,0x82, 0x82, 0x44, 0x38, 0x0 }, // 44 D
{0xFE,0x92, 0x92, 0x92,0x92, 0x00}, // 45 E
{0xFE, 0x90,0x90, 0x80, 0x80, 0x00 }, // 46 F
{0x38, 0x44,0x82, 0x82, 0x8A, 0x00}, // 47 G
{0xFE, 0x10,0x10, 0x10, 0xFE, 0x00}, // 48 H
{0x82,0x82, 0xFE, 0x82,0x82, 0x00 }, // 49 I
{0x4, 0x2, 0x2,0x82,0xFE, 0x00}, // 4a J
{0xFE, 0x10, 0x28, 0x44,0x82, 0x00},// 4b K
{0xFE,0x2, 0x2, 0x2, 0x2, 0x00}, // 4c L
{0xFE, 0x40, 0x20, 0x40, 0xFE, 0x00}, // 4d M
{0xFE,0x40, 0x38, 0x4, 0xFE, 0x00}, // 4e N
{0x38, 0x44, 0x82, 0x44,0x38, 0x00}, // 4f O
{0xFE, 0x90, 0x90, 0x90, 0x60, 0x00}, // 50 P
{0x38, 0x44, 0x82, 0x44, 0x38, 0x00}, // 51 Q
{0xFE, 0x90, 0x98, 0x94, 0x62, 0x00}, // 52 R
{0x064, 0x92, 0x92, 0x92, 0x4C, 0x00}, // 53 S
{0x80, 0x80, 0xFE, 0x80, 0x80, 0x00}, // 54 T
{0xFC, 0x2, 0x2, 0x2,0xFC, 0x00}, // 55 U
{0xE0, 0x1C, 0x2, 0x1C, 0xE0, 0x00}, // 56 V
{0xFE, 0x4, 0x8, 0x4, 0xFE, 0x00}, // 57 W
{0x82, 0x6C, 0x10, 0x6C, 0x82, 0x00}, // 58 X
{0x80, 0x40, 0x3E, 0x40, 0x80, 0x00}, // 59 Y
{0x86, 0x8A, 0x92, 0xA2, 0xC2, 0x00}}; // 5a Z
}
 
Maybe something more like this would get you to the character you want. (Ignoring the controllatch bytes, I am not fluent on the handshaking.)
Code:
void PRTFuntion (unsigned char* whatCharToPrint )
{
char* pLCDByte = 0;
// print on each "page" is each page a color ?
for ( int LCDPage = 0 ; LCDPage <=3; LCDPage++) 
// going through the 4 pages of the
    {
    // ignoring space char for now because space 
    // is not next to 'A' in the ascii alphabet
    // access the first dimension of the array
    pLCDByte = ASCII[whatCharToPrint - 'A' + 1];
    // do the bytes making up the character 
    for ( int idxByte=0; idxByte <= 5; idxByte++)
    {
        // access the second dimension of the array
        outportb (DATALATCH, pLCDByte[idxByte] );
    }

}   // end function


char ASCII[27][6] =  /* as above */
Code:
// another way to access a two dim array
int idxToChar = whatCharToPrint - 'A' + 1;
for( int idxByte=0; idxByte <= 5; idxByte++)
    {
        // access both dimension of the array at once
        char toOutput = ASCII[idxToChar][idxByte];
        outportb (DATALATCH, toOutput );
    }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top